diff --git a/painter.py b/painter.py index 454d26b..1a28ebc 100644 --- a/painter.py +++ b/painter.py @@ -53,13 +53,18 @@ class Painter(Widget): def draw(self): self.canvas.clear() with self.canvas: + # draw order: particles, then grids, then transparent particles + + for particle in self.particles: + particle.draw() + # draw grids for particle in self.particles: if particle.grid>0: self.draw_grid(particle.squares[0].pos,particle.grid) for particle in self.particles: - particle.draw() + particle.draw(alpha=0.5) def draw_grid(self,pos,mesh): # height offset due to status bar and command prompt diff --git a/polyomino.py b/polyomino.py index 1b5aa22..4e39126 100644 --- a/polyomino.py +++ b/polyomino.py @@ -18,14 +18,15 @@ class Polyomino(): self.grid=kwargs.get("grid",0) # draw function - def draw(self): + def draw(self,**kwargs): + alpha=kwargs.get("alpha",1) # set color if not self.selected: - Color(*self.color) + Color(*self.color,alpha) else: (r,g,b)=self.color # darken selected - Color(r/2,g/2,b/2) + Color(r/2,g/2,b/2,alpha) for square in self.squares: Rectangle(pos=((square.pos.x-0.5)*square.size,(square.pos.y-0.5)*square.size),size=(square.size,square.size))