Set color of next particle

This commit is contained in:
Ian Jauslin 2024-02-21 16:49:48 -05:00
parent 0a8a0e3c53
commit ff11c1ce84

View File

@ -38,6 +38,9 @@ class Painter(Widget):
# shape of particle to add next # shape of particle to add next
self.shape=Cross self.shape=Cross
# color of particle to add next
self.color=(0,0,1)
# underlying lattice # underlying lattice
self.lattice=None self.lattice=None
@ -232,7 +235,7 @@ class Painter(Widget):
# create new particle # create new particle
if touch.button=="right": if touch.button=="right":
new=self.shape(touchx,touchy) new=self.shape(touchx,touchy,color=self.color)
# snap to lattice # snap to lattice
if self.lattice!=None: if self.lattice!=None:
new.move(self.lattice.nearest_delta(new.elements[0].pos)) new.move(self.lattice.nearest_delta(new.elements[0].pos))
@ -440,6 +443,9 @@ class Painter(Widget):
# set color of selected particles # set color of selected particles
def set_color(self,color): def set_color(self,color):
# set color for next particles
self.color=color
# set color of selected particles
for particle in self.selected: for particle in self.selected:
particle.color=color particle.color=color
# redraw # redraw