darken selected cross
This commit is contained in:
parent
e1960f631f
commit
8f1d841f14
21
cross.py
21
cross.py
@ -20,8 +20,9 @@ class Cross():
|
|||||||
self.pos.x=x
|
self.pos.x=x
|
||||||
self.pos.y=y
|
self.pos.y=y
|
||||||
|
|
||||||
def draw(self):
|
def draw(self,**kwargs):
|
||||||
Color(*(self.color))
|
# override color
|
||||||
|
Color(*(kwargs.get("color",self.color)))
|
||||||
Rectangle(pos=((self.pos.x-1.5)*self.size,(self.pos.y-0.5)*self.size),size=(3*self.size,self.size))
|
Rectangle(pos=((self.pos.x-1.5)*self.size,(self.pos.y-0.5)*self.size),size=(3*self.size,self.size))
|
||||||
Rectangle(pos=((self.pos.x-0.5)*self.size,(self.pos.y-1.5)*self.size),size=(self.size,3*self.size))
|
Rectangle(pos=((self.pos.x-0.5)*self.size,(self.pos.y-1.5)*self.size),size=(self.size,3*self.size))
|
||||||
|
|
||||||
@ -234,7 +235,13 @@ class Cross_painter(Widget):
|
|||||||
self.canvas.clear()
|
self.canvas.clear()
|
||||||
with self.canvas:
|
with self.canvas:
|
||||||
for cross in self.crosses:
|
for cross in self.crosses:
|
||||||
|
if cross!=self.selected:
|
||||||
cross.draw()
|
cross.draw()
|
||||||
|
# color selected
|
||||||
|
else:
|
||||||
|
(r,g,b)=cross.color
|
||||||
|
# darken
|
||||||
|
cross.draw(color=(r/2,g/2,b/2))
|
||||||
|
|
||||||
|
|
||||||
# respond to mouse down
|
# respond to mouse down
|
||||||
@ -252,15 +259,9 @@ class Cross_painter(Widget):
|
|||||||
|
|
||||||
# select cross
|
# select cross
|
||||||
if touch.button=="left":
|
if touch.button=="left":
|
||||||
# unselect
|
# select cross under touch
|
||||||
if self.selected!=None:
|
|
||||||
self.selected.selected=False
|
|
||||||
|
|
||||||
# find cross under touch
|
|
||||||
self.selected=self.find_cross(Point(touch.x/Cross.size,touch.y/Cross.size))
|
self.selected=self.find_cross(Point(touch.x/Cross.size,touch.y/Cross.size))
|
||||||
# select
|
self.draw()
|
||||||
if self.selected!=None:
|
|
||||||
self.selected.selected=True
|
|
||||||
|
|
||||||
|
|
||||||
# respond to drag
|
# respond to drag
|
||||||
|
Loading…
Reference in New Issue
Block a user