summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1998-10-24 16:29:21 (GMT)
committerGuido van Rossum <guido@python.org>1998-10-24 16:29:21 (GMT)
commit5ac15bc9c82b8d3d32402f733197c8f1e78892f3 (patch)
tree6007daaf49316ec65fec321010b9763a6ddd47a2
parent2457fc2a816aa7c9ca0be82a4595567204d5457e (diff)
downloadcpython-5ac15bc9c82b8d3d32402f733197c8f1e78892f3.zip
cpython-5ac15bc9c82b8d3d32402f733197c8f1e78892f3.tar.gz
cpython-5ac15bc9c82b8d3d32402f733197c8f1e78892f3.tar.bz2
Split the goto() function in two: _goto() is the internal one,
using Canvas coordinates, and goto() uses turtle coordinates and accepts variable argument lists.
-rw-r--r--Tools/idle/turtle.py14
1 files changed, 9 insertions, 5 deletions
diff --git a/Tools/idle/turtle.py b/Tools/idle/turtle.py
index 15b4138..9aa0835 100644
--- a/Tools/idle/turtle.py
+++ b/Tools/idle/turtle.py
@@ -55,7 +55,7 @@ class RawPen:
x0, y0 = start = self._position
x1 = x0 + distance * cos(self._angle*self._invradian)
y1 = y0 - distance * sin(self._angle*self._invradian)
- self.goto(x1, y1)
+ self._goto(x1, y1)
def backward(self, distance):
self.forward(-distance)
@@ -106,14 +106,14 @@ class RawPen:
def write(self, arg, move=0):
x, y = start = self._position
+ x = x-1 # correction -- calibrated for Windows
item = self._canvas.create_text(x, y,
text=str(arg), anchor="sw",
fill=self._color)
self._items.append(item)
if move:
x0, y0, x1, y1 = self._canvas.bbox(item)
- x1 = x1-1 # correction -- calibrated for Windows
- self.goto(x1, y1)
+ self._goto(x1, y1)
def fill(self, flag):
if self._filling:
@@ -187,14 +187,18 @@ class RawPen:
def goto(self, *args):
if len(args) == 1:
try:
- x1, y1 = args[0]
+ x, y = args[0]
except:
raise Error, "bad point argument: %s" % `args[0]`
else:
try:
- x1, y1 = args
+ x, y = args
except:
raise Error, "bad coordinates: %s" % `args[0]`
+ x0, y0 = self._origin
+ self._goto(x0+x, y0-y)
+
+ def _goto(self, x1, y1):
x0, y0 = start = self._position
self._position = map(float, (x1, y1))
if self._filling: