|
From: Kevin A. <ka...@us...> - 2004-05-01 17:29:21
|
Update of /cvsroot/pythoncard/PythonCard In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20957 Modified Files: turtle.py Log Message: general cleanup, switched to True/False; round() before drawPoint/drawLine Index: turtle.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/turtle.py,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** turtle.py 21 Apr 2004 07:33:09 -0000 1.14 --- turtle.py 1 May 2004 17:29:13 -0000 1.15 *************** *** 15,19 **** def __init__(self): """ this should be called after a subclass has done its init """ ! self._tracing = 0 self._degrees() --- 15,19 ---- def __init__(self): """ this should be called after a subclass has done its init """ ! self._tracing = False self._degrees() *************** *** 201,205 **** if not self._visible: self._drawTurtle() ! self._visible = 1 def hideTurtle(self): --- 201,205 ---- if not self._visible: self._drawTurtle() ! self._visible = True def hideTurtle(self): *************** *** 209,213 **** if self._dirty: self._drawTurtle() ! self._visible = 0 def _drawTurtle(self): --- 209,213 ---- if self._dirty: self._drawTurtle() ! self._visible = False def _drawTurtle(self): *************** *** 217,225 **** def suspendOdometer(self): """suspends the turtle odometer""" ! self._odometerOn = 0 def resumeOdometer(self): """resumes the turtle odometer""" ! self._odometerOn = 1 def getOdometer(self): --- 217,225 ---- def suspendOdometer(self): """suspends the turtle odometer""" ! self._odometerOn = False def resumeOdometer(self): """resumes the turtle odometer""" ! self._odometerOn = True def getOdometer(self): *************** *** 234,242 **** """raises the turtle pen, so no drawing will occur on subsequent commands until the pen is lowered with penDown""" ! self._drawing = 0 def penDown(self): """lowers the turtle pen""" ! self._drawing = 1 """ --- 234,242 ---- """raises the turtle pen, so no drawing will occur on subsequent commands until the pen is lowered with penDown""" ! self._drawing = False def penDown(self): """lowers the turtle pen""" ! self._drawing = True """ *************** *** 312,328 **** #self._color = wx.Pen(wx.NamedColour("black")) ! self._origin = float(width)/2.0, float(height)/2.0 self._position = self._origin self._odometer = 0.0 ! self._odometerOn = 0 # don't waste time tracking unless requested self._angle = 0.0 ! self._drawing = 1 self._width = 1 self._filling = 0 self._path = [] self._tofill = [] ! self._dirty = 0 ! self._visible = 0 ! self._drawingTurtle = 0 self._turtleDelay = 0 --- 312,329 ---- #self._color = wx.Pen(wx.NamedColour("black")) ! self._origin = width/2.0, height/2.0 self._position = self._origin self._odometer = 0.0 ! # don't waste time tracking unless requested ! self._odometerOn = False self._angle = 0.0 ! self._drawing = True self._width = 1 self._filling = 0 self._path = [] self._tofill = [] ! self._dirty = False ! self._visible = False ! self._drawingTurtle = False self._turtleDelay = 0 *************** *** 335,339 **** y = self._position[1] drawingState = self._drawing ! self._drawing = 0 self._goto(x, y) self._drawing = drawingState --- 336,340 ---- y = self._position[1] drawingState = self._drawing ! self._drawing = False self._goto(x, y) self._drawing = drawingState *************** *** 378,382 **** # that means keeping the variable in a form that is # simple to compare to the underlying dc canvas ! self.canvas.drawPoint((x, y)) # other variations #self.dc.DrawLine(x, y, x+1, y+1) --- 379,383 ---- # that means keeping the variable in a form that is # simple to compare to the underlying dc canvas ! self.canvas.drawPoint((round(x), round(y))) # other variations #self.dc.DrawLine(x, y, x+1, y+1) *************** *** 390,394 **** self.canvas._bufImage.SetPen(self._pen) ###self.dc.DrawLine(x1, y1, x2, y2) ! self.canvas.drawLine((x1, y1), (x2, y2)) # probably replace this with a wxPython primitive for polygons --- 391,395 ---- self.canvas._bufImage.SetPen(self._pen) ###self.dc.DrawLine(x1, y1, x2, y2) ! self.canvas.drawLine((round(x1), round(y1)), (round(x2), round(y2))) # probably replace this with a wxPython primitive for polygons *************** *** 420,424 **** ###self.dc.Clear() self.canvas.clear() ! self._dirty = 0 # need to enhance this to support the various --- 421,425 ---- ###self.dc.Clear() self.canvas.clear() ! self._dirty = False # need to enhance this to support the various *************** *** 519,523 **** #if not self._drawingTurtle: self._dirty = not self._dirty ! self._drawingTurtle = 1 drawingState = self._drawing currentPos = self._position --- 520,524 ---- #if not self._drawingTurtle: self._dirty = not self._dirty ! self._drawingTurtle = True drawingState = self._drawing currentPos = self._position *************** *** 549,553 **** self._drawing = drawingState self._position = currentPos ! self._drawingTurtle = 0 if self._dirty and self._turtleDelay > 0: time.sleep(self._turtleDelay) --- 550,554 ---- self._drawing = drawingState self._position = currentPos ! self._drawingTurtle = False if self._dirty and self._turtleDelay > 0: time.sleep(self._turtleDelay) *************** *** 570,589 **** #AbstractTurtle.reset() ! self._origin = float(width)/2.0, float(height)/2.0 #print "width: %d, height: %d" % (width, height) #print "_origin.x: %f, _origin.y: %f" % (self._origin[0], self._origin[1]) self._position = self._origin self._odometer = 0.0 ! self._odometerOn = 0 # don't waste time tracking unless requested self._angle = 0.0 ! self._drawing = 1 # whether the pen is down self._width = 1 #self._filling = 0 #self._path = [] #self._tofill = [] ! self._visible = 0 # whether the turtle is visible, independent of the pen state ! self._dirty = 0 # if _dirty then erase old turtle before drawing ! self._drawingTurtle = 0 # only true while drawing the turtle ! self._turtleDelay = 0 # number of seconds to pause after drawing the turtle def _goto(self, x1, y1): --- 571,596 ---- #AbstractTurtle.reset() ! self._origin = width/2.0, height/2.0 #print "width: %d, height: %d" % (width, height) #print "_origin.x: %f, _origin.y: %f" % (self._origin[0], self._origin[1]) self._position = self._origin self._odometer = 0.0 ! # don't waste time tracking unless requested ! self._odometerOn = False self._angle = 0.0 ! # whether the pen is down ! self._drawing = True self._width = 1 #self._filling = 0 #self._path = [] #self._tofill = [] ! # whether the turtle is visible, independent of the pen state ! self._visible = False ! # if _dirty then erase old turtle before drawing ! self._dirty = False ! # only true while drawing the turtle ! self._drawingTurtle = False ! # number of seconds to pause after drawing the turtle ! self._turtleDelay = 0 def _goto(self, x1, y1): *************** *** 600,604 **** x0, y0 = start = self._position ! self._position = map(float, (x1, y1)) #if self._filling: # self._path.append(self._position) --- 607,611 ---- x0, y0 = start = self._position ! self._position = (float(x1), float(y1)) #if self._filling: # self._path.append(self._position) *************** *** 623,627 **** self.canvas._bufImage.SetPen(self._pen) ###self.dc.DrawLine(x0, y0, x1, y1) ! self.canvas.drawLine((x0, y0), (x1, y1)) if not self._drawingTurtle: --- 630,634 ---- self.canvas._bufImage.SetPen(self._pen) ###self.dc.DrawLine(x0, y0, x1, y1) ! self.canvas.drawLine((round(x0), round(y0)), (round(x1), round(y1))) if not self._drawingTurtle: |