transparency for grids
This commit is contained in:
parent
f0f090315a
commit
1c1e2ad6f7
@ -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
|
||||
|
@ -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))
|
||||
|
Loading…
Reference in New Issue
Block a user