python (3.12.0)

(root)/
lib/
python3.12/
__pycache__/
turtle.cpython-312.opt-1.pyc

ˑe;^dZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
mZmZddl
mZddlmZgdZgdZgdZd	d
gZeezezezdgzZgdZid
ddddddddddddddddddddd d!d"d#d"d$d%d&d'd(d)d*d+d,d-d.d/Zd0Zd1Z	eeGd3d4eZd5Zd6Zd7Zdgd8Z Gd9d:ejBZ"e e"ejFd;Gd<d=ejHZ%ejFZ#Gd>d?e&Z'Gd@deZ(GdAdBeZ)GdCdDe&Z*GdEdFe&Z+GdGdHe'Z,GdIdJe&Z-GdKdLe&Z.GdMdNe&Z/GdOdPe.e-Z0e0Z1dQZ2GdRdSe,Z3GdTdUe0Z4e4Z5dhdVZ6dWZ7ed(Z8	e8d)k7re7e8dZZ:d[Z;d\Z<d]Z=d^Z>e>ee3d_d`e<e>ee4dadbe;e?Z@eAdck(rddZBdeZCdfZDeCeDeEyy#e$red2YdwxYw#e9$redXe8Yqe$redYe8zYwxYw)ia

Turtle graphics is a popular way for introducing programming to
kids. It was part of the original Logo programming language developed
by Wally Feurzig and Seymour Papert in 1966.

Imagine a robotic turtle starting at (0, 0) in the x-y plane. After an ``import turtle``, give it
the command turtle.forward(15), and it moves (on-screen!) 15 pixels in
the direction it is facing, drawing a line as it moves. Give it the
command turtle.right(25), and it rotates in-place 25 degrees clockwise.

By combining together these and similar commands, intricate shapes and
pictures can easily be drawn.

----- turtle.py

This module is an extended reimplementation of turtle.py from the
Python standard distribution up to Python 2.5. (See: https://www.python.org)

It tries to keep the merits of turtle.py and to be (nearly) 100%
compatible with it. This means in the first place to enable the
learning programmer to use all the commands, classes and methods
interactively when using the module from within IDLE run with
the -n switch.

Roughly it has the following features added:

- Better animation of the turtle movements, especially of turning the
  turtle. So the turtles can more easily be used as a visual feedback
  instrument by the (beginning) programmer.

- Different turtle shapes, gif-images as turtle shapes, user defined
  and user controllable turtle shapes, among them compound
  (multicolored) shapes. Turtle shapes can be stretched and tilted, which
  makes turtles very versatile geometrical objects.

- Fine control over turtle movement and screen updates via delay(),
  and enhanced tracer() and speed() methods.

- Aliases for the most commonly used commands, like fd for forward etc.,
  following the early Logo traditions. This reduces the boring work of
  typing long sequences of commands, which often occur in a natural way
  when kids try to program fancy pictures on their first encounter with
  turtle graphics.

- Turtles now have an undo()-method with configurable undo-buffer.

- Some simple commands/methods for creating event driven programs
  (mouse-, key-, timer-events). Especially useful for programming games.

- A scrollable Canvas class. The default scrollable Canvas can be
  extended interactively as needed while playing around with the turtle(s).

- A TurtleScreen class with methods controlling background color or
  background image, window and canvas size and other properties of the
  TurtleScreen.

- There is a method, setworldcoordinates(), to install a user defined
  coordinate-system for the TurtleScreen.

- The implementation uses a 2-vector class named Vec2D, derived from tuple.
  This class is public, so it can be imported by the application programmer,
  which makes certain types of computations very natural and compact.

- Appearance of the TurtleScreen and the Turtles at startup/import can be
  configured by means of a turtle.cfg configuration file.
  The default configuration mimics the appearance of the old turtle module.

- If configured appropriately the module reads in docstrings from a docstring
  dictionary in some different language, supplied separately  and replaces
  the English ones by those read in. There is a utility function
  write_docstringdict() to write a dictionary with the original (English)
  docstrings to disc, so it can serve as a template for translations.

Behind the scenes there are some features included with possible
extensions in mind. These will be commented and documented elsewhere.
N)isfilesplitjoin)deepcopy)simpledialog)	ScrolledCanvasTurtleScreenScreen	RawTurtleTurtleRawPenPenShapeVec2D)addshapebgcolorbgpicbyeclearscreen	colormodedelayexitonclick	getcanvas	getshapeslistenmainloopmodenuminputonkey
onkeypressonkeyrelease
onscreenclickontimerregister_shaperesetscreen
screensizesetupsetworldcoordinates	textinputtitletracerturtlesupdate
window_heightwindow_width)Pbackbackward
begin_fill
begin_polybkcircleclear
clearstampclearstampsclonecolordegreesdistancedotdownend_fillend_polyfd	fillcolorfillingforwardget_polygetpen	getscreen
get_shapepoly	getturtlegotoheading
hideturtlehomehtisdown	isvisibleleftltonclickondrag	onreleasepdpenpencolorpendownpensizepenuppospositionpuradiansrightreset
resizemodertseth
setheadingsetpossetpositionsettiltangle
setundobuffersetxsetyshape	shapesizeshapetransformshearfactor
showturtlespeedststampteleporttilt	tiltangletowards
turtlesizeundoundobufferentriesupwidthwritexcorycorwrite_docstringdictdone
Terminator)rr1r4rArNrRrVr\r^rcrdrfrgrrrxr{r|r|?heightg?	canvwidthi
canvheighti,	leftright	topbottomrstandardr?r
undobuffersizeirlclassicrXblackrBrbnoresizevisibleTlanguageenglish
exampleturtleturtlescreenzPython Turtle GraphicsF)
examplescreenr*
using_IDLEct|d5}|j}dddi}D]}|j}|r|jdr'	|j	d\}}|j}|j}|dvrt|}n	d|vrt|}nt|}|||<|S#1swYxYw#t
$rt
d|d|YwxYw#t
$rY@wxYw)	z/Convert content of config-file into dictionary.rN#=zBad line in config-file z:
)TrueFalseNonez''z"".)
open	readlinesstrip
startswithr
ValueErrorprintevalfloatint)filenamefcfglinescfgdictlinekeyvalues       :/BuggyBox/python/3.12.0/bootstrap/lib/python3.12/turtle.pyconfig_dictrs	
h	!;;=!Gzz|ts+	CJCiik
99KE
%<!%LEJE+,N3!!	xEF	

s/B;CC';CC$#C$'	C32C3c4d}i}i}t|rt|}d|vrd|dz}	tt\}}t	||}t|rt|}tj|tj|y#t
$rd}YNwxYw)a@Read config-files, change configuration-dict accordingly.

    If there is a turtle.cfg file in the current working directory,
    read it from there. If this contains an importconfig-value,
    say 'myway', construct filename turtle_mayway.cfg else use
    turtle.cfg and read it from the import-directory, where
    turtle.py is located.
    Update configuration dictionary first according to config-file,
    in the import directory, then according to config-file in the
    current working directory.
    If no config-file is found, the default configuration is used.
    z
turtle.cfgimportconfigz
turtle_%s.cfgN)rrr__file__r	Exception_CFGr-)rdefault_cfgcfgdict1cfgdict2headtail	cfg_file2s       r
readconfigrsKHH
k{+!%(@@8_
d{+	iy)KKKK	sB		BBz"No configfile read, reason unknowncLeZdZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZ
y)
raA 2 dimensional vector class, used as a helper class
    for implementing turtle graphics.
    May be useful for turtle graphics programs also.
    Derived from tuple, so a vector is a tuple!

    Provides (for a, b vectors, k number):
       a+b vector addition
       a-b vector subtraction
       a*b inner product
       k*a and a*k multiplication with scalar
       |a| absolute value of a
       a.rotate(angle) rotation
    c2tj|||fSN)tuple__new__)clsxys   rrz
Vec2D.__new__s}}S1a&))c>t|d|dz|d|dzSNrrselfothers  r__add__z
Vec2D.__add__)T!WU1X%tAwuQx'788rct|tr|d|dz|d|dzzSt|d|z|d|zSr)
isinstancerrs  r__mul__z
Vec2D.__mul__sNeU#758#DGE!H$444T!WU]DGEM22rc~t|tst|trt|d|z|d|zStSr)rrrrNotImplementedrs  r__rmul__zVec2D.__rmul__s8eS!Zu%=aQ
66rc>t|d|dz
|d|dz
Srrrs  r__sub__z
Vec2D.__sub__rrc*t|d|dSrrrs r__neg__z
Vec2D.__neg__sd1gXQx((rc&tj|Sr)mathhypotrs r__abs__z
Vec2D.__abs__szz4  rct|d|d}tj|}tj|tj|}}t|d|z|d|zz|d|z|d|zzS)z.rotate self counterclockwise by angle
        rr)rrr_cossin)rangleperpcss     rrotatezVec2D.rotatesxd1gXtAw'U#xx1T!WQYtAwqy($q'!)DGAI*=>>rc|d|dfSrrs r__getnewargs__zVec2D.__getnewargs__sQa!!rcd|zS)Nz(%.2f,%.2f)rrs r__repr__zVec2D.__repr__s
t##rN)__name__
__module____qualname____doc__rrrrrrrrrrrrrrrs9*939)!?"$rrct|j}|j|D]}t|||jjD]'\}}t
|tjk(s#|||<)y)#helper function for Scrolled CanvasN)	list	__bases__reverse__methodDict__dict__itemstypetypesFunctionType)r_dictbaseList_superrrs      rrrspCMM"H$VU#$ll((*
U;%,,,E#Jrc>i}t|||jS)r)rkeys)rrs  r	__methodsr&sEe::<rzTdef %(method)s(self, *args, **kw): return self.%(attribute)s.%(method)s(*args, **kw)cPi}t||i}t|}|jD]#}|dddk(s|dddk(s||vs||vr||||<%|jD]B\}}	||	d}
t	|t
rt||dz}t|
t|||
|Dy)Nr_)methodfunc)r	attribute)	rrrrrstr__stringBodyexecsetattr)	fromClasstoClasstoPartexclude_dict_1rmfcexrrd
execStrings            r__forwardmethodsr0sG'"E
I
Clln$
bq6S=BrsGsNbGmrSyE"I	$
.t,fc"6HH
Z	61V9-
.rcTeZdZdZ		d
dZddZdZdZdZdZ	d	Z
d
ZdZdZ
y)rzModeled after the scrolled canvas class from Grayons's Tkinter book.

    Used as the default canvas, which pops up automatically when
    using turtle graphics functions or the Turtle class.
    c
$tjj|||||j|_||c|_|_||c|_|_d|_	tj||||jtjd|_tj||jjtj|_tj||jj"|_|jj'|j j(|j$j(|j+dd	d
|j-dd	d
|jj/d	|d	ddd	d	d|j$j/d	|d	dd	d	d	d|j j/d	|d	d	dd	d	d|j1|jj3d
|j4y)N)r|rwhite)r|rbgreliefborderwidth)commandorient)r)xscrollcommandyscrollcommandrr)weightminsizenewspadxin_padyrowcolumnrowspan
columnspanstickyz<Configure>)TKFrame__init__winfo_toplevel_rootwindowr|rrrrCanvasSUNKEN_canvas	Scrollbarxview
HORIZONTALhscrollyviewvscroll	configuresetrowconfigurecolumnconfiguregridrabindonResize)rmasterr|rrrs      rr/zScrolledCanvas.__init__Ks
$eFC..0"'
DK*3Z'yyuV$(GGBII1N||FDLL4F4F+-==:||FDLL4F4FGdll.>.>.2ll.>.>		@!Aq1Qq!4q1!!&		Bq1!!&		Bq1!!&		B

mT]];rNc|r||_|r||_|r||_|jj	||jdz|jdz|jdz|jdzf|jjd|j|jz
dzz|jz|jjd|j|jz
dzz|jz|jy)z<Adjust canvas and scrollbars according to given canvas size.r)rscrollregionrN)
rrrr4configxview_movetor|yview_movetor
adjustScrollsrrrrs    rrazScrolledCanvas.resetds&DN(DO
DGr'+~~oq&84??:JA:M'+~~q'8$//1:L&N		O	
!!#t~~

'BR'G"H?C~~#N	O!!#t'Cb'H"I>Boo#N	Orc
~|jj}|jj}|jjd|j|z
z|jz|jjd|j|z
z|jz||jks||jkrG|jjd|dddddd|jjd|ddddddy|jj|jjy)zA Adjust scrollbars according to window- and canvas-size.
        rrrr#r$N)r4winfo_widthwinfo_heightrGrrHrr8r?r:grid_forget)rcwidthcheights   rrIzScrolledCanvas.adjustScrollsvs))+,,++-!!#t~~f'<"=dnn"LM!!#tw'>"?"OPDNN"g&?LL1Dqa%&a

PLL1Dqa%&a

P
LL$$&LL$$&rc$|jy)zself-explanatoryN)rI)revents  rrAzScrolledCanvas.onResizesrc4|jj|S@ 'forward' method, which canvas itself has inherited...
        )r4bboxrargss  rrVzScrolledCanvas.bboxs!t||  $''rc:|jj|i|SrT)r4cgetrrXkwargss   rrZzScrolledCanvas.cgets !t||  $1&11rc<|jj|i|yrUN)r4rFr[s   rrFzScrolledCanvas.config	T,V,rc<|jj|i|yr^)r4r@r[s   rr@zScrolledCanvas.binds	4*6*rc<|jj|i|yr^)r4unbindr[s   rrbzScrolledCanvas.unbindr_rc8|jjyr^)r4focus_forcers rrdzScrolledCanvas.focus_forces	
  "r)i^iXreNNN)rrrrr/rarIrArVrZrFr@rbrdrrrrrEsA
25DG<2$' (
2
-
+
-
#rrr4c:eZdZdZdZdZdZdZdZdZ	dZ
y	)
_Rootz'Root class for Screen based on Tkinter.cBtjj|yr)r-Tkr/rs rr/z_Root.__init__s
trcft||||||_|jjddy)Nrboth)expandfill)rr4pack)rr|rrOrPs     rsetupcanvasz_Root.setupcanvass-%dE667K0rc|jSr)r4rs r
_getcanvasz_Root._getcanvass||rc4|jd||||fzy)Nz%dx%d%+d%+d)geometry)rr|rstartxstartys     rset_geometryz_Root.set_geometrys

mUFFF$CCDrc(|jd|y)NWM_DELETE_WINDOW)wm_protocol)rdestroys  r	ondestroyz_Root.ondestroys+W5rc"|jSr)winfo_screenwidthrs r	win_widthz_Root.win_widths%%''rc"|jSr)winfo_screenheightrs r
win_heightz_Root.win_heights&&((rN)rrrrr/rprrrwr|rrrrrrhrhs)11E6()rrhceZdZdZdZdZdZdZ		d$dZdZ			d$d	Z
d
ZdZdZ
d
Zd%dZdZd&dZd&dZd&dZd&dZdZd%dZdZdZdZdZdZdZdZdZdZd'dZ d Z!d!Z"d"Z#d'd#Z$y)(TurtleScreenBasezProvide the basic graphics functionality.
       Interface between Tkinter and turtle.py.

       To port turtle.py to some different graphics toolkit
       a corresponding TurtleScreenBase class has to be implemented.
    cjtjdd|j}|j|S)z$return a blank image object
        r)r|rrB)r-
PhotoImagecvblank)rimgs  r_blankimagezTurtleScreenBase._blankimages(mm!Adgg>		
rcDtj||jS)z`return an image object containing the
        imagedata from a gif-file named filename.
        )filerB)r-rr)rrs  r_imagezTurtleScreenBase._images}}(477;;rc||_t|tr-|jj}|jj}nvt|jj
d}t|jj
d}|jj|dz|dz|dz|dzf||_||_dx|_|_	y)Nr|rrrDr)
rrrrrrrZrFxscaleyscale)rrwhs    rr/zTurtleScreenBase.__init__sb.)!!A""ADGGLL)*ADGGLL*+AGGNNA2q51"a%Aq!t*ENF$''dkrc>|jjdddS)z<Create an invisible polygon item on canvas self.cv)
        )rrrrrrrrnoutline)rcreate_polygonrs r_createpolyzTurtleScreenBase._createpolys!ww%%&8r2%NNrNcg}|D]B\}}	|j||jz|j|	|jzD|jj|g|||jj||||jj||||jj|||r|jj
|yy)a`Configure polygonitem polyitem according to provided
        arguments:
        coordlist is sequence of coordinates
        fill is filling color
        outline is outline color
        top is a boolean value, which specifies if polyitem
        will be put on top of the canvas' displaylist so it
        will not be covered by other items.
        Nrn)rr|appendrrrcoords
itemconfigure	tag_raise)
rpolyitem	coordlistrnrr|topclrrs
          r	_drawpolyzTurtleScreenBase._drawpolys	(DAqIIa$++o&IIqb4;;&'	(	x%"%GG!!(!6GG!!(G!<GG!!(%!8GGh'rc	b|jjddddddtjS)z9Create an invisible line item on canvas self.cv)
        rrr)rnr|capstyle)rcreate_liner-ROUNDrs r_createlinezTurtleScreenBase._createlines3ww""1aABa.0hh#8	8rc|fg}|D]B\}}|j||jz|j||jzD|jj|g|||jj||||jj|||r|jj
|yy)aQConfigure lineitem according to provided arguments:
        coordlist is sequence of coordinates
        fill is drawing color
        width is width of drawn line.
        top is a boolean value, which specifies if polyitem
        will be put on top of the canvas' displaylist so it
        will not be covered by other items.
        Nrrr)	rlineitemrrnr|rrrrs	         r	_drawlinezTurtleScreenBase._drawlines B!
,1		!dkk/*		1"t{{*+
,
DGGNN8)b)GG!!(!6GG!!(%!8GGh'rc:|jj|y)z]Delete graphics item from canvas.
        If item is"all" delete all graphics items.
        N)rdeleteritems  r_deletezTurtleScreenBase._delete#s	
trc8|jjy)z(Redraw graphics items on canvas
        N)rr-rs r_updatezTurtleScreenBase._update)s	
rc:|jj|y)z-Delay subsequent canvas actions for delay ms.N)rafterrrs  r_delayzTurtleScreenBase._delay.s

ercz	|jj|}d}|S#tj$rd}Y|SwxYw)zCCheck if the string color is a legal Tkinter color string.
        TF)r	winfo_rgbr-TclError)rr:rgboks    r_iscolorstringzTurtleScreenBase._iscolorstring2sF	''##E*CB	{{	B		s!::c|-|jj||jy|jjdS)zVSet canvas' backgroundcolor if color is not None,
        else return backgroundcolor.N)rr)rrFrrZ)rr:s  r_bgcolorzTurtleScreenBase._bgcolor<s8GGNNN&LLN77<<%%rc|\}}||jz}||jz}dddd}|jj|dz
||||||}	|jj	|	\}
}}}
|	|dz
fS)zWrite txt at pos in canvas with specified font
        and color.
        Return text item and x-coord of right bottom corner
        of text's bounding box.swrse)rQcenterr`r)textanchorrnfont)rrrcreate_textrV)rr\txtalignrrXrrrrx0y0x1y1s              r_writezTurtleScreenBase._writeEs
1
O
OT;ww""1Q33/7#Fd+BBRTzrc jj|d|zyfd}jj|d|z||y)zBind fun to mouse-click event on turtle.
        fun must be a function with two arguments, the coordinates
        of the clicked point on the canvas.
        num, the number of the mouse-button defaults to 1
        N<Button-%s>cjj|jjzjj	|j
jz}}||yrrcanvasxrrcanvasyrrrRrrfunrs   reventfunz+TurtleScreenBase._onclick.<locals>.eventfun\P0<11$++=Aq	rr
tag_unbindtag_bindrrrnumaddrs` `   r_onclickzTurtleScreenBase._onclickSsG;GGt]S%89

GGT=3#6#Frc jj|d|zyfd}jj|d|z||y)agBind fun to mouse-button-release event on turtle.
        fun must be a function with two arguments, the coordinates
        of the point on the canvas where mouse button is released.
        num, the number of the mouse-button defaults to 1

        If a turtle is clicked, first _onclick-event will be performed,
        then _onscreensclick-event.
        Nz<Button%s-ButtonRelease>cjj|jjzjj	|j
jz}}||yrrrs   rrz-TurtleScreenBase._onrelease.<locals>.eventfunnrrrrs` `   r
_onreleasezTurtleScreenBase._onreleasebsL;GGt%?#%EF

GGT#=#C%s
,rc jj|d|zyfd}jj|d|z||y)aqBind fun to mouse-move-event (with pressed mouse button) on turtle.
        fun must be a function with two arguments, the coordinates of the
        actual mouse position on the canvas.
        num, the number of the mouse-button defaults to 1

        Every sequence of mouse-move-events on a turtle is preceded by a
        mouse-click event on that turtle.
        Nz<Button%s-Motion>c	jj|jjzjj	|j
jz}}||y#t$rYywxYwr)rrrrrrrrrs   rrz*TurtleScreenBase._ondrag.<locals>.eventfunsg GGOOEGG4T[[@ GGOOEGG44T[[@A1I sA.A22	A>=A>rrs` `   r_ondragzTurtleScreenBase._ondragusI;GGt%83%>?

GGT#6#<hLrcjjd|zyfd}jjd|z||y)aGBind fun to mouse-click event on canvas.
        fun must be a function with two arguments, the coordinates
        of the clicked point on the canvas.
        num, the number of the mouse-button defaults to 1

        If a turtle is clicked, first _onclick-event will be performed,
        then _onscreensclick-event.
        Nrcjj|jjzjj	|j
jz}}||yrrrs   rrz1TurtleScreenBase._onscreenclick.<locals>.eventfunrrrrbr@)rrrrrs``   r_onscreenclickzTurtleScreenBase._onscreenclicks?;GGNN=3./

GGLL,h<rc |jjd|zdyfd}|jjd|z|y)z`Bind fun to key-release event of key.
        Canvas must have focus. See method listen
        Nz<KeyRelease-%s>cyrrrRrs rrz0TurtleScreenBase._onkeyrelease.<locals>.eventfunrrrrrrs `  r
_onkeyreleasezTurtleScreenBase._onkeyreleases?;GGNN,s2D9
GGLL*S0(;rc?||jjddy|jjd|zdyfd}||jjd|y|jjd|z|y)zIf key is given, bind fun to key-press event of key.
        Otherwise bind fun to any key-press.
        Canvas must have focus. See method listen.
        Nz
<KeyPress>z
<KeyPress-%s>cyrrrs rrz.TurtleScreenBase._onkeypress.<locals>.eventfunrrrrs `  r_onkeypresszTurtleScreenBase._onkeypresssk
;{|T24d;
{\84_s2H=rc8|jjy)z=Set focus on canvas (in order to collect key-events)
        N)rrdrs r_listenzTurtleScreenBase._listens	
rc~|dk(r|jj|y|jj||y)z?Install a timer, which calls fun after t milliseconds.
        rN)r
after_idlerrrts   r_ontimerzTurtleScreenBase._ontimers/
6GGs#GGMM!S!rc>|jjdd|S)z0Create and return image item on canvas.
        rimage)rcreate_image)rrs  r_createimagezTurtleScreenBase._createimages ww##Aq#66rc|\}}|jj|||jz||jzf|jj	||y)zZConfigure image item as to draw image object
        at position (x,y) on canvas)
        rN)rrrr
itemconfig)rrr\rrrs      r
_drawimagezTurtleScreenBase._drawimagesN1ta$++orDKK/?@A4u-rct|jj|||jj|y)zConfigure image item as to draw image object
        at center of canvas. Set item to the first item
        in the displaylist, so it will be drawn below
        any other item .rN)rr	tag_lower)rrrs   r	_setbgpiczTurtleScreenBase._setbgpics-
	
4u-$rc8|jj|S)zQReturn 'line' or 'polygon' or 'image' depending on
        type of item.
        )rrrs  r_typezTurtleScreenBase._typesww||D!!rc|jj|}tdt|dDcgc]}||||dzf}}|Scc}w)a returns list of coordinate-pairs of points of item
        Example (for insiders):
        >>> from turtle import *
        >>> getscreen()._pointlist(getturtle().turtle._item)
        [(0.0, 9.9999999999999982), (0.0, -9.9999999999999982),
        (9.9999999999999982, 0.0)]
        >>> rrr)rrrangelen)rrripls     r
_pointlistzTurtleScreenBase._pointlistsSWW^^D
!).q#b'1)=
>Ar!ur!A#wh
>
>
?sA
cD|jj||||fy)Nr)rrF)rsrx1sry1srx2sry2s     r_setscrollregionz!TurtleScreenBase._setscrollregionsT4t$<=rc@|jj}|D]}t|jj|}g}|r8|dd\}}|j	||z|j	||z|dd}|r8|jj|g|y)Nr)rfind_allrrr)	rxscalefactoryscalefactorrrcoordinatesnewcoordlistrrs	         r_rescalezTurtleScreenBase._rescales  "	0Dtww~~d34KL"2A1##A$45##A$45)!"o	

DGGNN4/,/	0rc<t|jts|j|jfS||cxur|cxur/nn,|jj|jjfS|||_|||_|jj|||y)zaResize the canvas the turtles are drawing on. Does
        not alter the drawing window.
        N)rrrrrrarJs    r_resizezTurtleScreenBase._resizes
$''>2>>4??22
0b077$$dgg&8&888 &DN!(DO

iR0rc|jj}|dkr|jd}|jj}|dkr|jd}||fS)z; Return the width and height of the turtle window.
        rr|r)rrLrM)rr|rs   r_window_sizezTurtleScreenBase._window_sizes\##%A:GGG$E%%'Q;WWX&Ff}rcL|jjjy)a{Starts event loop - calling Tkinter's mainloop function.

        No argument.

        Must be last statement in a turtle graphics program.
        Must NOT be used if a script is run from within IDLE in -n mode
        (No subprocess) - for interactive use of turtle graphics.

        Example (for a TurtleScreen instance named screen):
        >>> screen.mainloop()

        N)rtkrrs rrzTurtleScreenBase.mainloops	


rcFtj|||jS)aPop up a dialog window for input of a string.

        Arguments: title is the title of the dialog window,
        prompt is a text mostly describing what information to input.

        Return the string input
        If the dialog is canceled, return None.

        Example (for a TurtleScreen instance named screen):
        >>> screen.textinput("NIM", "Name of first player:")

        )parent)r	askstringr)rr*prompts   rr)zTurtleScreenBase.textinput%s%%eVDGGDDrcLtj||||||jS)aPop up a dialog window for input of a number.

        Arguments: title is the title of the dialog window,
        prompt is a text mostly describing what numerical information to input.
        default: default value
        minval: minimum value for input
        maxval: maximum value for input

        The number input must be in the range minval .. maxval if these are
        given. If not, a hint is issued and the dialog remains open for
        correction. Return the number input.
        If the dialog is canceled,  return None.

        Example (for a TurtleScreen instance named screen):
        >>> screen.numinput("Poker", "Your stakes:", 1000, minval=10, maxval=10000)

        )initialvalueminvaluemaxvaluer")raskfloatr)rr*r$defaultminvalmaxvals      rrzTurtleScreenBase.numinput4s)$$$UF.4v,0GG5	5r)NNNFrrNrf)%rrrrrrr/rrrrrrrrrrrrrrrrrrrrrrr
rrrrrr)rrrrrrs<(O
3705(28-1-2(.
&
G,&M*=$	<>$
"7
. "
>
0
1	

E5rrceZdZdZy)rzWill be raised in TurtleScreen.update, if _RUNNING becomes False.

    This stops execution of a turtle graphics script.
    Main purpose: use in the Demo-Viewer turtle.Demo.py.
    NrrrrrrrrrPs
	rceZdZdZy)TurtleGraphicsErrorzSome TurtleGraphics Error
    Nr/rrrr1r1Ysrr1c eZdZdZddZddZy)rzData structure modeling shapes.

    attribute _type is one of "polygon", "image", "compound"
    attribute _data is - depending on _type a poygon-tuple,
    an image or a list constructed using the addcomponent method.
    Ncb||_|dk(r#t|trt|}||_y|dk(rWt|trd|jj
drEt|r:tj|}||_y|dk(r
g}||_ytd|z||_y)Npolygonr.gifcompoundzThere is no shape type %s)rrrrrlowerendswithrr	rr1_data)rtype_datas   rr/zShape.__init__es
I$%T{
g
$$::<((0VD\'..t4D
	j
 D
&&AE&IJJ
rc|jdk7rtd|jz||}|jj|||gy)a-Add component to a shape of type compound.

        Arguments: poly is a polygon, i. e. a tuple of number pairs.
        fill is the fillcolor of the component,
        outline is the outline color of the component.

        call (for a Shapeobject namend s):
        --   s.addcomponent(((0,0), (10,10), (-10,10)), "red", "blue")

        Example:
        >>> poly = ((0,0),(10,-5),(0,10),(-10,-5))
        >>> s = Shape("compound")
        >>> s.addcomponent(poly, "red", "blue")
        >>> # .. add more components and then use register_shape()
        r6z Cannot add component to %s ShapeN)rr1r9r)rpolyrnrs    raddcomponentzShape.addcomponentusR ::#%&HBF**'MN
N?G

4w/0rr)rrrrr/r>rrrrr^s 1rrc8eZdZdZd	dZd
dZdZdZdZdZ	y)Tbufferz5Ring buffer used as undobuffer for RawTurtle objects.cF||_dgg|z|_d|_d|_y)NrF)bufsizebufferptrcumulate)rrBs  rr/zTbuffer.__init__s'vh(
rNc|2t|jD]}dg|j|<d|_y||_dgg|z|_d|_y)Nr)r	rBrCrD)rrBrs   rraz
Tbuffer.resetsW?4<<(
("&A
(
#DL 6(W,DKrc|jdkDrp|js;|jdz|jz|_||j|j<y|j|jj	|yyr)rBrErDrCrrs  rpushzTbuffer.pushs_<<!== HHqLDLL8(,DHH%DHH%,,T2rc|jdkDrY|j|j}|ydg|j|j<|jdz
|jz|_|Syr)rBrCrDrs  rpopzTbuffer.pops^<<!;;txx(D|)-DHH% HHqLDLL8
rcT|j|jjdgz
Sr)rBrCcountrs rnr_of_itemszTbuffer.nr_of_itemss"||dkk//777rc^t|jdzt|jzS)N )rrCrDrs rrzTbuffer.__repr__s#4;;#%DHH
55r)rr)
rrrrr/rarHrJrMrrrrr@r@s#?
386rr@ceZdZdZdZedededfdZdZd!d	Zd
Z	d!dZ
dZd
Zd!dZ
dZdZdZd"dZd!dZdZdZdZdZdZdZd#dZdZd!dZd"dZd$dZd!dZd%d ZeZ eZ!eZ"e
Z#eZ$y)&r	zProvides screen oriented methods like bgcolor etc.

    Only relies upon the methods of TurtleScreenBase and NOT
    upon components of the underlying graphics toolkit -
    which is Tkinter in this case.
    Trrrc
tj||tddtddtddtddtddtddtd|jd	|_d
di|_||_||_td|_	g|_
|jtjd
k(r;|j}|jddddd|jdddddyy)Nr4)rrrrr))r))rr))	)))r[r))r_)r_rc)rYrarr[)ra)rc)r^r_)r`rb)rZr)rfr`)r\r^)rZr\)rerZ)rr)rrX)rT)Q#@Q@)Gz. @Q@)rjri)rhrgrU)Qrg)Qri)Gz. rj)Q#rhrR)rnrk)rmrl)rlrm)rkrn)gg$)rhrn)rjrm)rirl)rgrk))rrS)rr)rSr)rSrS))rGz)rg'@)rSro)rr)rar]rd)r`r]r)arrowrr5squaretrianglerrnopicrrdarwinwm
attributesrz-topmost10)rr/rr_shapes_bgpics_mode_delayvaluer
_colormode_keysr6sysplatformr0call)rrrrr
rootwindows      rr/zTurtleScreen.__init__s	!!$+#9.GH"9/&'
#9/HI#9/)*"9/+,"9.KL"7D,<,<,>?%* "~
 {+


<<8#**,JOOD,ZEOOD,ZE
$rctd|_td|_|jd|j	d|_d|_d|_d|_g|_	|jdd	D]}|jd
||jd
|jd
d
D]&}|jd
||jd
|(d
t_y
)aqDelete all drawings and all turtles from the TurtleScreen.

        No argument.

        Reset empty TurtleScreen to its initial state: white background,
        no backgroundimage, no eventbindings and tracing on.

        Example (for a TurtleScreen instance named screen):
        >>> screen.clear()

        Note: this method is not available as function.
        rrallrrtrrr)rrN)rr}r~rr_bgpic
_bgpicname_tracing_updatecounter_turtlesrrSr rrr_pen)rbtnrs   rr6zTurtleScreen.clears ={+U''+!

W	$CLLs#	$::a=	'CJJtS!OOD#&	'rNcJ||jS|j}|dvrtd|z||_|dvrX|j|jdz|j
dz|jdz|j
dzdx|_|_|jy)ahSet turtle-mode ('standard', 'logo' or 'world') and perform reset.

        Optional argument:
        mode -- one of the strings 'standard', 'logo' or 'world'

        Mode 'standard' is compatible with turtle.py.
        Mode 'logo' is compatible with most Logo-Turtle-Graphics.
        Mode 'world' uses userdefined 'worldcoordinates'. *Attention*: in
        this mode angles appear distorted if x/y unit-ratio doesn't equal 1.
        If mode is not given, return the current mode.

             Mode      Initial turtle heading     positive angles
         ------------|-------------------------|-------------------
          'standard'    to the right (east)       counterclockwise
            'logo'        upward    (north)         clockwise

        Examples:
        >>> mode('logo')   # resets turtle heading to north
        >>> mode()
        'logo'
        NrlogoworldzNo turtle-graphics-mode %s)rrrr)	r|r7r1rrrrrrarrs  rrzTurtleScreen.modes,<::zz|44%&BT&IJJ
''!!4>>/1"4t6F6I'+~~q'8$//1:L
N(++DK$+

rct|jdk7r|jdt||z
}t||z
}|j\}}|j|dz
|dz
|j|j
}
}	|j|z|_|j|z|_||jz}||j
z}|j|z}
|j|z}|j|||
||j|j|	z|j
|
z|jy)asSet up a user defined coordinate-system.

        Arguments:
        llx -- a number, x-coordinate of lower left corner of canvas
        lly -- a number, y-coordinate of lower left corner of canvas
        urx -- a number, x-coordinate of upper right corner of canvas
        ury -- a number, y-coordinate of upper right corner of canvas

        Set up user coodinat-system and switch to mode 'world' if necessary.
        This performs a screen.reset. If mode 'world' is already active,
        all drawings are redrawn according to the new coordinates.

        But ATTENTION: in user-defined coordinatesystems angles may appear
        distorted. (see Screen.mode())

        Example (for a TurtleScreen instance named screen):
        >>> screen.setworldcoordinates(-10,-0.5,50,1.5)
        >>> for _ in range(36):
        ...     left(10)
        ...     forward(0.5)
        rN)rrrr&rrrrrrr-)rllxllyurxuryxspanyspanwxwy	oldxscale	oldyscalerrrrs               rr(z TurtleScreen.setworldcoordinates$s
,99;'!IIgcCi cCi ""$B2r"u%#{{DKK9	nnu,oo-T[[ tdkk!~~$%dD$5

dkk)+T[[-BC
rc|F|jjdrtd|j|}n't	dt|trtd|}||j|<y)aAdds a turtle shape to TurtleScreen's shapelist.

        Arguments:
        (1) name is the name of a gif-file and shape is None.
            Installs the corresponding image shape.
            !! Image-shapes DO NOT rotate when turning the turtle,
            !! so they do not display the heading of the turtle!
        (2) name is an arbitrary string and shape is a tuple
            of pairs of coordinates. Installs the corresponding
            polygon shape
        (3) name is an arbitrary string and shape is a
            (compound) Shape object. Installs the corresponding
            compound shape.
        To use a shape, you have to issue the command shape(shapename).

        call: register_shape("turtle.gif")
        --or: register_shape("tri", ((0,0), (10,10), (-10,10)))

        Example (for a TurtleScreen instance named screen):
        >>> screen.register_shape("triangle", ((5,-3),(0,5),(-5,-3)))

        Nr5rz;Bad arguments for register_shape.
Use  help(register_shape)r4)r7r8rrr1rrrz)rnamerls   rr$zTurtleScreen.register_shapeKsk.=zz|$$V,gt{{4'89)+HJJ
u
%)U+E"Trct|dk(r|d}t|tr/|j|s|dk(r|St	dt|z	|\}}}|jdk(r#|||fDcgc]}td|zc}\}}}d|cxkrdkrnnd|cxkrdkrnn
d|cxkrdksnt	d	t|zd
|||fzS#t
tf$rt	dt|zwxYwcc}w)aReturn color string corresponding to args.

        Argument may be a string or a tuple of three
        numbers corresponding to actual colormode,
        i.e. in the range 0<=n<=colormode.

        If the argument doesn't represent a color,
        an error is raised.
        rrrzbad color string: %sbad color arguments: %sro@bad color sequence: %s
#%02x%02x%02x)	r
rrrr1	TypeErrorrr~round)rr:rgbrs      r	_colorstrzTurtleScreen._colorstrns	u:?!HEeS!""5)Ub[)*@3u:*MNN	NGAq!??c!011ay9!uU1W~9GAq!a3Q!]s]a3%&>U&KLL!Q**
:&	N%&?#e*&LMM	N:sC0C>'C;c	@|jds|St|dk(r dDcgc]}t|||dzd}}n?t|dk(r#|ddDcgc]}dt||dz}}ntd|zt	fd	|DScc}wcc}w)
NrrZ)rrr`rrVrerzbad colorstring: %sc3BK|]}|jzdzyw)rN)r~).0rrs  r	<genexpr>z&TurtleScreen._color.<locals>.<genexpr>s9Q(,9s)rr
rr1r)rcstrrrrs`    r_colorzTurtleScreen._colorss#Kt9>09:1#d1QqSk2&:B:
Y!^/3ABx8!"Sa"%%8B8%&;d&BCC9b999;8sBBcx||jS|dk(rt||_y|dk(rt||_yy)aqReturn the colormode or set it to 1.0 or 255.

        Optional argument:
        cmode -- one of the values 1.0 or 255

        r, g, b values of colortriples have to be in range 0..cmode.

        Example (for a TurtleScreen instance named screen):
        >>> screen.colormode()
        1.0
        >>> screen.colormode(255)
        >>> pencolor(240,160,80)
        Nrr)r~rr)rcmodes  rrzTurtleScreen.colormodes<=??"C<#ElDO
c\!%jDOrc||jD]-}|j|j|j/y)zReset all Turtles on the Screen to their initial state.

        No argument.

        Example (for a TurtleScreen instance named screen):
        >>> screen.reset()
        N)r_setmoder|ra)rrs  rrazTurtleScreen.resets0mm	FOODJJ'LLN	rc|jS)zReturn the list of turtles on the screen.

        Example (for a TurtleScreen instance named screen):
        >>> screen.turtles()
        [<turtle.Turtle object at 0x00E11FB0>]
        )rrs rr,zTurtleScreen.turtless}}rcz|r|j|}nd}|j|}||j|}|S)aSet or return backgroundcolor of the TurtleScreen.

        Arguments (if given): a color string or three numbers
        in the range 0..colormode or a 3-tuple of such numbers.

        Example (for a TurtleScreen instance named screen):
        >>> screen.bgcolor("orange")
        >>> screen.bgcolor()
        'orange'
        >>> screen.bgcolor(0.5,0,0.5)
        >>> screen.bgcolor()
        '#800080'
        N)rrrrrXr:s   rrzTurtleScreen.bgcolorsANN4(EE

e$KK&Erc||jSt||_d|_|t||_|jr|j	yy)aeTurns turtle animation on/off and set delay for update drawings.

        Optional arguments:
        n -- nonnegative  integer
        delay -- nonnegative  integer

        If n is given, only each n-th regular screen update is really performed.
        (Can be used to accelerate the drawing of complex graphics.)
        Second arguments sets delay value (see RawTurtle.delay())

        Example (for a TurtleScreen instance named screen):
        >>> screen.tracer(8, 25)
        >>> dist = 2
        >>> for i in range(200):
        ...     fd(dist)
        ...     rt(90)
        ...     dist += 2
        Nr)rrrr}r-)rnrs   rr+zTurtleScreen.tracersM&
9== A
"5zD==KKMrc@||jSt||_y)z Return or set the drawing delay in milliseconds.

        Optional argument:
        delay -- positive integer

        Example (for a TurtleScreen instance named screen):
        >>> screen.delay(15)
        >>> screen.delay()
        15
        N)r}rrs  rrzTurtleScreen.delays!=###u:rctjsdt_t|jdkDr5|xjdz
c_|xj|jzc_yy)zIncrement update counter.TrrN)r	_RUNNINGrrrrs r
_incrementudczTurtleScreen._incrementudcsP$$$(L!==11$4==0rc|j}d|_|jD]"}|j|j$||_|j	y)z'Perform a TurtleScreen update.
        TN)rr,_update_data_drawturtler)rtracingrs   rr-zTurtleScreen.update	sN--
	A
NN
MMO	 
rc(|jdS)z Return the width of the turtle window.

        Example (for a TurtleScreen instance named screen):
        >>> screen.window_width()
        640
        rrrs rr/zTurtleScreen.window_width  "1%%rc(|jdS)z Return the height of the turtle window.

        Example (for a TurtleScreen instance named screen):
        >>> screen.window_height()
        480
        rrrs rr.zTurtleScreen.window_heightrrc|jS)zReturn the Canvas of this TurtleScreen.

        No argument.

        Example (for a Screen instance named screen):
        >>> cv = screen.getcanvas()
        >>> cv
        <turtle.ScrolledCanvas instance at 0x010742D8>
        )rrs rrzTurtleScreen.getcanvas&s
wwrcHt|jjS)zReturn a list of names of all currently available turtle shapes.

        No argument.

        Example (for a TurtleScreen instance named screen):
        >>> screen.getshapes()
        ['arrow', 'blank', 'circle', ... , 'turtle']
        )sortedrzrrs rrzTurtleScreen.getshapes2sdll'')**rc*|j|||y)aBind fun to mouse-click event on canvas.

        Arguments:
        fun -- a function with two arguments, the coordinates of the
               clicked point on the canvas.
        btn -- the number of the mouse-button, defaults to 1

        Example (for a TurtleScreen instance named screen)

        >>> screen.onclick(goto)
        >>> # Subsequently clicking into the TurtleScreen will
        >>> # make the turtle move to the clicked point.
        >>> screen.onclick(None)
        N)rrrrrs    rrSzTurtleScreen.onclick=s	
Cc*rc|*||jvrE|jj|n)||jvr|jj||j||y)amBind fun to key-release event of key.

        Arguments:
        fun -- a function with no arguments
        key -- a string: key (e.g. "a") or key-symbol (e.g. "space")

        In order to be able to register key-events, TurtleScreen
        must have focus. (See method listen.)

        Example (for a TurtleScreen instance named screen):

        >>> def f():
        ...     fd(50)
        ...     lt(60)
        ...
        >>> screen.onkey(f, "Up")
        >>> screen.listen()

        Subsequently the turtle can be moved by repeatedly pressing
        the up-arrow key, consequently drawing a hexagon

        N)rremoverrrrrs   rrzTurtleScreen.onkeyNsU.;djj 

!!#&



"JJc"3$rc|*||jvrG|jj|n+|)||jvr|jj||j||y)aBind fun to key-press event of key if key is given,
        or to any key-press-event if no key is given.

        Arguments:
        fun -- a function with no arguments
        key -- a string: key (e.g. "a") or key-symbol (e.g. "space")

        In order to be able to register key-events, TurtleScreen
        must have focus. (See method listen.)

        Example (for a TurtleScreen instance named screen
        and a Turtle instance named turtle):

        >>> def f():
        ...     fd(50)
        ...     lt(60)
        ...
        >>> screen.onkeypress(f, "Up")
        >>> screen.listen()

        Subsequently the turtle can be moved by repeatedly pressing
        the up-arrow key, or by keeping pressed the up-arrow key.
        consequently drawing a hexagon.
        N)rrrrrs   rr zTurtleScreen.onkeypresslsY2;djj 

!!#&
_DJJ!6JJc"c"rc$|jy)aSet focus on TurtleScreen (in order to collect key-events)

        No arguments.
        Dummy arguments are provided in order
        to be able to pass listen to the onclick method.

        Example (for a TurtleScreen instance named screen):
        >>> screen.listen()
        N)r)rxdummyydummys   rrzTurtleScreen.listens
	
rc(|j||y)aInstall a timer, which calls fun after t milliseconds.

        Arguments:
        fun -- a function with no arguments.
        t -- a number >= 0

        Example (for a TurtleScreen instance named screen):

        >>> running = True
        >>> def f():
        ...     if running:
        ...             fd(50)
        ...             lt(60)
        ...             screen.ontimer(f, 250)
        ...
        >>> f()   # makes the turtle marching around
        >>> running = False
        N)rrs   rr#zTurtleScreen.ontimers&	


c1rc||jS||jvr|j||j|<|j|j|j|||_y)aFSet background image or return name of current backgroundimage.

        Optional argument:
        picname -- a string, name of a gif-file or "nopic".

        If picname is a filename, set the corresponding image as background.
        If picname is "nopic", delete backgroundimage, if present.
        If picname is None, return the filename of the current backgroundimage.

        Example (for a TurtleScreen instance named screen):
        >>> screen.bgpic()
        'nopic'
        >>> screen.bgpic("landscape.gif")
        >>> screen.bgpic()
        'landscape.gif'
        N)rr{rrr)rpicnames  rrzTurtleScreen.bgpicsX"???"$,,&$(KK$8DLL!t{{DLL$9:!rc(|j|||S)aResize the canvas the turtles are drawing on.

        Optional arguments:
        canvwidth -- positive integer, new width of canvas in pixels
        canvheight --  positive integer, new height of canvas in pixels
        bg -- colorstring or color-tuple, new backgroundcolor
        If no arguments are given, return current (canvaswidth, canvasheight)

        Do not alter the drawing window. To observe hidden parts of
        the canvas use the scrollbars. (Can make visible those parts
        of a drawing, which were outside the canvas before!)

        Example (for a Turtle instance named turtle):
        >>> turtle.screensize(2000,1500)
        >>> # e.g. to search for an erroneously escaped turtle ;-)
        )rrJs    rr&zTurtleScreen.screensizes"||Iz266rrNNr-rrf)%rrrrrrr/r6rr(r$rrrrar,rr+rrr-r/r.rrrSrr rr#rr&r"r%rrr!rrrr	r	sH $V,DM&FP< D%N!#F+6	:)*
.8
&1	&&
	++"%<#@
*"07&MKKHLrr	cLeZdZdZeddeddedddZdZdZdZefdZ	d	Z
d*dZdZd+d
Z
dZdZdZdZd,dddedd
fdZdZdZdZdZdZdZdZd*dZdZd Zd!Zd*d"Zd*d#Z d$Z!d%Z"d,d&Z#d-d'Z$d,d(Z%d*d)Z&eZ'eZ(eZ)eZ*eZ+eZ,eZ-eZ.e"Z/y
).
TNavigatorzRNavigation part of the RawTurtle.
    Implements methods for turtle movement.
    r)rrrrrrc|j|_|j|_||_d|_|j
d|_|j|tj|yr)
DEFAULT_ANGLEOFFSET_angleOffsetDEFAULT_ANGLEORIENT_angleOrientr|
undobufferr;rrrars  rr/zTNavigator.__init__sV 44 44



drcjtdd|_tj|j|_y)zXreset turtle to its initial values

        Will be overwritten by parent class
        rN)r	_positionrSTART_ORIENTATIONr|_orientrs rrazTNavigator.resets'
sC"44TZZ@rNc||jS|dvry||_|dvrd|_d|_y|jdz|_d|_y)z:Set turtle-mode to 'standard', 'world' or 'logo'.
        Nr)rrrr@r)r|rr_fullcirclers  rrzTNavigator._setmodesZ<::44
(( !D !D $ 0 0 3D "Drch||_d|z|_|jdk(rd|_y|dz|_y)z+Helper function for degrees() and radians()ihrrrN)r
_degreesPerAUr|rr
fullcircles  r_setDegreesPerAUzTNavigator._setDegreesPerAUs6% ^::# !D *2
Drc&|j|y)a> Set angle measurement units to degrees.

        Optional argument:
        fullcircle -  a number

        Set angle measurement units, i. e. set number
        of 'degrees' for a full circle. Default value is
        360 degrees.

        Example (for a Turtle instance named turtle):
        >>> turtle.left(90)
        >>> turtle.heading()
        90

        Change angle measurement unit to grad (also known as gon,
        grade, or gradian and equals 1/100-th of the right angle.)
        >>> turtle.degrees(400.0)
        >>> turtle.heading()
        100

        N)rrs  rr;zTNavigator.degreess,	
j)rcB|jtjy)a Set the angle measurement units to radians.

        No arguments.

        Example (for a Turtle instance named turtle):
        >>> turtle.heading()
        90
        >>> turtle.radians()
        >>> turtle.heading()
        1.5707963267948966
        N)rrtaurs rr_zTNavigator.radians,s	
dhh'rc^|j|j|zz}|j|y)z)move turtle forward by specified distanceN)rr_goto)rr<endes   r_gozTNavigator._go:s%~~x 77

4rcb||jz}|jj||_y)z=Turn turtle counterclockwise by specified angle if angle > 0.N)rrrrrs  r_rotatezTNavigator._rotate?s(
###||**51rc||_y)zmove turtle to position end.Nr)rends  rrzTNavigator._gotoDs	rFfill_gaprreturncr||n|jd}||n|jd}t|||_y)zPTo be overwritten by child class RawTurtle.
        Includes no TPen references.Nrr)rr)rrrrnew_xnew_ys      rrtzTNavigator.teleportHs:]q(9]q(9ue,rc&|j|y)aMove the turtle forward by the specified distance.

        Aliases: forward | fd

        Argument:
        distance -- a number (integer or float)

        Move the turtle forward by the specified distance, in the direction
        the turtle is headed.

        Example (for a Turtle instance named turtle):
        >>> turtle.position()
        (0.00, 0.00)
        >>> turtle.forward(25)
        >>> turtle.position()
        (25.00,0.00)
        >>> turtle.forward(-75)
        >>> turtle.position()
        (-50.00,0.00)
        Nrrr<s  rrDzTNavigator.forwardOs*	
rc(|j|y)aMove the turtle backward by distance.

        Aliases: back | backward | bk

        Argument:
        distance -- a number

        Move the turtle backward by distance, opposite to the direction the
        turtle is headed. Do not change the turtle's heading.

        Example (for a Turtle instance named turtle):
        >>> turtle.position()
        (0.00, 0.00)
        >>> turtle.backward(30)
        >>> turtle.position()
        (-30.00, 0.00)
        Nrrs  rr0zTNavigator.backfs$	
(rc(|j|y)aTurn turtle right by angle units.

        Aliases: right | rt

        Argument:
        angle -- a number (integer or float)

        Turn turtle right by angle units. (Units are by default degrees,
        but can be set via the degrees() and radians() functions.)
        Angle orientation depends on mode. (See this.)

        Example (for a Turtle instance named turtle):
        >>> turtle.heading()
        22.0
        >>> turtle.right(45)
        >>> turtle.heading()
        337.0
        Nrrs  rr`zTNavigator.rightzs&	
eVrc&|j|y)aTurn turtle left by angle units.

        Aliases: left | lt

        Argument:
        angle -- a number (integer or float)

        Turn turtle left by angle units. (Units are by default degrees,
        but can be set via the degrees() and radians() functions.)
        Angle orientation depends on mode. (See this.)

        Example (for a Turtle instance named turtle):
        >>> turtle.heading()
        22.0
        >>> turtle.left(45)
        >>> turtle.heading()
        67.0
        Nrrs  rrQzTNavigator.lefts&	
Urc|jS)zReturn the turtle's current location (x,y), as a Vec2D-vector.

        Aliases: pos | position

        No arguments.

        Example (for a Turtle instance named turtle):
        >>> turtle.pos()
        (0.00, 240.00)
        rrs rr\zTNavigator.poss~~rc |jdS)z Return the turtle's x coordinate.

        No arguments.

        Example (for a Turtle instance named turtle):
        >>> reset()
        >>> turtle.left(60)
        >>> turtle.forward(100)
        >>> print turtle.xcor()
        50.0
        rrrs rr~zTNavigator.xcor~~a  rc |jdS)a	 Return the turtle's y coordinate
        ---
        No arguments.

        Example (for a Turtle instance named turtle):
        >>> reset()
        >>> turtle.left(60)
        >>> turtle.forward(100)
        >>> print turtle.ycor()
        86.6025403784
        rrrs rrzTNavigator.ycorr
rcn||jt|y|jt||y)atMove turtle to an absolute position.

        Aliases: setpos | setposition | goto:

        Arguments:
        x -- a number      or     a pair/vector of numbers
        y -- a number             None

        call: goto(x, y)         # two coordinates
        --or: goto((x, y))       # a pair (tuple) of coordinates
        --or: goto(vec)          # e.g. as returned by pos()

        Move turtle to an absolute position. If the pen is down,
        a line will be drawn. The turtle's orientation does not change.

        Example (for a Turtle instance named turtle):
        >>> tp = turtle.pos()
        >>> tp
        (0.00, 0.00)
        >>> turtle.setpos(60,30)
        >>> turtle.pos()
        (60.00,30.00)
        >>> turtle.setpos((20,80))
        >>> turtle.pos()
        (20.00,80.00)
        >>> turtle.setpos(tp)
        >>> turtle.pos()
        (0.00,0.00)
        N)rr)rrrs   rrJzTNavigator.gotos+<
9JJuay!JJuQ{#rcJ|jdd|jdy)a$Move turtle to the origin - coordinates (0,0).

        No arguments.

        Move turtle to the origin - coordinates (0,0) and set its
        heading to its start-orientation (which depends on mode).

        Example (for a Turtle instance named turtle):
        >>> turtle.home()
        rN)rJrers rrMzTNavigator.homes	
		!QrcT|jt||jdy)aSet the turtle's first coordinate to x

        Argument:
        x -- a number (integer or float)

        Set the turtle's first coordinate to x, leave second coordinate
        unchanged.

        Example (for a Turtle instance named turtle):
        >>> turtle.position()
        (0.00, 240.00)
        >>> turtle.setx(10)
        >>> turtle.position()
        (10.00, 240.00)
        rNrrr)rrs  rrjzTNavigator.setxs  	

5DNN1-./rcT|jt|jd|y)aSet the turtle's second coordinate to y

        Argument:
        y -- a number (integer or float)

        Set the turtle's first coordinate to x, second coordinate remains
        unchanged.

        Example (for a Turtle instance named turtle):
        >>> turtle.position()
        (0.00, 40.00)
        >>> turtle.sety(-10)
        >>> turtle.position()
        (0.00, -10.00)
        rNr)rrs  rrkzTNavigator.setys  	

5*A./rc|t||}t|tr|}n5t|tr	t|}nt|tr|j}t|jz
S)aReturn the distance from the turtle to (x,y) in turtle step units.

        Arguments:
        x -- a number   or  a pair/vector of numbers   or   a turtle instance
        y -- a number       None                            None

        call: distance(x, y)         # two coordinates
        --or: distance((x, y))       # a pair (tuple) of coordinates
        --or: distance(vec)          # e.g. as returned by pos()
        --or: distance(mypen)        # where mypen is another turtle

        Example (for a Turtle instance named turtle):
        >>> turtle.pos()
        (0.00, 0.00)
        >>> turtle.distance(30,40)
        50.0
        >>> pen = Turtle()
        >>> pen.forward(77)
        >>> turtle.distance(pen)
        77.0
        )rrrrrabs)rrrr\s    rr<zTNavigator.distance#s],
=1+CaC
5
!)C
:
&++C3'((rc|t||}t|tr|}n5t|tr	t|}nt|tr|j}|jz
\}}tt
jt
j||ddz}||jz}|j|j|zz|jzS)aCReturn the angle of the line from the turtle's position to (x, y).

        Arguments:
        x -- a number   or  a pair/vector of numbers   or   a turtle instance
        y -- a number       None                            None

        call: distance(x, y)         # two coordinates
        --or: distance((x, y))       # a pair (tuple) of coordinates
        --or: distance(vec)          # e.g. as returned by pos()
        --or: distance(mypen)        # where mypen is another turtle

        Return the angle, between the line from turtle-position to position
        specified by x, y and the turtle's start orientation. (Depends on
        modes - "standard" or "logo")

        Example (for a Turtle instance named turtle):
        >>> turtle.pos()
        (10.00, 10.00)
        >>> turtle.towards(0,0)
        225.0
        rv@)
rrrrrrrr;atan2rrrr)rrrr\results     rrwzTNavigator.towardsCs,
=1+CaC
5
!)C
:
&++CT^^#1t||DJJq!$45r:UB$$$$!!D$5$5f$<<@P@PPPrc|j\}}ttjtj||ddz}||j
z}|j|j|zz|jzS)z Return the turtle's current heading.

        No arguments.

        Example (for a Turtle instance named turtle):
        >>> turtle.left(67)
        >>> turtle.heading()
        67.0
        rr)	rrrr;rrrrr)rrrrs    rrKzTNavigator.headingfsm||1t||DJJq!$45r:UB$$$$!!D$5$5f$<<@P@PPPrc||jz
|jz}|j}||dzz|z|dzz
}|j|y)aSet the orientation of the turtle to to_angle.

        Aliases:  setheading | seth

        Argument:
        to_angle -- a number (integer or float)

        Set the orientation of the turtle to to_angle.
        Here are some common directions in degrees:

         standard - mode:          logo-mode:
        -------------------|--------------------
           0 - east                0 - north
          90 - north              90 - east
         180 - west              180 - south
         270 - south             270 - west

        Example (for a Turtle instance named turtle):
        >>> turtle.setheading(90)
        >>> turtle.heading()
        90
        @N)rKrrr)rto_anglerfulls    rrezTNavigator.setheadingusQ.DLLN*D,=,==tBw$tBw.Urc	|jr-|jjdgd|j_|j}||j}|Bt||jz}dt
tdt|dzzd|zz}d|z|z}d	|z}d
|ztjtj||jzz}|dkr	|||}}}|j}	|j}
|dk(r|jddn|jd|j|t|D]F}|j||j!||jd|j|H|j||dk(r|j|	|
|j||jrd|j_yy)
a Draw a circle with given radius.

        Arguments:
        radius -- a number
        extent (optional) -- a number
        steps (optional) -- an integer

        Draw a circle with given radius. The center is radius units left
        of the turtle; extent - an angle - determines which part of the
        circle is drawn. If extent is not given, draw the entire circle.
        If extent is not a full circle, one endpoint of the arc is the
        current pen position. Draw the arc in counterclockwise direction
        if radius is positive, otherwise in clockwise direction. Finally
        the direction of the turtle is changed by the amount of extent.

        As the circle is approximated by an inscribed regular polygon,
        steps determines the number of steps to use. If not given,
        it will be calculated automatically. Maybe used to draw regular
        polygons.

        call: circle(radius)                  # full circle
        --or: circle(radius, extent)          # arc
        --or: circle(radius, extent, steps)
        --or: circle(radius, steps=6)         # 6-sided polygon

        Example (for a Turtle instance named turtle):
        >>> turtle.circle(50)
        >>> turtle.circle(120, 180)  # semicircle
        seqTNrg@gM@rrrrF)rrHrErqrrrminrrr_r_tracerrrr	r)rradiusextentstepsrqfracrw2ltrdlrs            rr5zTNavigator.circles<??OO  %)'+DOO$

>%%F=v;t///Dc#bVS0$7<==E&L5 
1W&L488DLL$4T5G5G$GHHA:rA2s"qA
\\^
[[]A:LLAJJqMRu	AJJuHHQKJJqMLLO		
	
bSA:LLR 

5??',DOO$rcyz/dummy method - to be overwritten by child classNr)rrs  rrqzTNavigator.speedrcyr*r)rars   rr zTNavigator._tracerr+rcyr*r)rrs  rrzTNavigator._delayr+rr)rrr)0rrrrrrDEFAULT_MODErrr/rarrr;r_rrrboolrtrDr0r`rQr\r~rrJrMrjrkr<rwrKrer5rqr rrAr4r1rcrRr]rfrgrdrrrrrs#sO#sO#sO'L(A
#.*0(
2
-5-D-T-.(**!!!$F0$0$)@!QF
Q8=-B>>>
B	
BH	B	
BH
FKDrrceZdZdZedfdZededfdZddZdd	Zd
Z	dZ
dZdd
ZdZ
dZdZddddeddfdZdZdZdZddZd dZd!dZdZdZeZe	Ze	Ze
Ze
ZeZeZ y)"TPenzFDrawing part of the RawTurtle.
    Implements drawing properties.
    rbcJ||_d|_tj|yr)_resizemoderr2_reset)rrbs  rr/z
TPen.__init__s%DrrXrBcd|_d|_||_||_d|_d|_d|_d|_d|_d|_	d|_
y)NrTr)rrr)rrrr)_pensize_shown	_pencolor
_fillcolor_drawing_speed_stretchfactor_shearfactor_tilt_shapetrafo
_outlinewidth)rrXrBs   rr5zTPen._resetsS
!#
&
+rNcn||jS|j}|dvr|j|yy)azSet resizemode to one of the values: "auto", "user", "noresize".

        (Optional) Argument:
        rmode -- one of the strings "auto", "user", "noresize"

        Different resizemodes have the following effects:
          - "auto" adapts the appearance of the turtle
                   corresponding to the value of pensize.
          - "user" adapts the appearance of the turtle according to the
                   values of stretchfactor and outlinewidth (outline),
                   which are set by shapesize()
          - "noresize" no adaption of the turtle's appearance takes place.
        If no argument is given, return current resizemode.
        resizemode("user") is called by a call of shapesize with arguments.


        Examples (for a Turtle instance named turtle):
        >>> turtle.resizemode("noresize")
        >>> turtle.resizemode()
        'noresize'
        N)autouserrrb)r4r7rW)rrmodes  rrbzTPen.resizemodes<,=###
00HHH&1rcD||jS|j|y)a!Set or return the line thickness.

        Aliases:  pensize | width

        Argument:
        width -- positive number

        Set the line thickness to width or return it. If resizemode is set
        to "auto" and turtleshape is a polygon, that polygon is drawn with
        the same line thickness. If no argument is given, current pensize
        is returned.

        Example (for a Turtle instance named turtle):
        >>> turtle.pensize()
        1
        >>> turtle.pensize(10)   # from here on lines of width 10 are drawn
        N)rZ)r7rW)rr|s  rrZzTPen.pensizes!$=== rcB|jsy|jdy)zPull the pen up -- no drawing when moving.

        Aliases: penup | pu | up

        No argument

        Example (for a Turtle instance named turtle):
        >>> turtle.penup()
        NFrYr;rWrs rr[z
TPen.penup.s}}rcB|jry|jdy)zPull the pen down -- drawing when moving.

        Aliases: pendown | pd | down

        No argument.

        Example (for a Turtle instance named turtle):
        >>> turtle.pendown()
        NTrIrJrs rrYzTPen.pendown<s==rc|jS)aReturn True if pen is down, False if it's up.

        No argument.

        Example (for a Turtle instance named turtle):
        >>> turtle.penup()
        >>> turtle.isdown()
        False
        >>> turtle.pendown()
        >>> turtle.isdown()
        True
        )r;rs rrOzTPen.isdownJs}}rcdddddd}||jS||vr||}n%d|cxkrd	krnntt|}nd}|j|
y)a Return or set the turtle's speed.

        Optional argument:
        speed -- an integer in the range 0..10 or a speedstring (see below)

        Set the turtle's speed to an integer value in the range 0 .. 10.
        If no argument is given: return current speed.

        If input is a number greater than 10 or smaller than 0.5,
        speed is set to 0.
        Speedstrings  are mapped to speedvalues in the following way:
            'fastest' :  0
            'fast'    :  10
            'normal'  :  6
            'slow'    :  3
            'slowest' :  1
        speeds from 1 to 10 enforce increasingly faster animation of
        line drawing and turtle turning.

        Attention:
        speed = 0 : *no* animation takes place. forward/back makes turtle jump
        and likewise left/right make the turtle turn instantly.

        Example (for a Turtle instance named turtle):
        >>> turtle.speed(3)
        rrrfrr)fastestfastnormalslowslowestNrg%@)rq)r<rrrW)rrqspeedss   rrqz
TPen.speedYsa6b1Q!M=;;F?5ME
5
4
e%EEurc6|rbt|}|dk(r|dx}}n|dk(r|\}}n	|dk(r|x}}|j}|j}|j||y|j|j|j|j
fS)aReturn or set the pencolor and fillcolor.

        Arguments:
        Several input formats are allowed.
        They use 0, 1, 2, or 3 arguments as follows:

        color()
            Return the current pencolor and the current fillcolor
            as a pair of color specification strings as are returned
            by pencolor and fillcolor.
        color(colorstring), color((r,g,b)), color(r,g,b)
            inputs as in pencolor, set both, fillcolor and pencolor,
            to the given value.
        color(colorstring1, colorstring2),
        color((r1,g1,b1), (r2,g2,b2))
            equivalent to pencolor(colorstring1) and fillcolor(colorstring2)
            and analogously, if the other input format is used.

        If turtleshape is a polygon, outline and interior of that polygon
        is drawn with the newly set colors.
        For more info see: pencolor, fillcolor

        Example (for a Turtle instance named turtle):
        >>> turtle.color('red', 'green')
        >>> turtle.color()
        ('red', 'green')
        >>> colormode(255)
        >>> color((40, 80, 120), (160, 200, 240))
        >>> color()
        ('#285078', '#a0c8f0')
        rrrr)rXrBN)r
rrWrr9r:)rrXr&pcolorfcolors     rr:z
TPen.colors@D	AAv"&q')a!%a"&&^^F+F^^F+FHHfH7;;t~~.DOO0LLLrc|r4|j|}||jk(ry|j|y|j|jS)aZ Return or set the pencolor.

        Arguments:
        Four input formats are allowed:
          - pencolor()
            Return the current pencolor as color specification string,
            possibly in hex-number format (see example).
            May be used as input to another color/pencolor/fillcolor call.
          - pencolor(colorstring)
            s is a Tk color specification string, such as "red" or "yellow"
          - pencolor((r, g, b))
            *a tuple* of r, g, and b, which represent, an RGB color,
            and each of r, g, and b are in the range 0..colormode,
            where colormode is either 1.0 or 255
          - pencolor(r, g, b)
            r, g, and b represent an RGB color, and each of r, g, and b
            are in the range 0..colormode

        If turtleshape is a polygon, the outline of that polygon is drawn
        with the newly set pencolor.

        Example (for a Turtle instance named turtle):
        >>> turtle.pencolor('brown')
        >>> tup = (0.2, 0.8, 0.55)
        >>> turtle.pencolor(tup)
        >>> turtle.pencolor()
        '#33cc8c'
        N)rX)rr9rWrrs   rrXz
TPen.pencolorsE:NN4(E&HHeH$;;t~~..rc|r4|j|}||jk(ry|j|y|j|jS)a] Return or set the fillcolor.

        Arguments:
        Four input formats are allowed:
          - fillcolor()
            Return the current fillcolor as color specification string,
            possibly in hex-number format (see example).
            May be used as input to another color/pencolor/fillcolor call.
          - fillcolor(colorstring)
            s is a Tk color specification string, such as "red" or "yellow"
          - fillcolor((r, g, b))
            *a tuple* of r, g, and b, which represent, an RGB color,
            and each of r, g, and b are in the range 0..colormode,
            where colormode is either 1.0 or 255
          - fillcolor(r, g, b)
            r, g, and b represent an RGB color, and each of r, g, and b
            are in the range 0..colormode

        If turtleshape is a polygon, the interior of that polygon is drawn
        with the newly set fillcolor.

        Example (for a Turtle instance named turtle):
        >>> turtle.fillcolor('violet')
        >>> col = turtle.pencolor()
        >>> turtle.fillcolor(col)
        >>> turtle.fillcolor(0, .5, 0)
        N)rB)rr:rWrrs   rrBzTPen.fillcolorsE8NN4(E'HHuH%;;t//rFrrrcp|j}|r|jd|j|y)z_To be overwritten by child class RawTurtle.
        Includes no TNavigator references.
        FrIN)rOrW)rrrrrYs     rrtz
TPen.teleports.++-HHUH#!rc(|jdy)zMakes the turtle visible.

        Aliases: showturtle | st

        No argument.

        Example (for a Turtle instance named turtle):
        >>> turtle.hideturtle()
        >>> turtle.showturtle()
        TshownNrWrs rrpzTPen.showturtles	
trc(|jdy)aYMakes the turtle invisible.

        Aliases: hideturtle | ht

        No argument.

        It's a good idea to do this while you're in the
        middle of a complicated drawing, because hiding
        the turtle speeds up the drawing observably.

        Example (for a Turtle instance named turtle):
        >>> turtle.hideturtle()
        Fr[Nr]rs rrLzTPen.hideturtle	s	
urc|jS)zReturn True if the Turtle is shown, False if it's hidden.

        No argument.

        Example (for a Turtle instance named turtle):
        >>> turtle.hideturtle()
        >>> print turtle.isvisible():
        False
        )r8rs rrPzTPen.isvisible	s{{rc|j|j|j|j|j|j
|j|j|j|j|jd}|s|s|St|tr|}ni}|j|i}|D]
}||||<|jr|jjd|fd}d|vr|j|dk7rd}d|vr?t|dt r|j#|df|d<|j|dk7rd}d|vr|j|dk7rd}|r|j%d|vr
|d|_d|vr
|d|_d|vr
|d|_d|vr5t|dt r|j#|df|d<|d|_d	|vr
|d	|_d
|vr
|d
|_d|vr&|d}t|t&t(fr||f}||_d|vr
|d|_d
|vr
|d
|_	d|vr
|d|_d|vr
|d|_
d|vsd|vsd|vr}|j\}	}
|j}t+j,|jt+j.|j}
}|	|
z|
||
z|zz|	|z|
|
||zz
zf|_|j3y)aLReturn or set the pen's attributes.

        Arguments:
            pen -- a dictionary with some or all of the below listed keys.
            **pendict -- one or more keyword-arguments with the below
                         listed keys as keywords.

        Return or set the pen's attributes in a 'pen-dictionary'
        with the following key/value pairs:
           "shown"      :   True/False
           "pendown"    :   True/False
           "pencolor"   :   color-string or color-tuple
           "fillcolor"  :   color-string or color-tuple
           "pensize"    :   positive number
           "speed"      :   number in range 0..10
           "resizemode" :   "auto" or "user" or "noresize"
           "stretchfactor": (positive number, positive number)
           "shearfactor":   number
           "outline"    :   positive number
           "tilt"       :   number

        This dictionary can be used as argument for a subsequent
        pen()-call to restore the former pen-state. Moreover one
        or more of these attributes can be provided as keyword-arguments.
        This can be used to set several pen attributes in one statement.


        Examples (for a Turtle instance named turtle):
        >>> turtle.pen(fillcolor="black", pencolor="red", pensize=10)
        >>> turtle.pen()
        {'pensize': 10, 'shown': True, 'resizemode': 'auto', 'outline': 1,
        'pencolor': 'red', 'pendown': True, 'fillcolor': 'black',
        'stretchfactor': (1,1), 'speed': 3, 'shearfactor': 0.0}
        >>> penstate=turtle.pen()
        >>> turtle.color("yellow","")
        >>> turtle.penup()
        >>> turtle.pen()
        {'pensize': 10, 'shown': True, 'resizemode': 'auto', 'outline': 1,
        'pencolor': 'yellow', 'pendown': False, 'fillcolor': '',
        'stretchfactor': (1,1), 'speed': 3, 'shearfactor': 0.0}
        >>> p.pen(penstate, fillcolor="green")
        >>> p.pen()
        {'pensize': 10, 'shown': True, 'resizemode': 'auto', 'outline': 1,
        'pencolor': 'red', 'pendown': True, 'fillcolor': 'green',
        'stretchfactor': (1,1), 'speed': 3, 'shearfactor': 0.0}
        )r\rYrXrBrZrqrb
stretchfactorrorrurWFrYTrXrZrBrqrbrarorr\ruN)r8r;r9r:r7r<r4r=r>rAr?rdictr-rrHrr_newLinerrrrrr@r)rrWpendict_pdp_p_bufrnewLinesfscxscyshfsacas              rrWzTPen.pen(	s^#'++"&--"&.."&//"&--"&++"&"2"2"&"5"5"&"3"3"&"4"4"&**wJc4 AA		#Cc(F3K	#??OO  %1>}}),?!J-/ $*
/? @*
~~:.>}}),MMO>iLDM?z]DN>iLDM!!K.%0!%;0A!B+nDOa<G*DK1 Da?#B"sEl+"X"$DA !- 0D>!"9Da<G*DKQ;6DJa6Q;-12D**HC##CXXdjj)488DJJ+?B!$Rc"frk):!$Rb3r6k): <Drcyr*rrusePoss  rrcz
TPen._newLine	r+rcyr*r)rrLforceds   rrzTPen._update	r+rcyr*rrWs  rrzTPen._color	r+rcyr*rrWs  rrzTPen._colorstr	r+rrrT)TF)!rrrrrr/r5rbrZr[rYrOrqr:rXrBr0rtrprLrPrWrcrrrr|r{r^rVr>rrrNrrrr2r2s#'|"4
#:.#K0'8 . 
$L,M\#/J"0H"5"D"T" 
{~>>>>
E	B	B	BD	B	Brr2ceZdZdZdZdZy)_TurtleImagez6Helper class: Datatype to store Turtle attributes
    cB||_d|_|j|yr)rr	_setshape)rr
shapeIndexs   rr/z_TurtleImage.__init__	s
z"rc6|j}||_|jdcxk(r|j|jk(ry|jdcxk(r|j|jk(ry|jdvr|j	|j
n1|jdk(r"|j
D]}|j	||j|j|_|jdk(r|j
|_y|jdk(r.|j|jdj|_y|jdk(r;|j|jDcgc]}|j
c}|_yycc}w)Nr4r)rr4r6r)	rr{rrzr_itemrrr9)rr{rrs    rrzz_TurtleImage._setshape	sR$::FfnnZ&@&F&FFG::DFNN:$>$D$DDE::--NN4::&
ZZ:
%


%t$
%^^J/55
::"++-DJ
ZZ7
",,V^^G-D-J-JKDJ
ZZ:
%*0..*D*J*JL4&,,.LDJ&Ls5FN)rrrrr/rzrrrrxrx	s#
LrrxceZdZdZgZdedededfdZdZdZd	Z	d
Z
dZdZd
Z
d<dZdZdZdZd<dddeddfdZdZd=dZd>dZd=dZdZd=dZdZd?dZdZd Zd@d!Zd"Zd#Z d$Z!d%Z"d=d&Z#d'Z$d(Z%d)Z&dAd*Z'd+Z(d,Z)d-Z*d=d.Z+d/Z,dBd0Z-d1Z.d2Z/d3Z0d4Z1d5Z2e2Z3d=d6Z4dCd7Z5dCd8Z6dCd9Z7d:Z8d;Z9eZ:y)DrzvAnimation part of the RawTurtle.
    Puts RawTurtle upon a TurtleScreen and provides tools for
    its animation.
    Nrlrrc
t|tr||_nt|tr9|tj
vrtj
j
|||_nt|ttfrgtj
D]}|j|k(s||_nIt||_tj
j
|jntd|z|j}tj||jtj||jj
||j!|_t%|||_d|_d|_dx|_|_||_d|_|j!|_|j6g|_|j4g|_g|_||_tA||_!|jEy)Nzbad canvas argument %sF)#r_Screenrr	rscreensrrr2rr1rr/rr2rrdrawingLineItemrxr_poly
_creatingPoly	_fillitem	_fillpathr8_hidden_from_screencurrentLineItemrcurrentLiner
stampItems_undobuffersizer@rr)rcanvasrlrrrs      rr/zRawTurtle.__init__	sfg& DK

-Y...!!((0 DK
 8
9#++
699&"(DK
6
+62!!((5%&>&GHHD&++-0

dt$%113"651
"*..#( %113 NN+**+
-!.1rctj|tj||j	|j|j
y)aDelete the turtle's drawings and restore its default values.

        No argument.

        Delete the turtle's drawings from the screen, re-center the turtle
        and set variables to the default values.

        Example (for a Turtle instance named turtle):
        >>> turtle.position()
        (0.00,-22.00)
        >>> turtle.heading()
        100.0
        >>> turtle.reset()
        >>> turtle.position()
        (0.00,0.00)
        >>> turtle.heading()
        0.0
        N)rrar2r5_clearrrrs rrazRawTurtle.reset
s<&	D
rcB||dkrd|_yt||_y)aSet or disable undobuffer.

        Argument:
        size -- an integer or None

        If size is an integer an empty undobuffer of given size is installed.
        Size gives the maximum number of turtle-actions that can be undone
        by the undo() function.
        If size is None, no undobuffer is present.

        Example (for a Turtle instance named turtle):
        >>> turtle.setundobuffer(42)
        Nr)rr@)rsizes  rrizRawTurtle.setundobuffer 
s!<419"DO%dmDOrcP|jy|jjS)zReturn count of entries in the undobuffer.

        No argument.

        Example (for a Turtle instance named turtle):
        >>> while undobufferentries():
        ...     undo()
        r)rrMrs rrzzRawTurtle.undobufferentries3
s$??"**,,rcdx|_|_|jD]}|jj	||jj|_g|_|jr%|jj|j|jg|_|j|j|jy)zDelete all of pen's drawingsN)rrrrrrrrr;rrr8rirrs  rrzRawTurtle._clear@
s*..JJ	&DKK%	&#{{668==##DNN3**+
4//0rcD|j|jy)agDelete the turtle's drawings from the screen. Do not move turtle.

        No arguments.

        Delete the turtle's drawings from the screen. Do not move turtle.
        State and position of the turtle as well as drawings of other
        turtles are not affected.

        Examples (for a Turtle instance named turtle):
        >>> turtle.clear()
        N)rrrs rr6zRawTurtle.clearN
s	

rc*|jj|jjdk7ryt|jdkDrG|jj|j|j|j|jyyr)	rrrr
rrrr9r7rs rrzRawTurtle._update_data]
so!!#;;%%*t "KK!!$"6"68H8H"&..$--
A#rc|j}|jdk(ry|jdk(rL|j|j|j	|j|jy|j|jdk(r6|jD]}|j|j	yy)z&Perform a Turtle-data update.
        rNr)	rrrrrrr}rr,)rrrs   rrzRawTurtle._updatee
s??a
__
!NNMM&,,-$$))$AMMO$ *rc:|jj||S)amTurns turtle animation on/off and set delay for update drawings.

        Optional arguments:
        n -- nonnegative  integer
        delay -- nonnegative  integer

        If n is given, only each n-th regular screen update is really performed.
        (Can be used to accelerate the drawing of complex graphics.)
        Second arguments sets delay value (see RawTurtle.delay())

        Example (for a Turtle instance named turtle):
        >>> turtle.tracer(8, 25)
        >>> dist = 2
        >>> for i in range(200):
        ...     turtle.fd(dist)
        ...     turtle.rt(90)
        ...     dist += 2
        )rr+)rflagrs   rr zRawTurtle._tracerw
s&{{!!$..rc8|jj|Sr)rrrWs  rrzRawTurtle._color
s{{!!$''rc8|jj|Sr)rrrWs  rrzRawTurtle._colorstr
s{{$$T**rct|tr|S	|\}}}|j
jdk(r#|||fDcgc]}td|zc}\}}}d|cxkrdkrnnd|cxkrdkrnn
d|cxkrdksnt	dt|zd|||fzS#ttf$rt	dt|zwxYwcc}w)z,Convert colortriples to hexstrings.
        rrrrrrr)rrrrr1rr~r)rrXrrrrs      r_ccz
RawTurtle._cc
sdC K	MGAq!;;!!S(011ay9!uU1W~9GAq!a3Q!]s]a3%&>T&JKK!Q**
:&	M%&?#d)&KLL	M:sBC'CFrrrcR|j}|j}|r|jd|r|s|j||n|jd}||n|jd}t|||_|j||r|s|j
yyy)aZInstantly move turtle to an absolute position.

        Arguments:
        x -- a number      or     None
        y -- a number             None
        fill_gap -- a boolean     This argument must be specified by name.

        call: teleport(x, y)         # two coordinates
        --or: teleport(x)            # teleport to x position, keeping y as is
        --or: teleport(y=y)          # teleport to y position, keeping x as is
        --or: teleport(x, y, fill_gap=True)
                                     # teleport but fill the gap in between

        Move turtle to an absolute position. Unlike goto(x, y), a line will not
        be drawn. The turtle's orientation does not change. If currently
        filling, the polygon(s) teleported from will be filled after leaving,
        and filling will begin again after teleporting. This can be disabled
        with fill_gap=True, which makes the imaginary line traveled during
        teleporting act as a fill barrier like in goto(x, y).

        Example (for a Turtle instance named turtle):
        >>> tp = turtle.pos()
        >>> tp
        (0.00,0.00)
        >>> turtle.teleport(60)
        >>> turtle.pos()
        (60.00,0.00)
        >>> turtle.teleport(y=10)
        >>> turtle.pos()
        (60.00,10.00)
        >>> turtle.teleport(20, 30)
        >>> turtle.pos()
        (20.00,30.00)
        FrINrr)rOrCrWr?rrr2)rrrrrYwas_fillingrrs        rrtzRawTurtle.teleport
sF++-llnHHUH#xMMO]q(9]q(9ue,!xOO (;rct|j}|j|j|j}d|_d|_t	|}||_||_||_t||jj|_|jj||j|jjj}|dk(r |j|j_n|dk(r8|j|jdj|j_n]|dk(rX|j|jjjDcgc]}|jc}|j_|j|_|j#|Scc}w)aCreate and return a clone of the turtle.

        No argument.

        Create and return a clone of the turtle with same position, heading
        and turtle properties.

        Example (for a Turtle instance named mick):
        mick = Turtle()
        joe = mick.clone()
        Nr4rrr6)rrcr;rrrxr{rrrzrrr}rr9rrr)rrrqttypers      rr9zRawTurtle.clone
sN

dmm$TN(>(>?q!t{{556<<I#//1AHHN
g
#001H1N1NOAHHN
j
 $nnT[[-C-CDJJLtf002LAHHN"..0				Ls%F5c||jjS||jjvrt	d|z|jj||j
y)aSet turtle shape to shape with given name / return current shapename.

        Optional argument:
        name -- a string, which is a valid shapename

        Set turtle shape to shape with given name or, if name is not given,
        return name of current shape.
        Shape with name must exist in the TurtleScreen's shape dictionary.
        Initially there are the following polygon shapes:
        'arrow', 'turtle', 'circle', 'square', 'triangle', 'classic'.
        To learn about how to deal with shapes see Screen-method register_shape.

        Example (for a Turtle instance named turtle):
        >>> turtle.shape()
        'arrow'
        >>> turtle.shape("turtle")
        >>> turtle.shape()
        'turtle'
        NzThere is no shape named %s)rr{rrr1rzr)rrs  rrlzRawTurtle.shape
sZ(<;;)))t{{,,..%&BT&IJJd#rc(||cxur|cxur!nn|j\}}|||jfS|dk(s|dk(rtd||||f}n%||f}n ||jd|f}n|j}||j}|jd||y)aOSet/return turtle's stretchfactors/outline. Set resizemode to "user".

        Optional arguments:
           stretch_wid : positive number
           stretch_len : positive number
           outline  : positive number

        Return or set the pen's attributes x/y-stretchfactors and/or outline.
        Set resizemode to "user".
        If and only if resizemode is set to "user", the turtle will be displayed
        stretched according to its stretchfactors:
        stretch_wid is stretchfactor perpendicular to orientation
        stretch_len is stretchfactor in direction of turtles orientation.
        outline determines the width of the shapes's outline.

        Examples (for a Turtle instance named turtle):
        >>> turtle.resizemode("user")
        >>> turtle.shapesize(5, 5, 12)
        >>> turtle.shapesize(outline=8)
        Nrz(stretch_wid/stretch_len must not be zerorD)rbrar)r=rAr1rW)rstretch_widstretch_lenrras     rrmzRawTurtle.shapesizes*+88'+':':$KT-?-???!{a/%&PQQ"" +[ 8
 +[ 8


$ //2K?M //M?((GF,g		?rcF||jS|jd|y)aSet or return the current shearfactor.

        Optional argument: shear -- number, tangent of the shear angle

        Shear the turtleshape according to the given shearfactor shear,
        which is the tangent of the shear angle. DO NOT change the
        turtle's heading (direction of movement).
        If shear is not given: return the current shearfactor, i. e. the
        tangent of the shear angle, by which lines parallel to the
        heading of the turtle are sheared.

        Examples (for a Turtle instance named turtle):
        >>> turtle.shape("circle")
        >>> turtle.shapesize(5,2)
        >>> turtle.shearfactor(0.5)
        >>> turtle.shearfactor()
        >>> 0.5
        NrD)rbro)r>rW)rshears  rrozRawTurtle.shearfactor<s%&=$$$F6rcVtjddd|j|y)a{Rotate the turtleshape to point in the specified direction

        Argument: angle -- number

        Rotate the turtleshape to point in the direction specified by angle,
        regardless of its current tilt-angle. DO NOT change the turtle's
        heading (direction of movement).

        Deprecated since Python 3.1

        Examples (for a Turtle instance named turtle):
        >>> turtle.shape("circle")
        >>> turtle.shapesize(5,2)
        >>> turtle.settiltangle(45)
        >>> turtle.stamp()
        >>> turtle.fd(50)
        >>> turtle.settiltangle(-45)
        >>> turtle.stamp()
        >>> turtle.fd(50)
        zturtle.RawTurtle.settiltangle()zn{name!r} is deprecated since Python 3.1 and scheduled for removal in Python {remove}. Use tiltangle() instead.)r
)rN)warnings_deprecatedrvrs  rrhzRawTurtle.settiltangleSs,*	>X$+	-	
urcF|Itj|j|jz}||jz|j
zS||jz|jz}tj|tjz}|jd|y)aSet or return the current tilt-angle.

        Optional argument: angle -- number

        Rotate the turtleshape to point in the direction specified by angle,
        regardless of its current tilt-angle. DO NOT change the turtle's
        heading (direction of movement).
        If angle is not given: return the current tilt-angle, i. e. the angle
        between the orientation of the turtleshape and the heading of the
        turtle (its direction of movement).

        (Incorrectly marked as deprecated since Python 3.1, it is really
        settiltangle that is deprecated.)

        Examples (for a Turtle instance named turtle):
        >>> turtle.shape("circle")
        >>> turtle.shapesize(5, 2)
        >>> turtle.tiltangle()
        0.0
        >>> turtle.tiltangle(45)
        >>> turtle.tiltangle()
        45.0
        >>> turtle.stamp()
        >>> turtle.fd(50)
        >>> turtle.tiltangle(-45)
        >>> turtle.tiltangle()
        315.0
        >>> turtle.stamp()
        >>> turtle.fd(50)
        NrD)rbru)	rr;r?rrrr_rrW)rrrus   rrvzRawTurtle.tiltanglens>=LL,,t/@/@@D4---1A1AAA6D...1B1BBD<<%0DHHTH2rcH|j||jzy)aRotate the turtleshape by angle.

        Argument:
        angle - a number

        Rotate the turtleshape by angle from its current tilt-angle,
        but do NOT change the turtle's heading (direction of movement).

        Examples (for a Turtle instance named turtle):
        >>> turtle.shape("circle")
        >>> turtle.shapesize(5,2)
        >>> turtle.tilt(30)
        >>> turtle.fd(50)
        >>> turtle.tilt(30)
        >>> turtle.fd(50)
        N)rvrs  rruzRawTurtle.tilts"	
ut~~//0rc$||cxur|cxur|cxur

|jS|j\}}}}||}||}||}||}||z||zz
dk(rtd||||f|_tj||tjz}	tj
|	tj|	}}
||z|
|zz
||z|
|zz
|
|z||zz|
|z||zzf\}}
}}||f|_|
|z|_|	|_	|jdy)aSet or return the current transformation matrix of the turtle shape.

        Optional arguments: t11, t12, t21, t22 -- numbers.

        If none of the matrix elements are given, return the transformation
        matrix.
        Otherwise set the given elements and transform the turtleshape
        according to the matrix consisting of first row t11, t12 and
        second row t21, 22.
        Modify stretchfactor, shearfactor and tiltangle according to the
        given matrix.

        Examples (for a Turtle instance named turtle):
        >>> turtle.shape("square")
        >>> turtle.shapesize(4,2)
        >>> turtle.shearfactor(-0.5)
        >>> turtle.shapetransform()
        (4.0, -1.0, -0.0, 2.0)
        Nrz0Bad shape transform matrix: must not be singularrDrE)r@r1rrrrrr=r>r?rW)rt11t12t21t22m11m12m21m22alfarmrna11a12a21a22s                rrnzRawTurtle.shapetransforms=(#+++###,!--S#s?#C?#C?#C?#C9sSy A%%&XYYc3/zz3$$txx/$$B fr#vor#v3 fr#vor#v3@S#s!3hG
F#rc	j|j}|j\}}|j\}}t|||jz|j
z}dt
|z|z\}}|D	cgc]<\}}	|||z||	zz|j
zz|||z||	zz|jzzf>c}	}Scc}	}w)zlComputes transformed polygon shapes from a shape
        according to current position and heading.
        r)rrrrrrr)
rr=rp0p1e0e1errs
          r
_polytrafozRawTurtle._polytrafosBB"b6==(6==89A,!#BIMO?E1RT"Q$Y

--rB3q5A:v}}2L/LMO	OOs*AB/c|jj|jj}|jdk(r)|j|j|jdk(Sy)a@Return the current shape polygon as tuple of coordinate pairs.

        No argument.

        Examples (for a Turtle instance named turtle):
        >>> turtle.shape("square")
        >>> turtle.shapetransform(4, -1, 0, 2)
        >>> turtle.get_shapepoly()
        ((50, -20), (30, 20), (-50, 20), (-30, -20))

        r4r6N)rrzrr{r
_getshapepolyr9)rrls  rrHzRawTurtle.get_shapepolysS##DKK$:$:;;;)#%%ekk5;;*3LMM$rc|jdk(s|r|j\nE|jdk(r%td|jdz}|dd|f\n|jdk(r|St	fd|DS)z`Calculate transformed shape polygon according to resizemode
        and shapetransform.
        rDrCrg@rrc3PK|]\}}|z|zz|z|zzfywrr)rrrrrrrs   rrz*RawTurtle._getshapepoly.<locals>.<genexpr>s2JAc!ec!emSUSU]3Js#&)r4r@maxr7r)rr4r6r&rrrrs    @@@@rrzRawTurtle._getshapepolysv%!%!1!1Cc3



'At}}S()A!"Aq!Cc3



+NJ'JJJrc	|j}|j|jj}|j}|jj
}|jrd|jdk(rT|jdkDrDd|_	|j}|dk(r|jdk(rd}n(|jdk(r
|j}n|j}|j|j|}|j |j"}}|j%|||||dy|d	k(r|j'||j(|y|d
k(ryt+||D]i\}	\}
}}|j|j|
d}
|j%|	|
|j-||j-||jdkyy|jry|dk(r|j%|dd
d
nZ|d	k(r5|j'||j(|jdjn |d
k(r|D]}	|j%|	dd
d
d|_	y)zpManages the correct rendering of the turtle with respect to
        its shape, resizemode, stretch and tilt etc.rFr4rrrCTrnrr|rrr6Nrprprprr)rrzrr{rr}r8rrrr9r4r7rArrr:r9rrrzipr)rrrlrtitemtshaperfcocrr=s           rrzRawTurtle._drawturtles&t{{556!!;;600A5&//A:M',D$[[F	!##z1q1%%/T]]++a(:(:6(BC$..B  B<=4!I'!!!%@*$,/v,>_(D.4R??4+=+=dD+IJD$$T4dhhrl-1XXb\ASASY]%__%''	!  (@"bI'!!!%*0..*A*G*GI*$!MD$$T+CRLM'+D$rc	|j}|j|jj}|j}|j
}|dk(r|j
}|jdk(rd}n(|jdk(r
|j}n|j}|j|j|}|j|j}}|j|||||dn|dk(r/|jd}|j!||j"|n|d	k(rg}|D]#}	|j
}
|j%|
%t'|}t)||D]i\}
\}}}|j|j|d}|j|
||j+||j+||jdk|j,j%|j.j1d
|f|S)aStamp a copy of the turtleshape onto the canvas and return its id.

        No argument.

        Stamp a copy of the turtle shape onto the canvas at the current
        turtle position. Return a stamp_id for that stamp, which can be
        used to delete it by calling clearstamp(stamp_id).

        Example (for a Turtle instance named turtle):
        >>> turtle.color("blue")
        >>> turtle.stamp()
        13
        >>> turtle.fd(50)
        r4rrrCTrrrr6rs)rrzrr{rr9rr4r7rArrr:r9rrrrrrrrrrrH)rrrlrrstitemrrrelementrr=s            rrszRawTurtle.stamp"st{{556I'')F:-1q!!V+Q''!OOD$6$6v$>?E__dnnBVUR89t

E
g
((,Ffdnnf=
j
 F!
$))+

d#
$6]F(+FF(;
[$ntRt'9'9$'EF  t$((2,)-"T=O=OUY![
[	
v&gv./
rcj||jvrit|tr#|D]}|jj	|n|jj	||jj|d|f}|j}||jvry|jj|}|jj|||jkr!|jdz
|jz|_	|jj|jdz|jzdgy)z9does the work for clearstamp() and clearstamps()
        rsNr)rrrrrrrrCindexrDrBinsert)rstampidsubitemrbufrs      r_clearstampzRawTurtle._clearstampOsdoo%'5)&1GKK''01##G,OO""7+!ooszz!

  &

$CGGww{ckk1CG

37719ckk1D6:rcF|j||jy)aDDelete stamp with given stampid

        Argument:
        stampid - an integer, must be return value of previous stamp() call.

        Example (for a Turtle instance named turtle):
        >>> turtle.color("blue")
        >>> astamp = turtle.stamp()
        >>> turtle.fd(50)
        >>> turtle.clearstamp(astamp)
        N)rr)rrs  rr7zRawTurtle.clearstampes	
!rc||jdd}n$|dk\r|jd|}n|j|d}|D]}|j||jy)aDelete all or first/last n of turtle's stamps.

        Optional argument:
        n -- an integer

        If n is None, delete all of pen's stamps,
        else if n > 0 delete first n stamps
        else if n < 0 delete last n stamps.

        Example (for a Turtle instance named turtle):
        >>> for i in range(8):
        ...     turtle.stamp(); turtle.fd(30)
        ...
        >>> turtle.clearstamps(2)
        >>> turtle.clearstamps(-2)
        >>> turtle.clearstamps()
        Nr)rrr)rrtoDeleters    rr8zRawTurtle.clearstampstsd$
9q)H
!Vr*Hqr*H	#DT"	#rc
|j|j|jt|jt
f}|j}d|j|||j|jdd|j|j|jddff}|jr|jj||j}|jr1|jdk(r!||z
}|d|j zdz|d|j"zdzz}dt%|dzdd|jzz|jzzz}|d	|zz}	t'd|D]t}
|
dk(rd
}nd}||	|
zz|_|jr?|j)|j*||jf|j|j||j-v|jr)|j)|j*dd
|j|jr|jj/|t|jt
r|jj/|||_|j0r|j2j/|t5|jdkDr|j7|j-y)zMove the pen to the point end, thereby drawing a line
        if pen is down. All other methods for turtle movement depend
        on this one.
        goNrrrrr皙?rTFrprprrnr|*)r;r9r7rrrrrrrr
rrrHr<rrrrr	rrrrrrr
rc)rrgo_modesr
undo_entrystartdiffdiffsqnhopsdeltarrs            rrzRawTurtle._gotosa]]^^]]57DNNC++&&q)''(<(<=jjm%
??OO  ,;;6??a/ID1gfmm+a/476==3H12LLFc63;C,<)=dkk)IJKKECI&E1e_

6CC!&!2==$$T%9%9&+T^^%<%)^^T]]CI

}}  !5!57G46dmm!M==##C(dnnd+NN!!#&JJc"t 2%MMOrcT|\}}}}|\}}}}	|\}
}}}
|j}t|j|z
dkDrtd|
|_||_|ddgk(rd}n|}|j
|
||||jDcgc]}||
vs|j|dk(r|}}|D].}|j||jj|0|}|jr|jdk(r||z
}|d|jzd	z|d|jzd	zz}dt|dzd
d|jzz|jzzz}|d|zz}t!d|D]V}|dk(rd
}nd}|||zz|_|r+|j
|j"||jf||||j%X|r|j
|j"dd|||_|j&rOt)|j*dkDr|j*j-|j*gk(rd|_d|_|	rH|j.gk(rd|_tdn&|j.|j.j-|j%ycc}w)z)Reverse a _goto. Used for undo()
        rz$undogoto: HALLO-DA-STIMMT-WAS-NICHT!rprrrrrrrrrTFrNzUnwahrscheinlich in _undogoto!)rrrrrrrrrrrr<rrrrr	rrrr
rrJr)rentryoldnewrcoodatadrawingpcpsrCcLIcLrrrusepcrtodeleterrrrrrrs                         r	_undogotozRawTurtle._undogotos',#S(G#+ R$RUt~~#$s*9:"
&&!!EEbuB7#zzD!aun(.Q6(ADD	!ANN1JJa 	!;;6??a/9D1gfmm+a/476==3H12LLFc63;C,<)=dkk)IJKKECI&E1e_

6CC!$uqy$$T%9%9&+T^^%<%'S2

  !5!57G46b!B
4::"

 zzR%*"!
~~#!%67+""$YDs	J%J%c$|jr(|jjd||jf||jz}|jj	|}|j
j}|dk(r|jdkDrqd|jz}dtt||zz}d|z|z}t|D]2}|jj	||_|j4||_|jy)z&Turns pen clockwise by angle.
        rotrrg@rN)rrHrrrrrr<rrr	r)rr	neworientranglevelr#rrs        rrzRawTurtle._rotate
s??OO  %0B0B!CD
###LL''.	++&&a<DKK!OT[[(HCJx/00EIeOE5\
#||2259
!rct|jdkDr|jj|j|j|j
|j|jj|_|jj|jn'|jj|jdg|_|r|jg|_yy)zCloses current line item and starts a new one.
           Remark: if current line became too long, animation
           performance (via _drawline) slowed down considerably.
        rT)rN)r
rrrrr9r7rrrrrps  rrczRawTurtle._newLine
s
t 1$KK!!$"6"68H8H&*nndmm
E#';;#:#:#<D JJd223KK!!$"6"6D!A $/Drc6t|jtS)aReturn fillstate (True if filling, False else).

        No argument.

        Example (for a Turtle instance named turtle):
        >>> turtle.begin_fill()
        >>> if turtle.filling():
        ...     turtle.pensize(5)
        ... else:
        ...     turtle.pensize(3)
        )rrrrs rrCzRawTurtle.filling(
s$..$//rcv|jsD|jj|_|jj|j|jg|_|j|jr'|jjd|jf|jy)aCalled just before drawing a shape to be filled.

        No argument.

        Example (for a Turtle instance named turtle):
        >>> turtle.color("black", "red")
        >>> turtle.begin_fill()
        >>> turtle.circle(60)
        >>> turtle.end_fill()
        	beginfillN)rCrrrrrrrrcrrHrrs rr2zRawTurtle.begin_fill6
sy||~![[446DNJJdnn-..)

??OO  +t~~!>?rcp|jrt|jdkDro|jj	|j
|j|j|jr'|jjd|j
fdx|_|_|jyy)aFill the shape drawn after the call begin_fill().

        No argument.

        Example (for a Turtle instance named turtle):
        >>> turtle.color("black", "red")
        >>> turtle.begin_fill()
        >>> turtle.circle(60)
        >>> turtle.end_fill()
        rrdofillN)
rCr
rrrrr:rrHrrs rr?zRawTurtle.end_fillK
s<<>4>>"Q&%%dnndnn+/??&<??OO(((DNN)CD.22DNT^LLNrcX|s}t|ttfr5|j|}|jt|jdz}nh|j}|sZ|jt|jdz}n6|#|jt|jdz}|j|}|j}|jr-|jjdgd|j_
	|jdk(r|j|j|j||j||j!d|j||jrd|j_
yy#|j|wxYw)aDraw a dot with diameter size, using color.

        Optional arguments:
        size -- an integer >= 1 (if given)
        color -- a colorstring or a numeric color tuple

        Draw a circular dot with diameter size, using color.
        If size is not given, the maximum of pensize+4 and 2*pensize is used.

        Example (for a Turtle instance named turtle):
        >>> turtle.dot()
        >>> turtle.fd(50); turtle.dot(20, "blue"); turtle.fd(50)
        reNrTrCrF)rrrrr7rr9rWrrHrErbrNrYrZrXrD)rrr:rWs    rr=z
RawTurtle.dot_
s:$e-t,}}s4==!'<<==3t}}a+@@D|}}s4==!'<<NN5)Ehhj??OO  %)'+DOO$	 F*	LLNLLMM% LLOHHSM??',DOO$
HHSMs
A&FF)c|jj|j||||j\}}|j	|j
j
||jr|jjd|f|S)z)Performs the writing for write()
        wri)	rrrr9rrrrrH)rrrrrrs      rrzRawTurtle._write
smKK&&t~~sE4:>..J	c

$??OO  %/
rcT|jr-|jjdgd|j_|jt	||j|}|r%|j
\}}|j|||jrd|j_yy)aWrite text at the current turtle position.

        Arguments:
        arg -- info, which is to be written to the TurtleScreen
        move (optional) -- True/False
        align (optional) -- one of the strings "left", "center" or right"
        font (optional) -- a triple (fontname, fontsize, fonttype)

        Write text - the string representation of arg - at the current
        turtle position according to align ("left", "center" or right")
        and with the given font.
        If move is True, the pen is moved to the bottom-right corner
        of the text. By default, move is False.

        Example (for a Turtle instance named turtle):
        >>> turtle.write('Home = ', True, align="center")
        >>> turtle.write((0,0), True)
        rTFN)rrHrErrr7r\rf)rargmoverrrrrs        rr}zRawTurtle.write
s&??OO  %)'+DOO$kk#c(EKKM4888:DAqKKQ??',DOO$rc6|jg|_d|_y)aStart recording the vertices of a polygon.

        No argument.

        Start recording the vertices of a polygon. Current turtle position
        is first point of polygon.

        Example (for a Turtle instance named turtle):
        >>> turtle.begin_poly()
        TN)rrrrs rr3zRawTurtle.begin_poly
snn%
!rcd|_y)a7Stop recording the vertices of a polygon.

        No argument.

        Stop recording the vertices of a polygon. Current turtle position is
        last point of polygon. This will be connected with the first point.

        Example (for a Turtle instance named turtle):
        >>> turtle.end_poly()
        FN)rrs rr@zRawTurtle.end_poly
s#rcF|jt|jSy)zReturn the lastly recorded polygon.

        No argument.

        Example (for a Turtle instance named turtle):
        >>> p = turtle.get_poly()
        >>> turtle.register_shape("myFavouriteShape", p)
        N)rrrs rrEzRawTurtle.get_poly
s"::!$$"rc|jS)aReturn the TurtleScreen object, the turtle is drawing  on.

        No argument.

        Return the TurtleScreen object, the turtle is drawing  on.
        So TurtleScreen-methods can be called for that object.

        Example (for a Turtle instance named turtle):
        >>> ts = turtle.getscreen()
        >>> ts
        <turtle.TurtleScreen object at 0x0106B770>
        >>> ts.bgcolor("pink")
        )rrs rrGzRawTurtle.getscreen
s{{rc|S)aUReturn the Turtleobject itself.

        No argument.

        Only reasonable use: as a function to return the 'anonymous turtle':

        Example:
        >>> pet = getturtle()
        >>> pet.fd(50)
        >>> pet
        <turtle.Turtle object at 0x0187D810>
        >>> turtles()
        [<turtle.Turtle object at 0x0187D810>]
        rrs rrIzRawTurtle.getturtle
s	rc8|jj|S)zDSet delay value which determines speed of turtle animation.
        )rrrs  rrzRawTurtle._delays{{  ''rc|jj|jj||||j	y)aBind fun to mouse-click event on this turtle on canvas.

        Arguments:
        fun --  a function with two arguments, to which will be assigned
                the coordinates of the clicked point on the canvas.
        btn --  number of the mouse-button defaults to 1 (left mouse button).
        add --  True or False. If True, new binding will be added, otherwise
                it will replace a former binding.

        Example for the anonymous turtle, i. e. the procedural way:

        >>> def turn(x, y):
        ...     left(360)
        ...
        >>> onclick(turn)  # Now clicking into the turtle will turn it.
        >>> onclick(None)  # event-binding will be removed
        N)rrrr}rrs    rrSzRawTurtle.onclicks/$	
T[[..S#>rc|jj|jj||||j	y)aBind fun to mouse-button-release event on this turtle on canvas.

        Arguments:
        fun -- a function with two arguments, to which will be assigned
                the coordinates of the clicked point on the canvas.
        btn --  number of the mouse-button defaults to 1 (left mouse button).

        Example (for a MyTurtle instance named joe):
        >>> class MyTurtle(Turtle):
        ...     def glow(self,x,y):
        ...             self.fillcolor("red")
        ...     def unglow(self,x,y):
        ...             self.fillcolor("")
        ...
        >>> joe = MyTurtle()
        >>> joe.onclick(joe.glow)
        >>> joe.onrelease(joe.unglow)

        Clicking on joe turns fillcolor red, unclicking turns it to
        transparent.
        N)rrrr}rrs    rrUzRawTurtle.onreleases/,	
t{{00#sC@rch|jj|jj|||y)aBind fun to mouse-move event on this turtle on canvas.

        Arguments:
        fun -- a function with two arguments, to which will be assigned
               the coordinates of the clicked point on the canvas.
        btn -- number of the mouse-button defaults to 1 (left mouse button).

        Every sequence of mouse-move-events on a turtle is preceded by a
        mouse-click event on that turtle.

        Example (for a Turtle instance named turtle):
        >>> turtle.ondrag(turtle.goto)

        Subsequently clicking and dragging a Turtle will move it
        across the screen thereby producing handdrawings (if pen is
        down).
        N)rrrr}rs    rrTzRawTurtle.ondrag5s&$	
DKK--sC=rc|jy|dk(rB|\}}|j||z|jz|jj}y|dk(r|d}|j	|y|dk(r|j|y|dvr<|d}|jj||jj|y|dk(r%|d}|jj|dd	d	
y|dk(rY|d}dx|_|_||jvr7|jj||jj|yy|dk(r4tj||d|jjyy)
z2Does the main part of the work for undo()
        Nrrsrr)rr=rrrrrrW)rrrrJr7rrrrrrrrr2rW)ractionr;rdegPAUdummyrrs        r_undozRawTurtle._undoJsk??"U? ME6LL%t'9'99:OO'')E
w
!WFOOF#
t^NN4 
~
%7DKK%JJd#
x
7DKK!!$(>')2
"
7
{
"7D.22DNT^tzz!##D)

!!$'"u_HHT47#OO!rc|jy|jj}|d}|dd}|dk(r/|r,|j}|j|d|dd|r+yy|j||y)aundo (repeatedly) the last turtle action.

        No argument.

        undo (repeatedly) the last turtle action.
        Number of available undo actions is determined by the size of
        the undobuffer.

        Example (for a Turtle instance named turtle):
        >>> for i in range(4):
        ...     turtle.fd(50); turtle.lt(80)
        ...
        >>> for i in range(8):
        ...     turtle.undo()
        ...
        Nrrr)rrJr)rrrr;s    rryzRawTurtle.undojsy"??"""$aABxU?xxz

47DH-
JJvt$rrrrf)NNNN)Frv)FrQ)Arialr^rPr-);rrrrrrr/rarirzrr6rrr rrrr0rtr9rlrmrorhrvrurnrrHrrrsrr7r8rrrrcrCr2r?r=rr}r3r@rErGrIrFrrSrUrTrryrxrrrrr	sUG"G} $%5 6i&P2,&-1
A!$/*(+
+.5.D.T.`&P6&?P7.6%3N1&%$P
ON"K$,P+Z;,
83j?B$0 0*()-V	-:"#% "F(
*2>*"@%:Jrrchtjtt_tjS)zReturn the singleton screen object.
    If none exists at the moment, create a new one and return it,
    else return the existing one.)r_screenrrrrr
r
s!~~ >>rcdeZdZdZdZedZdZededededfdZd	Z	d
Z
dZdZy)
rNr*cttjhtxt_|_|jjtj|jj|jtjtd}td}td}td}td}td}|jj|||||jjt_tj|tj|j||||yy)Nr|rrrrr)r_rootrhr*_titler|_destroyr4rrprrr	r/r')rr|rrrrrs       rr/z_Screen.__init__s== ).0GMDJJJW^^,JJ  /??"ME(^F[)Il+J[)I[)IJJ""5&)ZH"jj335GO!!$8JJufi;#rr|rrrct|jdsy|jj}|jj}t	|t
rd|cxkrdkrnn||z}|||z
dz}t	|t
rd|cxkrdkrnn||z}|||z
dz}|jj
|||||jy)a Set the size and position of the main window.

        Arguments:
        width: as integer a size in pixels, as float a fraction of the screen.
          Default is 50% of screen.
        height: as integer the height in pixels, as float a fraction of the
          screen. Default is 75% of screen.
        startx: if positive, starting position in pixels from the left
          edge of the screen, if negative from the right edge
          Default, startx=None is to center window horizontally.
        starty: if positive, starting position in pixels from the top
          edge of the screen, if negative from the bottom edge
          Default, starty=None is to center window vertically.

        Examples (for a Screen instance named screen):
        >>> screen.setup (width=200, height=200, startx=0, starty=0)

        sets window to 200x200 pixels, in upper left of screen

        >>> screen.setup(width=.75, height=0.5, startx=None, starty=None)

        sets window to 75% of screen by 50% of screen and centers
        rwNrrr)hasattrrrrrrrwr-)rr|rrurvrshs       rr'z
_Screen.setups2tzz>2
ZZ
!
!
#
ZZ
"
"
$eU#UauHE>5jA%Ffe$f)9)9YF>6kQ&F

vvv>
rcxtjtjj||t_y)aqSet title of turtle-window

        Argument:
        titlestring -- a string, to appear in the titlebar of the
                       turtle graphics window.

        This is a method of Screen-class. Not available for TurtleScreen-
        objects.

        Example (for a Screen instance named screen):
        >>> screen.title("Welcome to the turtle-zoo!")
        N)rrr*r)rtitlestrings  rr*z
_Screen.titles'==$MM,$rc|j}|tjur,dt_dt_dt_dt_dt_|jy)NF)	rrrrrr4r	rr{)rroots  rrz_Screen._destroysDzz7== FK!FN GM"GO %rc$|jy)z~Shut the turtlegraphics window.

        Example (for a TurtleScreen instance named screen):
        >>> screen.bye()
        N)rrs rrz_Screen.byes
	


rcfd}j|tdry	ty#t$rt	dYywxYw)alGo into mainloop until the mouse is clicked.

        No arguments.

        Bind bye() method to mouseclick on TurtleScreen.
        If "using_IDLE" - value in configuration dictionary is False
        (default value), enter mainloop.
        If IDLE with -n switch (no subprocess) is used, this value should be
        set to True in turtle.cfg. In this case IDLE's mainloop
        is active also for the client script.

        This is a method of the Screen-class and not available for
        TurtleScreen instances.

        Example (for a Screen instance named screen):
        >>> screen.exitonclick()

        c&jy)z&Screen.bye() with two dummy-parametersN)r)rrrs  rexitGracefullyz+_Screen.exitonclick.<locals>.exitGracefully
sHHJrrNr)rSrrAttributeErrorexit)rr's` rrz_Screen.exitonclicksA&		
^$	J	G	s
.AA)
rrrrr4rrr/r'r*rrrrrrrrsREG
']F<"w-X+&tK/@&P%"rrc8eZdZdZdZdZedededfdZy)rzRawTurtle auto-creating (scrolled) canvas.

    When a Turtle object is created or a function derived from some
    Turtle method is called a TurtleScreen object is automatically created.
    Nrlrrctjtt_tj	|tj|||y)N)rlrr)rrr
rr/)rrlrrs    rr/zTurtle.__init__s;>>!#XFN4!&*8#*		,r)rrrrrrrr/rrrrrs1
DGG} $%5 6i	,rrcfi}tD]}d|z}t|j||<!tD]}d|z}t|j||<!t	d|zd5}td|D}|j
d|ddD]6}|j
d	t|z|j
d
||z8|d}|j
d	t|z|j
d||z|j
d|jdddy#1swYyxYw)
aCreate and write docstring-dictionary to file.

    Optional argument:
    filename -- a string, used as filename
                default value is turtle_docstringdict

    Has to be called explicitly, (not used by the turtle-graphics classes)
    The docstring dictionary will be written to the Python script <filename>.py
    It is intended to serve as a template for translation of the docstrings
    into different languages.
    z_Screen.zTurtle.z%s.pyrc3TK|] }|jddtvr|"yw)rrN)r_alias_list)rrs  rrz&write_docstringdict.<locals>.<genexpr>As+=Aa;=s&(zdocsdict = {

Nrz%s :
z        """%s
""",

z        """%s
"""

z}
)	_tg_screen_functionsrr_tg_turtle_functionsrrr}reprclose)rdocsdict
methodnamerrrs      rrr+s8H**
#S	))
*+*

"S	))
*
g 	%===	"#9	?C
GGHtCy()
GG-
=>	?2h	49$%	(8C=89			s
"B<D''D0cdd|jiz}t|}|j}|D]}	||t|_y#t
$rt
d|zY3wxYw)zRead in docstrings from lang-specific docstring dictionary.

    Transfer docstrings, translated to lang, from a dictionary-file
    to the methods of classes Screen and Turtle and - in revised form -
    to the corresponding functions.
    z!turtle_docstringdict_%(language)srzBad docstring-entry: %sN)r7
__import__r3rrrr)langmodnamemoduler3rs     rread_docstringsr:Mso2Z

4MMG

 FH3	3 (
DI3	3+c12	3sA		A#"A#zCannot find docsdict forz;Unknown Error when trying to import %s-docstring-dictionaryctj|}|jt|jjdd}g}|jjD]B}|jxxtjjk(rn xtjjk(rnn|j|jlxtjjk(r |jd|jxtjjk(r,|j|jd|jtjjk(r |jd|j.	td|jdd	j!|d
}t#||fS)a?Get strings describing the arguments for the given object

    Returns a pair of strings representing function parameter lists
    including parenthesis.  The first string is suitable for use in
    function definition and the second is suitable for use in function
    call.  The "self" parameter is not included.
    rN)
parameters*rz**zUnsupported parameter kind(z, ))inspect	signaturereplacerr<valueskind	ParameterPOSITIONAL_ONLYPOSITIONAL_OR_KEYWORDrrVAR_POSITIONALKEYWORD_ONLYVAR_KEYWORDRuntimeErrorrr)oborig_sigfunc_sig	call_argsparam	call_texts      rgetmethparlistrRjsy  $H++2245ab9 HI$$++-Mjj:1!!119'##99:  ,1""11  1UZZL!12/""//  EJJ<q!=>""..  2ejj\!23"#?LLMDIIi()+Ix=)##rcddl}|ytd}|jd|zd}|jd|z}|j	d|}|S)z<To reduce docstrings from RawTurtle class for functions
    rNr%s.r \(.+ %s\)::rerrBcompilesub)docstrrX
turtlename	newdocstrparexps     r_turtle_docreviser_W
~o&Juz1"5I
ZZ3
4F

3	*Ircddl}|ytd}|jd|zd}|jd|z}|j	d|}|S)z?To reduce docstrings from TurtleScreen class for functions
    rNrrTrrUrVrW)r[rX
screennamer]r^s     r_screen_docrevisercr`rardef {name}{paramslist}:
    if {obj} is None:
        if not TurtleScreen._RUNNING:
            TurtleScreen._RUNNING = True
            raise Terminator
        {obj} = {init}
    try:
        return {obj}.{name}{argslist}
    except TK.TclError:
        if not TurtleScreen._RUNNING:
            TurtleScreen._RUNNING = True
            raise Terminator
        raise
c|D]}t||}t|\}}|dk(rtd||0tj	|||||}	t|	t
||jt
|_y)Nrz>>>>>>)objinitr
paramslistargslist)getattrrRr__func_bodyformatr
globalsr)
	functionsrrerf	docreviser4rpl1pl2defstrs
          r_make_global_funcsrrs	B
j)!&)S"9(C%##$Z/2S$BVWY(1&..(A	*%	BrzTurtle._screenzScreen()zTurtle._penzTurtle()__main__cBtrtytyr)rOr^rVrrr	switchpenrus8DDrcttdttdt	tdt
dD]p}|dk(r
tt
dD]}tdtd|dk(rtdtttd	t	rtd
tdtdttdtdtdtdtd
t	tdd
tdd
tdt
dD].}tdtdtdtd0tdtt
dD].}tdtdtdtd0ty)zDemo of old turtle.py - moduleTdrrrerZmaroonrErrF
startstartrredr`N)rar+r{r1r>r|r	r2rDrQr:r?r`r})rrs  rdemo1r}s^
t


aq	AAv1X
R
Avh
DBKF		a
gu


b	
b	
c

lA
gq
eq	ABKHBK"I			tq	ABKHBK"I		
	
rc	tdttdtt	ddtdddz}t
dtdD]}tt|dtdtrttrttdtd	d}t!d
tdtdtdd
D]}|dkDr t#t%d	d|zz
dd|ztdD]}t'|tdt)|dz
}tdttdzdztdt+t'dt
dt-t/ddtdt#tdD]/}tddt
dt'dt
d1t)tdt+t'dt-t1dt3}|j5dt7}|j5d|j1d|j|j9d|jd|j;|j=dd|jd|j?|jd|j/dd|jd|jdtt	|d}|j|dkDr|j'd|jd |j|j	||j'd|d!zdk(r*|jA|jAt|dz
}|j|dkDr|jd"d#d$%|j!d&|j!dd'}tCjDdtr+|j|jtr+|j'd|jd(d)*|jG|dy+),zDemo of some new features.rrrrrxrzwait a moment...rgreenrzrWrVxFrEr|yellowre2rrCi(rfblueorangerg@g333333?rzCAUGHT! )rrVboldr`)rrrc,ttyr)rr)rrs  rbabazdemo2.<locals>.baba`sMErz  Click me!)Courierrr)rN)$rqrrrZrerwr<rcr	rur5r}rzryrarRrrXr2rBrAr?r^rVr:rlrIrbrrQr{rJr>rstimesleeprS)r!rlaengertrirrLrs        rdemo2r
s
a

71a=!!Q#
2r	AK62		 !!F !

2#

3r2
	"A1u#bd(Ar!t,1X
6
3

JbLFrF5719b.!
	"	3

2
2

eH
aq	A2rNrFrFrF		
	

2

2

hkv&!XBQ		C		"

QVH%q		!76?#ll6"Q&IIcNIIcNNN3;;v./FF1IrzQ		QJEll6"Q&			*#8	HWU		

1
!HHJKKM !	r
		-(?	AD!r)r)turtle_docstringdict)Frtkinterr-rrrr@rros.pathrrrcopyrr_tg_classesr/r0
_tg_utilities__all__r.rrrrrrrrrr	rr.rr2rjrhobjectrrr1rr@r	rr2rxrr
r
rrrrr:	_LANGUAGEImportErrorrRr_rcrjrrrrrrur}rrrrr<module>rs0KZ
'' I)!'/
--0DD(>*,	#	4	c		c		T		
	T		

		S				$				W		g		z		D		I	 	!	"")'	,:<1t
*$E*$j1
.*a#RXXa#FI6)BEE)0
B5vB5T	)	)
,1F,1^"6f"6Li#iVCCLR6RjL6L>ojob%
~l~@,Y,(
 D3"
	MI	""$H

  
B'#Z1BD' *.?Az2jaF
G	GMCWw1	/01@t1	
$i0M	HBKLMMs*G6
H
6
HH
H,H,+H,