diff --git a/cross.py b/cross.py index be952d9..a0f11b5 100644 --- a/cross.py +++ b/cross.py @@ -20,8 +20,9 @@ class Cross(): self.pos.x=x self.pos.y=y - def draw(self): - Color(*(self.color)) + def draw(self,**kwargs): + # 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-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() with self.canvas: for cross in self.crosses: - cross.draw() + if cross!=self.selected: + cross.draw() + # color selected + else: + (r,g,b)=cross.color + # darken + cross.draw(color=(r/2,g/2,b/2)) # respond to mouse down @@ -252,15 +259,9 @@ class Cross_painter(Widget): # select cross if touch.button=="left": - # unselect - if self.selected!=None: - self.selected.selected=False - - # find cross under touch + # select cross under touch self.selected=self.find_cross(Point(touch.x/Cross.size,touch.y/Cross.size)) - # select - if self.selected!=None: - self.selected.selected=True + self.draw() # respond to drag