From 8f1d841f14d18f7bd0a4c8dd51ffc92f4b4efdcc Mon Sep 17 00:00:00 2001 From: Ian Jauslin Date: Wed, 20 Oct 2021 01:05:20 -0400 Subject: [PATCH] darken selected cross --- cross.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) 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