Set shape from command
This commit is contained in:
parent
955aa8f10a
commit
b1d56fea04
@ -20,6 +20,7 @@ import os.path
|
|||||||
|
|
||||||
import filecheck
|
import filecheck
|
||||||
import colors
|
import colors
|
||||||
|
from polyomino import Cross,Disk
|
||||||
|
|
||||||
class Command_prompt(Label):
|
class Command_prompt(Label):
|
||||||
|
|
||||||
@ -338,6 +339,9 @@ class Command_prompt(Label):
|
|||||||
if argv[1]=="color":
|
if argv[1]=="color":
|
||||||
self.run_set_color(argv)
|
self.run_set_color(argv)
|
||||||
return
|
return
|
||||||
|
elif argv[1]=="shape":
|
||||||
|
self.run_set_shape(argv)
|
||||||
|
return
|
||||||
elif argv[1]=="grid":
|
elif argv[1]=="grid":
|
||||||
self.run_set_grid(argv)
|
self.run_set_grid(argv)
|
||||||
return
|
return
|
||||||
@ -372,6 +376,19 @@ class Command_prompt(Label):
|
|||||||
return
|
return
|
||||||
self.app.painter.set_color(color)
|
self.app.painter.set_color(color)
|
||||||
|
|
||||||
|
# set particle shape
|
||||||
|
def run_set_shape(self,argv):
|
||||||
|
if len(argv)<3:
|
||||||
|
self.message="error: 'set shape' command was run with without an argument -- usage: 'set shape <shape_descriptor>'"
|
||||||
|
return
|
||||||
|
elif argv[2]=="cross":
|
||||||
|
self.app.painter.shape=Cross
|
||||||
|
elif argv[2]=="disk":
|
||||||
|
self.app.painter.shape=Disk
|
||||||
|
else:
|
||||||
|
self.message="error: unrecognized shape '"+argv[2]+"'; supported shapes are cross|disk"
|
||||||
|
return
|
||||||
|
|
||||||
# toggle grid
|
# toggle grid
|
||||||
def run_set_grid(self,argv):
|
def run_set_grid(self,argv):
|
||||||
if len(argv)==2:
|
if len(argv)==2:
|
||||||
|
@ -35,6 +35,9 @@ class Painter(Widget):
|
|||||||
# list of particles
|
# list of particles
|
||||||
self.particles=[]
|
self.particles=[]
|
||||||
|
|
||||||
|
# shape of particle to add next
|
||||||
|
self.shape=Cross
|
||||||
|
|
||||||
# underlying lattice
|
# underlying lattice
|
||||||
self.lattice=None
|
self.lattice=None
|
||||||
|
|
||||||
@ -229,8 +232,7 @@ class Painter(Widget):
|
|||||||
|
|
||||||
# create new particle
|
# create new particle
|
||||||
if touch.button=="right":
|
if touch.button=="right":
|
||||||
new=Cross(touchx,touchy)
|
new=self.shape(touchx,touchy)
|
||||||
#new=Disk(touchx,touchy)
|
|
||||||
# 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))
|
||||||
|
Loading…
Reference in New Issue
Block a user