MCPcopy Index your code
hub / github.com/python/cpython / _goto

Method _goto

Lib/turtle.py:3262–3313  ·  view source on GitHub ↗

Move the pen to the point end, thereby drawing a line if pen is down. All other methods for turtle movement depend on this one.

(self, end)

Source from the content-addressed store, hash-verified

3260 self._update()
3261
3262 def _goto(self, end):
3263 """Move the pen to the point end, thereby drawing a line
3264 if pen is down. All other methods for turtle movement depend
3265 on this one.
3266 """
3267 ## Version with undo-stuff
3268 go_modes = ( self._drawing,
3269 self._pencolor,
3270 self._pensize,
3271 isinstance(self._fillpath, list))
3272 screen = self.screen
3273 undo_entry = ("go", self._position, end, go_modes,
3274 (self.currentLineItem,
3275 self.currentLine[:],
3276 screen._pointlist(self.currentLineItem),
3277 self.items[:])
3278 )
3279 if self.undobuffer:
3280 self.undobuffer.push(undo_entry)
3281 start = self._position
3282 if self._speed and screen._tracing == 1:
3283 diff = (end-start)
3284 diffsq = (diff[0]*screen.xscale)**2 + (diff[1]*screen.yscale)**2
3285 nhops = 1+int((diffsq**0.5)/(3*(1.1**self._speed)*self._speed))
3286 delta = diff * (1.0/nhops)
3287 for n in range(1, nhops):
3288 if n == 1:
3289 top = True
3290 else:
3291 top = False
3292 self._position = start + delta * n
3293 if self._drawing:
3294 screen._drawline(self.drawingLineItem,
3295 (start, self._position),
3296 self._pencolor, self._pensize, top)
3297 self._update()
3298 if self._drawing:
3299 screen._drawline(self.drawingLineItem, ((0, 0), (0, 0)),
3300 fill="", width=self._pensize)
3301 # Turtle now at end,
3302 if self._drawing: # now update currentLine
3303 self.currentLine.append(end)
3304 if isinstance(self._fillpath, list):
3305 self._fillpath.append(end)
3306 ###### vererbung!!!!!!!!!!!!!!!!!!!!!!
3307 self._position = end
3308 if self._creatingPoly:
3309 self._poly.append(end)
3310 if len(self.currentLine) > 42: # 42! answer to the ultimate question
3311 # of life, the universe and everything
3312 self._newLine()
3313 self._update() #count=True)
3314
3315 def _undogoto(self, entry):
3316 """Reverse a _goto. Used for undo()

Callers

nothing calls this directly

Calls 6

_updateMethod · 0.95
_newLineMethod · 0.95
_pointlistMethod · 0.80
_drawlineMethod · 0.80
pushMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected