Added painbrush - incomplete

This commit is contained in:
Skyler Lehmkuhl 2012-01-10 23:15:06 -05:00
parent dc64c2d1a9
commit 6803073dc4
1 changed files with 12 additions and 7 deletions

View File

@ -52,11 +52,13 @@ def onMouseDownGroup(self, x, y):
if svlgui.MODE in [" ", "s"]: if svlgui.MODE in [" ", "s"]:
if self.hitTest(x, y): if self.hitTest(x, y):
self.clicked = True self.clicked = True
elif svlgui.MODE in ["r", "e"]: elif svlgui.MODE in ["r", "e", "p"]:
if svlgui.MODE=="r": if svlgui.MODE=="r":
self.cshape = box(x, y, 0, 0) self.cshape = box(x, y, 0, 0)
elif svlgui.MODE=="e": elif svlgui.MODE=="e":
self.cshape = ellipse(x, y, 0, 0) self.cshape = ellipse(x, y, 0, 0)
elif svlgui.MODE=="p":
self.cshape = shape(x, y)
#self.cshape.rotation = 5 #self.cshape.rotation = 5
self.cshape.initx,self.cshape.inity = x, y self.cshape.initx,self.cshape.inity = x, y
self.add(self.cshape) self.add(self.cshape)
@ -102,26 +104,28 @@ def onMouseDragGroup(self, x, y):
x=x-self.cshape.initx x=x-self.cshape.initx
y=y-self.cshape.inity y=y-self.cshape.inity
self.cshape.shapedata = [["M",x/2,0],["C",4*x/5,0,x,y/5,x,y/2],["C",x,4*y/5,4*x/5,y,x/2,y],["C",x/5,y,0,4*y/5,0,y/2],["C",0,y/5,x/5,0,x/2,0]] self.cshape.shapedata = [["M",x/2,0],["C",4*x/5,0,x,y/5,x,y/2],["C",x,4*y/5,4*x/5,y,x/2,y],["C",x/5,y,0,4*y/5,0,y/2],["C",0,y/5,x/5,0,x/2,0]]
elif svlgui.MODE == "p":
self.cshape.shapedata.append(["L",x-self.cshape.initx,y-self.cshape.inity])
def onMouseDragObj(self, x, y): def onMouseDragObj(self, x, y):
self.x = x-self.initx self.x = x-self.initx
self.y = y-self.inity self.y = y-self.inity
def onKeyDownGroup(self, key): def onKeyDownGroup(self, key):
pass pass
if key in [" ", "s", "r", "e", "b"]: if key in [" ", "s", "r", "e", "b", "p"]:
svlgui.MODE=key svlgui.MODE=key
svlgui.set_cursor({" ":"arrow","s":"arrow","r":"crosshair","e":"crosshair", svlgui.set_cursor({" ":"arrow","s":"arrow","r":"crosshair","e":"crosshair",
"b":"arrow"}[key], MainWindow.stage) "b":"arrow","p":"arrow"}[key], MainWindow.stage)
elif key=="F6": elif key=="F6":
add_keyframe() add_keyframe()
print "Added keyframe." print "Added keyframe."
def onKeyDownObj(self, key): def onKeyDownObj(self, key):
if key in ("delete", "backspace"): if key in ("delete", "backspace"):
del self.parent[self.parent.index(self)] # Need to clean up deletion del self.parent[self.parent.index(self)] # Need to clean up deletion
elif key in [" ", "s", "r", "e", "b"]: elif key in [" ", "s", "r", "e", "b", "p"]:
svlgui.MODE=key svlgui.MODE=key
svlgui.set_cursor({" ":"arrow","s":"arrow","r":"crosshair","e":"crosshair", svlgui.set_cursor({" ":"arrow","s":"arrow","r":"crosshair","e":"crosshair",
"b":"arrow"}[key], MainWindow.stage) "b":"arrow","p":"arrow"}}[key], MainWindow.stage)
elif key=="F6": elif key=="F6":
add_keyframe() add_keyframe()
@ -154,8 +158,9 @@ def ellipse(x, y, width, height, fill=svlgui.FILLCOLOR):
# must figure out shapedata... # must figure out shapedata...
return ellipse return ellipse
def shape(x, y, fill): def shape(x, y, fill=None):
shape = svlgui.Shape() shape = svlgui.Shape(x,y)
shape.shapedata = [["M",0,0]]
return shape return shape
root = svlgui.Group() root = svlgui.Group()