Returning to actual shape drawing, cleaned up a print

This commit is contained in:
Skyler Lehmkuhl 2013-11-28 00:41:43 -05:00
parent 7318989db3
commit 2044659c3c
1 changed files with 18 additions and 10 deletions

View File

@ -118,8 +118,15 @@ def onMouseDownGroup(self, x, y,button=1,clicks=1):
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": elif svlgui.MODE=="p":
# self.cshape = shape(x, y) for i in self.lines:
self.cshape = svlgui.Line(svlgui.Point(x, y),svlgui.Point(x,y)) if abs(x-i.endpoint1.x)<10 and abs(y-i.endpoint1.y)<10:
x, y = i.endpoint1.x, i.endpoint1.y
break
elif abs(x-i.endpoint2.x)<10 and abs(i.endpoint2.y)<10:
x, y = i.endpoint2.x, i.endpoint2.y
break
self.cshape = shape(x, y)
'''self.cshape = svlgui.Line(svlgui.Point(x, y),svlgui.Point(x,y))
for i in self.lines: for i in self.lines:
if abs(self.cshape.endpoint1.x-i.endpoint1.x)<10 and abs(self.cshape.endpoint1.y-i.endpoint1.y)<10: if abs(self.cshape.endpoint1.x-i.endpoint1.x)<10 and abs(self.cshape.endpoint1.y-i.endpoint1.y)<10:
self.cshape.connection1 = i.endpoint1 self.cshape.connection1 = i.endpoint1
@ -130,7 +137,7 @@ def onMouseDownGroup(self, x, y,button=1,clicks=1):
self.cshape.connection1.lines.add(self.cshape) self.cshape.connection1.lines.add(self.cshape)
break break
self.lines.append(self.cshape) self.lines.append(self.cshape)
return return'''
#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)
@ -197,10 +204,11 @@ def onMouseUpGroup(self, x, y,button=1,clicks=1):
undo_stack[-1] = undo_stack[-1].complete({"obj":cobj, "frame":self.activelayer.currentframe, "layer":self.activelayer}) undo_stack[-1] = undo_stack[-1].complete({"obj":cobj, "frame":self.activelayer.currentframe, "layer":self.activelayer})
clear(redo_stack) clear(redo_stack)
elif svlgui.MODE=="p": elif svlgui.MODE=="p":
'''print len(self.cshape.shapedata) prelen = len(self.cshape.shapedata)
self.cshape.shapedata = misc_funcs.simplify_shape(self.cshape.shapedata, svlgui.PMODE.split()[-1],1) self.cshape.shapedata = misc_funcs.simplify_shape(self.cshape.shapedata, svlgui.PMODE.split()[-1],1)
print len(self.cshape.shapedata)''' postlen = len(self.cshape.shapedata)
for i in self.lines: print str((prelen-postlen)*100/prelen)+"% reduction: started at "+str(prelen)+" vertices, ended at "+str(postlen)+" vertices"
'''for i in self.lines:
if abs(self.cshape.endpoint2.x-i.endpoint1.x)<10 and abs(self.cshape.endpoint2.y-i.endpoint1.y)<10: if abs(self.cshape.endpoint2.x-i.endpoint1.x)<10 and abs(self.cshape.endpoint2.y-i.endpoint1.y)<10:
self.cshape.connection2 = i.endpoint1 self.cshape.connection2 = i.endpoint1
self.cshape.connection2.lines.add(self.cshape) self.cshape.connection2.lines.add(self.cshape)
@ -208,7 +216,7 @@ def onMouseUpGroup(self, x, y,button=1,clicks=1):
elif abs(self.cshape.endpoint2.x-i.endpoint2.x)<10 and abs(self.cshape.endpoint2.y-i.endpoint2.y)<10: elif abs(self.cshape.endpoint2.x-i.endpoint2.x)<10 and abs(self.cshape.endpoint2.y-i.endpoint2.y)<10:
self.cshape.connection2 = i.endpoint2 self.cshape.connection2 = i.endpoint2
self.cshape.connection2.lines.add(self.cshape) self.cshape.connection2.lines.add(self.cshape)
break break'''
self.cshape = None self.cshape = None
MainWindow.stage.draw() MainWindow.stage.draw()
def onMouseUpObj(self, x, y,button=1,clicks=1): def onMouseUpObj(self, x, y,button=1,clicks=1):
@ -267,9 +275,9 @@ def onMouseDragGroup(self, x, y,button=1,clicks=1):
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": elif svlgui.MODE == "p":
# self.cshape.shapedata.append(["L",x-self.cshape.initx,y-self.cshape.inity]) self.cshape.shapedata.append(["L",x-self.cshape.initx,y-self.cshape.inity])
self.cshape.endpoint2.x = x # self.cshape.endpoint2.x = x
self.cshape.endpoint2.y = y # self.cshape.endpoint2.y = y
def onMouseDragObj(self, x, y,button=1,clicks=1): def onMouseDragObj(self, x, y,button=1,clicks=1):
if svlgui.MODE==" ": if svlgui.MODE==" ":
self.x = x-self.initx self.x = x-self.initx