python (3.11.7)

(root)/
lib/
python3.11/
__pycache__/
turtle.cpython-311.pyc

e3dZdZddlZddlZddlZddlZddlZddlZddl	Z	ddl
mZmZm
Z
ddlmZddlmZgdZgdZgd	Zd
dgZeezezezdgzZgd
Ziddddddddddddddddddddd d!d"d#d$d#d%d&d'd(d)d*d+d,d-d.d/d0Zd1Zd2Z	een#e$red3YnwxYwGd4d5eZd6Zd7Zd8Z djd:Z!Gd;d<ej"Z#e!e#ej$d=Gd>d?ej%Z&ej$Z$Gd@dAe'Z(GdBdeZ)GdCdDeZ*GdEdFe'Z+GdGdHe'Z,GdIdJe(Z-GdKdLe'Z.GdMdNe'Z/GdOdPe'Z0GdQdRe/e.Z1e1Z2dSZ3GdTdUe-Z4GdVdWe1Z5e5Z6dkdYZ7dZZ8ed)Z9	e9d*kre8e9n+#e:$red[e9Yne$red\e9zYnwxYwd]Z;d^Z<d_Z=d`Z>daZ?e?ee4dbdce=e?ee5dddee<e@ZAeBdfkr)dgZCdhZDdiZEeDeEeFdSdS)la

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.

z-turtle 1.1b- - for Python 3.1   -  4. 5. 2009N)isfilesplitjoin)deepcopy)simpledialog)	ScrolledCanvasTurtleScreenScreen	RawTurtleTurtleRawPenPenShapeVec2D)addshapebgcolorbgpicbyeclearscreen	colormodedelayexitonclick	getcanvas	getshapeslistenmainloopmodenuminputonkey
onkeypressonkeyrelease
onscreenclickontimerregister_shaperesetscreen
screensizesetupsetworldcoordinates	textinputtitletracerturtlesupdate
window_heightwindow_width)Obackbackward
begin_fill
begin_polybkcircleclear
clearstampclearstampsclonecolordegreesdistancedotdownend_fillend_polyfd	fillcolorfillingforwardget_polygetpen	getscreen
get_shapepoly	getturtlegotoheading
hideturtlehomehtisdown	isvisibleleftltonclickondrag	onreleasepdpenpencolorpendownpensizepenuppospositionpuradiansrightreset
resizemodertseth
setheadingsetpossetpositionsettiltangle
setundobuffersetxsetyshape	shapesizeshapetransformshearfactor
showturtlespeedststamptilt	tiltangletowards
turtlesizeundoundobufferentriesupwidthwritexcorycorwrite_docstringdictdone
Terminator)rr1r4rArNrRrVr\r^rcrdrfrgrrrwrzr{r{?heightg?	canvwidthi
canvheighti,	leftright	topbottomrstandardr?r
undobuffersizeirlclassicrXblackrBrbnoresizevisibleTlanguageenglish
exampleturtleturtlescreenzPython Turtle GraphicsF)
examplescreenr*
using_IDLEcNt|d5}|}dddn#1swxYwYi}|D]}|}|r|dr.	|d\}}n%#t
$rt
d|d|YiwxYw|}|}|dvrt|}n5	d|vrt|}nt|}n#t
$rYnwxYw|||<|S)	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.11.7/bootstrap/lib/python3.11/turtle.pyconfig_dictrs	
h		!;;==!!!!!!!!!!!!!!!Gzz||	ts++		CJC			ExxxEFFFH	iikk

999KKEE
%<<!%LLEEJJE



Ns02660B		B+*B++#D
DDcd}i}i}t|rt|}d|vrd|dz}	tt\}}t	||}n#t
$rd}YnwxYwt|rt|}t|t|dS)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{++					
i*y))KKKKs'AA,+A,z"No configfile read, reason unknowncNeZdZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZ
dS)
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
    c<t|||fSN)tuple__new__)clsxys   rrz
Vec2D.__new__s}}S1a&)))c^t|d|dz|d|dzSNrrselfothers  r__add__z
Vec2D.__add__,T!WU1X%tAwuQx'7888rct|tr#|d|dz|d|dzzSt|d|z|d|zSr)
isinstancerrs  r__mul__z
Vec2D.__mul__sYeU##	5758#DGE!H$444T!WU]DGEM222rct|tst|tr"t|d|z|d|zStSr)rrrrNotImplementedrs  r__rmul__zVec2D.__rmul__sKeS!!	7Zu%=%=	7aQ
666rc^t|d|dz
|d|dz
Srrrs  r__sub__z
Vec2D.__sub__rrc>t|d|dSrrrs r__neg__z
Vec2D.__neg__	sd1gXQx(((rctj|Sr)mathhypotrs r__abs__z
Vec2D.__abs__sz4  rc(t|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.rotate
sd1gXtAw''U##x1T!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__rrrrrrrrrrrrrrrs***999333999)))!!!???"""$$$$$rrct|j}||D]}t|||jD]'\}}t
|tjkr|||<(dS)#helper function for Scrolled CanvasN)	list	__bases__reverse__methodDict__dict__itemstypetypesFunctionType)r_dictbaseList_superrrs      rrr"sCM""H$$VU####l((**
U;;%,,,E#JrcNi}t|||S)r)rkeys)rrs  r	__methodsr,s%Ee::<<rzTdef %(method)s(self, *args, **kw): return self.%(attribute)s.%(method)s(*args, **kw)rci}t||i}t|}|D]2}|dddks|dddks||vs||vr'||||<3|D]S\}}	||	d}
t	|t
r
t||dz}t||
t|||
|TdS)Nr_)methodfunc)r	attribute)	rrrrrstr__stringBodyexecsetattr)	fromClasstoClasstoPartexclude_dict_1rmfcexrrd
execStrings            r__forwardmethodsr6sG'"""E
I

Cllnn$$
bqb6S==BrssGsNNbGmmrSyyE"II

..t,,fc""	I6HHH
Z	61V9----
..rcVeZdZdZ		ddZddZdZd	Zd
ZdZ	dZ
d
ZdZdZ
dS)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.
    ^Xc
tj||||||_||c|_|_||c|_|_d|_	tj
||||j	tjd|_tj
||jjtj|_tj
||jj|_|j|jj|jj|dd	d
|dd	d
|jd	|d	ddd	d	d|jd	|d	dd	d	d	d|jd	|d	d	dd	d	d||jd
|jdS)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      rr1zScrolledCanvas.__init__Qs
$eFCCC..00"'
DK*3Z'yuV$(GBI1NNN|FDL4F+-=:::|FDL4FGGGdl.>.2l.>		@	@	@!Aq111Qq!444q1!!&		B	B	Bq1!!&		B	B	Bq1!!&		B	B	B

mT];;;;;rNc|r||_|r||_|r||_|j||jdz|jdz|jdz|jdzf|jd|j|jz
dzz|jz|jd|j|jz
dzz|jz|	dS)z<Adjust canvas and scrollbars according to given canvas size.r)rscrollregionrN)
rrrr6configxview_movetor{yview_movetor
adjustScrollsrrrrs    rrazScrolledCanvas.resetjs	'&DN	)(DO
	DGr'+~oq&84?:JA:M'+~q'8$/1:L&N		O	O	O	
!!#t~
'BR'G"H?C~#N	O	O	O!!#t'Cb'H"I>Bo#N	O	O	Orc
:|j}|j}|jd|j|z
z|jz|jd|j|z
z|jz||jks||jkrF|jd|dddddd|j	d|dddddddS|j
|j	
dS)zA Adjust scrollbars according to window- and canvas-size.
        rrrr%r&N)r6winfo_widthwinfo_heightrIrrJrr:rAr<grid_forget)rcwidthcheights   rrKzScrolledCanvas.adjustScrolls|s7))++,++--!!#t~f'<"=dn"LMMM!!#tw'>"?"OPPPDN""g&?&?L1Dqa%&a

P
P
PL1Dqa%&a

P
P
P
P
P
L$$&&&L$$&&&&&rc.|dS)zself-explanatoryN)rK)revents  rrCzScrolledCanvas.onResizesrc |jj|S@ 'forward' method, which canvas itself has inherited...
        )r6bboxrargss  rrXzScrolledCanvas.bboxs!t| $''rc&|jj|i|SrV)r6cgetrrZkwargss   rr\zScrolledCanvas.cgets!t| $1&111rc*|jj|i|dSrWN)r6rHr]s   rrHzScrolledCanvas.config$	T,V,,,,,rc*|jj|i|dSr`)r6rBr]s   rrBzScrolledCanvas.binds$	4*6*****rc*|jj|i|dSr`)r6unbindr]s   rrdzScrolledCanvas.unbindrarc8|jdSr`)r6focus_forcers rrfzScrolledCanvas.focus_forces	
  """""r)rrrrNNN)rrrrr1rarKrCrXr\rHrBrdrfrrrrrKs
25DG<<<<2$''' (((
222
---
+++
---
#####rrr6c<eZdZdZdZdZdZdZdZdZ	dZ
d	S)
_Rootz'Root class for Screen based on Tkinter.cDtj|dSr)r/Tkr1rs rr1z_Root.__init__s
trcnt||||||_|jdddS)Nrboth)expandfill)rr6pack)rr{rrQrRs     rsetupcanvasz_Root.setupcanvass:%dE667KK00000rc|jSr)r6rs r
_getcanvasz_Root._getcanvass
|rc>|d||||fzdS)Nz%dx%d%+d%+d)geometry)rr{rstartxstartys     rset_geometryz_Root.set_geometrys(

mUFFF$CCDDDDDrc2|d|dS)NWM_DELETE_WINDOW)wm_protocol)rdestroys  r	ondestroyz_Root.ondestroys+W55555rc*|Sr)winfo_screenwidthrs r	win_widthz_Root.win_widths%%'''rc*|Sr)winfo_screenheightrs r
win_heightz_Root.win_heights&&(((rN)rrrrr1rqrsrxr}rrrrrriris11111EEE666((()))))rriceZdZdZdZdZdZdZ		d&dZd	Z			d&d
Z
dZdZd
Z
dZd'dZdZd(dZd(dZd(dZd(dZdZd'dZdZdZdZdZdZdZdZdZd Zd)d!Z d"Z!d#Z"d$Z#d)d%Z$dS)*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.
    cftjdd|j}||S)z$return a blank image object
        r)r{rrD)r/
PhotoImagecvblank)rimgs  r_blankimagezTurtleScreenBase._blankimages.m!Adg>>>		
rc8tj||jS)z`return an image object containing the
        imagedata from a gif-file named filename.
        )filerD)r/rr)rrs  r_imagezTurtleScreenBase._images}(47;;;;rc||_t|tr|jj}|jj}n{t|jd}t|jd}|j|dz|dz|dz|dzf||_||_dx|_|_	dS)Nr{rrrFr)
rrrrrrr\rHxscaleyscale)rrwhs    rr1zTurtleScreenBase.__init__sb.))	G!A"AADGLL))**ADGLL**++AGNNA2q51"a%Aq!t*ENFFF$''dkkkrc<|jdddS)z<Create an invisible polygon item on canvas self.cv)
        )rrrrrrrrooutline)rcreate_polygonrs r_createpolyzTurtleScreenBase._createpolys"w%%&8r2%NNNrNFcg}|D]@\}}	|||jz||	|jzA|jj|g|R||j||||j||||j|||r|j|dSdS)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.
        Nro)rr{appendrrrcoords
itemconfigure	tag_raise)
rpolyitem	coordlistrorr{topclrrs
          r	_drawpolyzTurtleScreenBase._drawpolys	(	(DAqIIa$+o&&&IIqb4;&''''x%"%%%%G!!(!666G!!(G!<<<G!!(%!888	(Gh'''''	(	(rc	X|jddddddtjS)z9Create an invisible line item on canvas self.cv)
        rrr)ror{capstyle)rcreate_liner/ROUNDrs r_createlinezTurtleScreenBase._createlines4w""1aABa.0h#88	8rcn|Xg}|D]@\}}|||jz|||jzA|jj|g|R||j||||j|||r|j|dSdS)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)	rlineitemrror{rrrrs	         r	_drawlinezTurtleScreenBase._drawlines B!
,
,1		!dk/***		1"t{*++++DGN8)b))))G!!(!666G!!(%!888	(Gh'''''	(	(rc:|j|dS)z]Delete graphics item from canvas.
        If item is"all" delete all graphics items.
        N)rdeleteritems  r_deletezTurtleScreenBase._delete)s	
trc8|jdS)z(Redraw graphics items on canvas
        N)rr-rs r_updatezTurtleScreenBase._update/s	
rc:|j|dS)z-Delay subsequent canvas actions for delay ms.N)rafterrrs  r_delayzTurtleScreenBase._delay4s

ercp	|j|}d}n#tj$rd}YnwxYw|S)zCCheck if the string color is a legal Tkinter color string.
        TF)r	winfo_rgbr/TclError)rr:rgboks    r_iscolorstringzTurtleScreenBase._iscolorstring8sN	'##E**CBB{			BBB		s33c|1|j||dS|jdS)zVSet canvas' backgroundcolor if color is not None,
        else return backgroundcolor.N)rr)rrHrr\)rr:s  r_bgcolorzTurtleScreenBase._bgcolorBsEGNNN&&&LLNNNNN7<<%%%rc|\}}||jz}||jz}dddd}|j|dz
||||||}	|j|	\}
}}}
|	|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)textanchorrofont)rrrcreate_textrX)rr\txtalignrrXrrrrx0y0x1y1s              r_writezTurtleScreenBase._writeKs
1
O
OT;;w""1Q33/7#FFd++BBRTzrrc j|d|zdSfd}j|d|z||dS)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>cj|jjzj|jjz}}||dSrrcanvasxrrcanvasyrrrTrrfunrs   reventfunz+TurtleScreenBase._onclick.<locals>.eventfuneT00<111$+=Aq					rr
tag_unbindtag_bindrrrnumaddrs` `   r_onclickzTurtleScreenBase._onclick\su;Gt]S%899999






GT=3#6#FFFFFrc j|d|zdSfd}j|d|z||dS)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>cj|jjzj|jjz}}||dSrrrs   rrz-TurtleScreenBase._onrelease.<locals>.eventfunwrrrrs` `   r
_onreleasezTurtleScreenBase._onreleaseks;Gt%?#%EFFFFF






GT#=#C%s
,
,
,
,
,rc j|d|zdSfd}j|d|z||dS)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	j|jjzj|jjz}}||dS#t$rYdSwxYwr)rrrrrrrrrs   rrz*TurtleScreenBase._ondrag.<locals>.eventfuns{ GOOEG44T[@ GOOEG444T[@AC1IIIII DDsAA  
A.-A.rrs` `   r_ondragzTurtleScreenBase._ondrag~sw;Gt%83%>?????






GT#6#<hLLLLLrcjd|zdSfd}jd|z||dS)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.
        Nrcj|jjzj|jjz}}||dSrrrs   rrz1TurtleScreenBase._onscreenclick.<locals>.eventfunrrrrdrB)rrrrrs``   r_onscreenclickzTurtleScreenBase._onscreenclicksm;GNN=3./////






GLL,h<<<<<rc |jd|zddSfd}|jd|z|dS)z`Bind fun to key-release event of key.
        Canvas must have focus. See method listen
        Nz<KeyRelease-%s>cdSrrrTrs rrz0TurtleScreenBase._onkeyrelease.<locals>.eventfunrrrrrrs `  r
_onkeyreleasezTurtleScreenBase._onkeyreleasesg;GNN,s2D99999




GLL*S0(;;;;;rc?||jdddS|jd|zddSfd}||jd|dS|jd|z|dS)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>cdSrrrs rrz.TurtleScreenBase._onkeypress.<locals>.eventfunrrrrs `  r_onkeypresszTurtleScreenBase._onkeypresss
;{|T222224d;;;;;




{\844444_s2H=====rc8|jdS)z=Set focus on canvas (in order to collect key-events)
        N)rrfrs r_listenzTurtleScreenBase._listens	
rc|dkr|j|dS|j||dS)z?Install a timer, which calls fun after t milliseconds.
        rN)r
after_idlerrrts   r_ontimerzTurtleScreenBase._ontimersE
66Gs#####GMM!S!!!!!rc<|jdd|S)z0Create and return image item on canvas.
        rimage)rcreate_image)rrs  r_createimagezTurtleScreenBase._createimages!w##Aq#666rc|\}}|j|||jz||jzf|j||dS)zZConfigure image item as to draw image object
        at position (x,y) on canvas)
        rN)rrrr
itemconfig)rrr\rrrs      r
_drawimagezTurtleScreenBase._drawimagesX1ta$+orDK/?@AAA4u-----rcr|j|||j|dS)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---$rc6|j|S)zQReturn 'line' or 'polygon' or 'image' depending on
        type of item.
        )rrrs  r_typezTurtleScreenBase._typesw||D!!!rc|j|fdtdtdD}|S)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)]
        >>> c8g|]}||dzfS)rr).0irs  r
<listcomp>z/TurtleScreenBase._pointlist.<locals>.<listcomp>s,
>
>
>Ar!ur!A#wh
>
>
>rrr)rrrangelen)rrplrs   @r
_pointlistzTurtleScreenBase._pointlistsHW^^D
!
!
>
>
>
>q#b''1)=)=
>
>
>
rcD|j||||fdS)Nr)rrH)rsrx1sry1srx2sry2s     r_setscrollregionz!TurtleScreenBase._setscrollregions'T4t$<=====rcP|j}|D]}t|j|}g}|rI|dd\}}|||z|||z|dd}|I|jj|g|RdS)Nr)rfind_allrrr)	rxscalefactoryscalefactorrrcoordinatesnewcoordlistrrs	         r_rescalezTurtleScreenBase._rescales  ""	0	0Dtw~~d3344KL
."2A21##A$4555##A$4555)!""o	
.

DGN4/,/////	0	0rct|jts|j|jfS||cxur|cxurnn|jj|jjfS|||_|||_|j|||dS)zaResize the canvas the turtles are drawing on. Does
        not alter the drawing window.
        N)rrrrrrarLs    r_resizezTurtleScreenBase._resizes
$'>22	3>4?22
0000b000000007$dg&888 &DN!(DO

iR00000rc|j}|dkr
|jd}|j}|dkr
|jd}||fS)z; Return the width and height of the turtle window.
        rr{r)rrNrO)rr{rs   r_window_sizezTurtleScreenBase._window_sizes^##%%A::GG$E%%''Q;;WX&Ff}rcB|jjdS)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 	

rc:tj|||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%eVDGDDDDrc@tj||||||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.numinput=s.$$UF.4v,0G555	5r)NNNFrrNrg)%rrrrrrr1rrrrrrrrrrrrrrrrrrrrrrrrrr r"rr)rrrrrrs]<<<(((OOO
3705((((2888-1-2((((.
&&&&"
G
G
G
G,,,,&MMMM*====$	<	<	<>>>>$
"""777
...   """


>>>
0
0
0
1
1
1
1			



E
E
E555555rrceZdZdZdS)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.
    NrrrrrrrrrYs
	DrceZdZdZdS)TurtleGraphicsErrorzSome TurtleGraphics Error
    Nr3rrrr5r5bsrr5c"eZdZdZddZddZdS)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.
    Nc||_|dkr%t|trt|}n|dkrft|trP|dr)t|rt	|}n|dkrg}ntd|z||_dS)Npolygonr.gifcompoundzThere is no shape type %s)rrrrrlowerendswithrr	rr5_data)rtype_datas   rr1zShape.__init__ns
I$%%
#T{{
g

$$$
5::<<((005VD\\5'..t44D
j
 
 DD%&AE&IJJJ


rc|jdkrtd|jz||}|j|||gdS)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()
        r:z Cannot add component to %s ShapeN)rr5r=r)rpolyrors    raddcomponentzShape.addcomponent~sa :##%&HBF*'MNN
N?G
4w/00000rr)rrrrr1rBrrrrrgsF 111111rrc:eZdZdZd
dZddZdZdZdZd	Z	dS)Tbufferz5Ring buffer used as undobuffer for RawTurtle objects.rcH||_dgg|z|_d|_d|_dS)NrF)bufsizebufferptrcumulate)rrFs  rr1zTbuffer.__init__s+vh(


rNc|#t|jD]
}dg|j|<n||_dgg|z|_d|_dS)Nr)rrFrGrH)rrFrs   rraz
Tbuffer.resetsX?4<((
(
("&A
(#DL 6(W,DKrc|jdkrV|js(|jdz|jz|_||j|j<dS|j|j|dSdSr)rFrIrHrGrrs  rpushzTbuffer.pushsl<!=
3 HqLDL8(,DH%%%DH%,,T22222rc|jdkr?|j|j}|dSdg|j|j<|jdz
|jz|_|SdSr)rFrGrHrs  rpopzTbuffer.popsX<!;tx(D|t)-DH% HqLDL8
rcH|j|jdgz
Sr)rFrGcountrs rnr_of_itemszTbuffer.nr_of_itemss!|dk//7777rcZt|jdzt|jzS)N )rrGrHrs rrzTbuffer.__repr__s$4;#%DH

55r)rr)
rrrrr1rarLrNrQrrrrrDrDs~??
33388866666rrDceZdZdZdZedededfdZdZd#d	Zd
Z	d#dZ
dZd
Zd#dZ
dZdZdZd$dZd#dZdZdZdZdZdZdZd%dZdZd#dZd$dZd&d Zd#d!Zd'd"ZeZ eZ!eZ"e
Z#eZ$dS)(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.
    Trrrczt||tddtddtddtddtddtddtd|d	|_d
di|_||_||_td|_	g|_
|tj
d
krH|}|ddddd|ddddddSdS)Nr8)rrrrr))r))rr))	)))r_r))rc)rcrg)r]rerr_)re)rg)rbrc)rdrf)r^r)rjrd)r`rb)r^r`)rir^)rr)rr\)rX)Q#@Q@)Gz. @Q@)rnrm)rlrkrY)Qrk)Qrm)Gz. rn)Q#rlrV)rrro)rqrp)rprq)rorr)gg$)rlrr)rnrq)rmrp)rkro))rrW)rr)rWr)rWrW))rGz)rg'@)rWrs)rr)rerarh)rdrar)arrowrr5squaretrianglerrnopicrrdarwinwm
attributesrz-topmost10)rr1rr_shapes_bgpics_mode_delayvaluer
_colormode_keysr6sysplatformr2call)rrrrr
rootwindows      rr1zTurtleScreen.__init__sR!!$+++#9.GHH"9/&''
#9/HII#9/)**"9/+,,"9.KLL"7D,<,<,>,>??%* "~
 {+


<8##**,,JOOD,ZEEEOOD,ZEEEEE
$#rctd|_td|_|d|d|_d|_d|_d|_g|_	|
dd	D]}|d
||d
|j
d
d
D].}|d
||d
|/d
t_d
S)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.
        rrallrrxrrr)rrN)rrrrr_bgpic
_bgpicname_tracing_updatecounter_turtlesrrSr rrr_pen)rbtnrs   rr6zTurtleScreen.clears ={+U''++!

W	$	$CLLs####:aaa=	'	'CJJtS!!!OOD#&&&&rNc:||jS|}|dvrtd|z||_|dvrH||jdz|jdz|jdz|jdzdx|_|_|dS)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)	rr;r5rrrrrrarrs  rrzTurtleScreen.modes,<:zz||444%&BT&IJJJ
'''!!4>/1"4t6F6I'+~q'8$/1:L
N
N
N(++DK$+

rc\|dkr|dt||z
}t||z
}|\}}||dz
|dz
|j|j}
}	|j|z|_|j|z|_||jz}||jz}|j|z}
|j|z}||||
||	|j|	z|j|
z|
dS)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)rrr"r&rrrrrrr-)rllxllyurxuryxspanyspanwxwy	oldxscale	oldyscalerrrrs               rr(z TurtleScreen.setworldcoordinates-s$,99;;'!!IIgcCi  cCi  ""$$B2r"u%%%#{DK9	nu,o-T[ tdk!~$%dD$555

dk)+T[-BCCC




rc|Z|dr$td||}n4t	dt|trtd|}||j|<dS)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)))

        Nr9rz;Bad arguments for register_shape.
Use  help(register_shape)r8)r;r<rrr5rrr~)rnamerls   rr$zTurtleScreen.register_shapeTs.=zz||$$V,,
Jgt{{4'8'899)+HJJJ
u
%
%	,)U++E"Trc:t|dkr|d}t|tr<||s|dkr|St	dt|z	|\}}}n4#t
tf$r t	dt|zwxYw|jdkrd|||fD\}}}d|cxkrdkr"nnd|cxkrdkrnnd|cxkrdks!nt	d	t|zd
|||fzS)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: %src2g|]}td|zSgo@roundrrs  rr
z*TurtleScreen._colorstr.<locals>.<listcomp>"999!uU1W~~999rbad color sequence: %s
#%02x%02x%02x)rrrrr5	TypeErrorrr)rr:rgbs     r	_colorstrzTurtleScreen._colorstrws\u::??!HEeS!!	O""5))
OUb[[)*@3u::*MNNN	NGAq!!:&	N	N	N%&?#e**&LMMM	N?c!!991ay999GAq!a3Q!]]]]s]]]]]a3%&>U&KLLL!Q**s.A551B&c&dsStdkrfddD}n<tdkrfdddD}ntdztfd	|DS)
Nrr^cFg|]}t||dzdS)rrZr)rrcstrs  rr
z'TurtleScreen._color.<locals>.<listcomp>s/:::1#d1QqS5k2&&:::r)rrrdricBg|]}dt|dzS)rZr)rrrs  rr
z'TurtleScreen._color.<locals>.<listcomp>s,888!"Sa"%%%888rrzbad colorstring: %sc32K|]}|jzdzVdS)rN)r)rrrs  r	<genexpr>z&TurtleScreen._color.<locals>.<genexpr>s/99Q(,999999r)rrr5r)rrrs`` r_colorzTurtleScreen._colorss##	Kt99>>::::	:::BB
YY!^^8888tABBx888BB%&;d&BCCC9999b999999rc||jS|dkrt||_dS|dkrt||_dSdS)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)rrr)rcmodes  rrzTurtleScreen.colormodesL=?"C<<#EllDOOO
c\\!%jjDOOO\rcv|jD]0}||j|1dS)zReset all Turtles on the Screen to their initial state.

        No argument.

        Example (for a TurtleScreen instance named screen):
        >>> screen.reset()
        N)r_setmoderra)rrs  rrazTurtleScreen.resetsBm		FOODJ'''LLNNNN		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}rc|r||}nd}||}|||}|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)rrrrrZr:s   rrzTurtleScreen.bgcolorsQ	NN4((EEE

e$$KK&&Erc||jSt||_d|_|t||_|jr|dSdS)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)rrrrr-)rnrs   rr+zTurtleScreen.tracers_&
9= A
"5zzD=	KKMMMMM		rc@||jSt||_dS)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)rrrs  rrzTurtleScreen.delays&=##u::rctjsdt_t|jdkr'|xjdz
c_|xj|jzc_dSdS)zIncrement update counter.TrrN)r	_RUNNINGrrrrs r
_incrementudczTurtleScreen._incrementudc	s`$	$(L!=11$4=0rc|j}d|_|D]*}||+||_|dS)z'Perform a TurtleScreen update.
        TN)rr,_update_data_drawturtler)rtracingrs   rr-zTurtleScreen.updates`-
		A
NN
MMOOOO
rc6|dS)z Return the width of the turtle window.

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

        Example (for a TurtleScreen instance named screen):
        >>> screen.window_height()
        480
        rrrs rr.zTurtleScreen.window_height&rrc|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/swrcNt|jS)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']
        )sortedr~rrs rrzTurtleScreen.getshapes;s dl''))***rrc4||||dS)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.onclickFs"	
Cc*****rc|$||jvr|j|n#||jvr|j||||dS)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.onkeyWsl.;dj  
!!#&&&


"
"Jc"""3$$$$$rc|$||jvr|j|n%|#||jvr|j||||dS)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.onkeypressusp2;dj  
!!#&&&
_DJ!6!6Jc"""c"""""rc.|dS)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	
rrc2|||dS)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|||_dS)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)rrrrr)rpicnames  rrzTurtleScreen.bgpics^"??"$,&&$(KK$8$8DL!t{DL$9:::!rc0||||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 ;-)
        )r rLs    rr&zTurtleScreen.screensizes"||Iz2666rrNNr1rrg)%rrrrrrr1r6rr(r$rrrrar,rr+rrr-r/r.rrrSrr rr#rr&r"r%rrr!rrrr	r	sH $V,DM&F&F&F&FP<    D%%%N!#!#!#!#F+++6	:	:	:))))*


.8
&
&
&
&111			&&&&&&


	+	+	+++++"%%%<####@



*""""07777&MKKHLLLrr	cHeZdZdZeddeddedddZdZdZdZefdZ	d	Z
d&dZdZd'dZ
dZdZdZdZdZdZdZdZdZdZdZd&dZdZdZdZd&dZd&dZd Zd!Z d(d"Z!d)d#Z"d(d$Z#d&d%Z$eZ%eZ&eZ'eZ(eZ)eZ*eZ+eZ,e Z-d
S)*
TNavigatorzRNavigation part of the RawTurtle.
    Implements methods for turtle movement.
    r)rrrrrrc|j|_|j|_||_d|_|d|_||t	|dSr)
DEFAULT_ANGLEOFFSET_angleOffsetDEFAULT_ANGLEORIENT_angleOrientr
undobufferr;rrrars  rr1zTNavigator.__init__sf 4 4



drchtdd|_tj|j|_dS)zXreset turtle to its initial values

        Will be overwritten by parent class
        rN)r	_positionrSTART_ORIENTATIONr_orientrs rrazTNavigator.resets(
sC"4TZ@rNc||jS|dvrdS||_|dvrd|_d|_dS|jdz|_d|_dS)z:Set turtle-mode to 'standard', 'world' or 'logo'.
        Nr)rrrr@r)rrr_fullcirclers  rrzTNavigator._setmodesi<:444F
((( !D !D $ 0 3D "Drcd||_d|z|_|jdkr	d|_dS|dz|_dS)z+Helper function for degrees() and radians()ihrrrN)r
_degreesPerAUrrr
fullcircles  r_setDegreesPerAUzTNavigator._setDegreesPerAUsC% ^:## !D *2
Drv@c0||dS)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)))))rcD|tjdS)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.radians5s 	
dh'''''rcT|j|j|zz}||dS)z)move turtle forward by specified distanceN)rr_goto)rr<endes   r_gozTNavigator._goCs-~x 77

4rcX||jz}|j||_dS)z=Turn turtle counterclockwise by specified angle if angle > 0.N)rrrrrs  r_rotatezTNavigator._rotateHs*
##|**511rc||_dS)zmove turtle to position end.Nr)rends  rrzTNavigator._gotoMs
rc0||dS)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.forwardQs*	
rc2||dS)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.backhs$	
(rc2||dS)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.right|s&	
eVrc0||dS)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 rr~zTNavigator.ycorrrc||t|dS|t||dS)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.gotosE<
9JJuay!!!!!JJuQ{{#####rc\|dd|ddS)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rcb|t||jddS)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- 	

5DN1-../////rcb|t|jd|dS)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|}n;t|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%sz,
=1++Ca	CC
5
!
!	)CC
:
&
&	+C3'(((rc|t||}t|tr|}n;t|tr
t|}nt|tr|j}||jz
\}}tt
jt
j||ddz}||j	z}|j
|j|zz|jzS)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
        Nrr)
rrrrrrrr;atan2rrrr)rrrr\results     rrvzTNavigator.towardsEs,
=1++Ca	CC
5
!
!	)CC
:
&
&	+CT^#1t|DJq!$4$455r::UB$$$!D$5f$<<@PPPrc|j\}}ttjtj||ddz}||jz}|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.headinghsd|1t|DJq!$4$455r::UB$$$!D$5f$<<@PPPrc||z
|jz}|j}||dzz|z|dzz
}||dS)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.setheadingwsY.DLLNN*D,==tBw$tBw.Urc	<|jr'|jdgd|j_|}||j}|Mt||jz}dt
tdt|dzzd|zz}d|z|z}d	|z}d
|ztj	tj
||jzz}|dkr	|||}}}|}	|
}
|dkr|ddn|d||t|D]V}|||||d||W|||dkr||	|
|||jrd|j_dSdS)
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)rrLrIrqrrrminrrr_r_tracerrrrr)rradiusextentstepsrqfracrw2ltrdlrs            rr5zTNavigator.circles<?	,O  %)))'+DO$

>%F=v;;t//Dc#bVS0$77<===E&L5 
1W&L48DL$4$4T5G$GHHHA::rA2s"qA
\\^^
[[]]A::LLAJJqMMMRu		AJJuHHQKKKJJqMMMLLOOOObSA::LLR   

5?	-',DO$$$	-	-rcdSz/dummy method - to be overwritten by child classNr)rrs  rrqzTNavigator.speedrcdSr.r)rars   rr$zTNavigator._tracerr/rcdSr.r)rrs  rrzTNavigator._delayr/rr)rrr).rrrrrrDEFAULT_MODErrr1rarrr;r_rrrrDr0r`rQr\r}r~rJrMrjrkr<rvrKrer5rqr$rrAr4r1rcrRr]rfrgrdrrrrrswE#sOOE#sOOE#sOO''L(AAA
#
#
#
#...****0(((
222
.(**!!!!!!!$!$!$!$F000$000$))))@!Q!Q!Q!QF
Q
Q
Q8=-=-=-=-B>>>>>>>>>>>>
B	
BH	B	
BH
FKDDDrrceZdZdZedfdZededfdZddZdd	Zd
Z	dZ
dZdd
ZdZ
dZdZdZdZdZddZddZddZdZdZeZe	Ze	Ze
Ze
ZeZeZdS)TPenzFDrawing part of the RawTurtle.
    Implements drawing properties.
    rbcV||_d|_t|dSr)_resizemoderr5_reset)rrbs  rr1z
TPen.__init__s)%DrrXrBcd|_d|_||_||_d|_d|_d|_d|_d|_d|_	d|_
dS)NrTr)rrr)rrrr)_pensize_shown	_pencolor
_fillcolor_drawing_speed_stretchfactor_shearfactor_tilt_shapetrafo
_outlinewidth)rrXrBs   rr8zTPen._resetsY
!#
&
+rNcx||jS|}|dvr||dSdS)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)r7r;rW)rrmodes  rrbzTPen.resizemodesM,=##

000HHH&&&&&10rcD||jS||dS)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)r:rW)rr{s  rrZzTPen.pensizes+$== rcD|jsdS|ddS)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.penup0s-}	FrcD|jrdS|ddS)zPull the pen down -- drawing when moving.

        Aliases: pendown | pd | down

        No argument.

        Example (for a Turtle instance named turtle):
        >>> turtle.pendown()
        NTrLrMrs rrYzTPen.pendown>s-=	F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.isdownLs}rcdddddd}||jS||vr	||}n/d|cxkrd	kr nntt|}nd}||
dS)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)
        rrrjrr)fastestfastnormalslowslowestNrg%@)rq)r?rrrW)rrqspeedss   rrqz
TPen.speed[s6b1Q!MM=;F??5MEE
5



4




e%%EEEurc`|ryt|}|dkr|dx}}n|dkr|\}}n
|dkr|x}}||}||}|||dS||j||jfS)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)rrrWrr<r=)rrZr*pcolorfcolors     rr:z
TPen.colors@	MD		AAvv"&q')a!%a"&&^^F++F^^F++FHHfH77777;;t~..DO0L0LLLrc|r:||}||jkrdS||dS||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)rr<rWrrs   rrXz
TPen.pencolors]:	/NN4((E&&HHeH$$$$$;;t~...rc|r:||}||jkrdS||dS||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.fillcolors]8	0NN4((E''HHuH%%%%%;;t///rc2|ddS)zMakes the turtle visible.

        Aliases: showturtle | st

        No argument.

        Example (for a Turtle instance named turtle):
        >>> turtle.hideturtle()
        >>> turtle.showturtle()
        TshownNrWrs rrpzTPen.showturtles	
trc2|ddS)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
        )r;rs rrPzTPen.isvisible	s{rc|j|j|j|j|j|j|j|j|j|j	|j
d}|s|s|St|tr|}ni}|
|i}|D]
}||||<|jr|jd|fd}d|vr|j|dkrd}d|vrMt|dt r||df|d<|j|dkrd}d|vr|j|dkrd}|r|d|vr
|d|_d|vr
|d|_d|vr
|d|_d|vrGt|dt r||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|vrg|j\}	}
|j}t+j|j
t+j|j
}
}|	|
z|
||
z|zz|	|z|
|
||zz
zf|_|dS)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
stretchfactorrorrtrWFrYTrXrZrBrqrbrcrorr^rtN)r;r>r<r=r:r?r7r@rArDrBrdictr-rrLrr_newLinerrrrrrCr)rrWpendict_pdp_p_bufrnewLinesfscxscyshfsacas              rrWzTPen.pen!	s_^#'+"&-"&."&/"&-"&+"&"2"&"5"&"3"&"4"&*	w	Jc4  	AAA		#	#Cc(F3KK?	2O  %111>>}),,??!J-//
A $*
/? @ @*
~:..>>}),,	MMOOO>>iLDM??z]DN>>iLDM!!K.%00
C!%;0A!B!B+nDOa<<G*DK1 Da?#B"sEl++
"X"$DA !- 0D>>!"9Da<<G*DKQ;;6DJa6Q;;-12D2D*HC#CXdj))48DJ+?+?B!$Rc"frk):!$Rb3r6k): <DrTcdSr.rrusePoss  rrez
TPen._newLine	r/rFcdSr.r)rrPforceds   rrzTPen._update	r/rcdSr.rrYs  rrzTPen._color	r/rcdSr.rrYs  rrzTPen._colorstr	r/rrT)TF)rrrrrr1r8rbrZr[rYrOrqr:rXrBrprLrPrWrerrrr{rzr^rVr>rrrNrrrr5r5s#'|"4
#:.#K0''''8    .   


$$$$L,M,M,M\#/#/#/J"0"0"0H 


{{{{~>>>>>>>>>>>>>>
E	B	B	BD	B	BBBrr5ceZdZdZdZdZdS)_TurtleImagez6Helper class: Datatype to store Turtle attributes
    cL||_d|_||dSr)rr	_setshape)rr
shapeIndexs   rr1z_TurtleImage.__init__	s(
z"""""rc|j||_|jdcxkrj|jkrnndS|jdcxkrj|jkrnndS|jdvr|jn*|jdkr|jD]}|j|j|_|jdkr|_dS|jdkr,jdj|_dS|jdkr%fdj|jD|_dSdS)Nr8r)rr8r:rc8g|]}Srrrrrs  rr
z*_TurtleImage._setshape.<locals>.<listcomp>	s7LLL4&,,..LLLr)	rr}rr~r_itemrrr=)rr}rrs   @rr|z_TurtleImage._setshape	s$:FFFFfnZ&@&FFFFFFF:DDDDFN:$>$DDDDDDF:---NN4:&&&&
Z:
%
%

%
%t$$$$^J/5
:""++--DJJJ
Z7
"
",,V^G-D-JKKDJJJ
Z:
%
%LLLL*0.*D*JLLLDJJJ&
%rN)rrrrr1r|rrrrzrz	sA###
LLLLLrrzceZdZdZgZdedededfdZdZdZd	Z	d
Z
dZdZd
Z
d<dZdZdZdZdZd=dZd>dZd=dZdZd=dZdZd?dZdZdZd@dZdZdZd Zd!Z d=d"Z!d#Z"d$Z#d%Z$dAd'Z%d(Z&d)Z'd*Z(d=d+Z)d,Z*dBd/Z+d0Z,d1Z-d2Z.d3Z/d4Z0e0Z1d=d5Z2dCd7Z3dCd8Z4dCd9Z5d:Z6d;Z7eZ8dS)DrzvAnimation part of the RawTurtle.
    Puts RawTurtle upon a TurtleScreen and provides tools for
    its animation.
    Nrlrrc:t|tr||_nt|tr5|tjvrtj|||_nt|ttfr\tjD]}|j	|kr	||_n9t||_tj|jntd|z|j}t||
t||j|||_t%|||_d|_d|_dx|_|_||_d|_||_|jg|_|jg|_g|_||_tA||_!|"dS)Nzbad canvas argument %sF)#r_Screenrr	rscreensrrr4rr5rr1rr5rrdrawingLineItemrzr_poly
_creatingPoly	_fillitem	_fillpathr;_hidden_from_screencurrentLineItemrcurrentLiner
stampItems_undobuffersizerDrr)rcanvasrlrrrs      rr1zRawTurtle.__init__	sfg&&	I DKK

-
-
	IY...!((000 DKK
 8
9
9		I#+
6
69&&"(DKE'+622!((555%&>&GHHHD&++--000

dt$$$%1133"6511
"*..#( %1133 N+*+
-!.11rct|t||||dS)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)rrar5r8_clearrrrs rrazRawTurtle.reset
sZ&	D


rcP||dkr	d|_dSt||_dS)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)rrD)rsizes  rrizRawTurtle.setundobuffer
s-<4199"DOOO%dmmDOOOrcF|jdS|jS)zReturn count of entries in the undobuffer.

        No argument.

        Example (for a Turtle instance named turtle):
        >>> while undobufferentries():
        ...     undo()
        Nr)rrQrs rryzRawTurtle.undobufferentries,
s%?"1**,,,rcvdx|_|_|jD]}|j||j|_g|_|jr|j	|j
|jg|_|||j
dS)zDelete all of pen's drawingsN)rrrrrrrrr>rrr8rirrs  rrzRawTurtle._clear9
s*..J	&	&DK%%%%#{6688=	4##DN333*+
4/00000rcV||dS)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.clearG
s"	



rc|j|jjdkrdSt|jdkr3|j|j|j|j|jdSdSr)	rrrrrrrr<r:rs rrzRawTurtle._update_dataV
s!!###;%**Ft  ""K!!$"68H"&.$-
A
A
A
A
A#"rc|j}|jdkrdS|jdkrX|||||jdS||jdkrA|D]}||dSdS)z&Perform a Turtle-data update.
        rNr)	rrrrrrrrr,)rrrs   rrzRawTurtle._update^
s?aF
_
!
!NNMM&,-----$))))$$AMMOOOO     *)rc8|j||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._tracerp
s&{!!$...rc6|j|Sr)rrrYs  rrzRawTurtle._color
s{!!$'''rc6|j|Sr)rrrYs  rrzRawTurtle._colorstr
s{$$T***rct|tr|S	|\}}}n4#ttf$r t	dt|zwxYw|jjdkrd|||fD\}}}d|cxkrdkr"nnd|cxkrdkrnnd|cxkrdks!nt	dt|zd|||fzS)z,Convert colortriples to hexstrings.
        rrc2g|]}td|zSrrrs  rr
z!RawTurtle._cc.<locals>.<listcomp>
rrrrrr)rrrrr5rr)rrZrrrs     r_ccz
RawTurtle._cc
s
dC  	K	MGAq!!:&	M	M	M%&?#d))&KLLL	M;!S((991ay999GAq!a3Q!]]]]s]]]]]a3%&>T&JKKK!Q**s	 1Ac|j||j|j}d|_d|_t	|}|_||_|_t|jj|_j|j	|jjj
}|dkr|j_nn|dkr0
j	dj|j_n8|dkr2fdj	|jjjD|j_|_||S)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()
        Nr8rrr:c8g|]}Srrrs  rr
z#RawTurtle.clone.<locals>.<listcomp>
s7LLLtf0022LLLr)rrer>rrrzr}rrr~rrrrr=rrr)rrqttypers    @rr9zRawTurtle.clone
sX

dm$$$TNN(>??q!!!t{56<I#//11AHNN
g

#001H1NOOAHNN
j
 
 LLLL$nT[-CDJLLLAHN"..00			rc||jjS||jvrt	d|z|j||dS)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}rrr5r|r)rrs  rrlzRawTurtle.shape
sh(<;))t{,,....%&BT&IJJJd###rc||cxur|cxurnn|j\}}|||jfS|dks|dkrtd||||f}n||f}n||jd|f}n|j}||j}|d||dS)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 zerorG)rbrcr)r@rDr5rW)rstretch_widstretch_lenrrcs     rrmzRawTurtle.shapesize
s*+888888888888'+':$KT-???!{a//%&PQQQ"" +[ 8

 +[ 8



$ /2K?MM /M?(GF,g		?	?	?	?	?rcF||jS|d|dS)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
        NrG)rbro)rArW)rshears  rrozRawTurtle.shearfactors.&=$$F66666rc^tjddd||dS)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_deprecatedrurs  rrhzRawTurtle.settiltanglesD*	>X$+	-	-	-	-	
urc|4tj|j|jz}||jz|jzS||jz|jz}tj|tjz}|d|dS)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)
        NrG)rbrt)	rr;rBrrrr_rrW)rrrts   rruzRawTurtle.tiltangle7s>=L,,,t/@@D4--1AAA6D..1BBD<%%0DHHTH22222rcZ|||zdS)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)rurs  rrtzRawTurtle.tilt^s+"	
ut~~///00000rc||cxur|cxur|cxur
nn|jS|j\}}}}||}||}||}||}||z||zz
dkrtd||||f|_tj||tjz}	tj|	tj|	}}
||z|
|zz
||z|
|zz
|
|z||zz|
|z||zzf\}}
}}||f|_|
|z|_|	|_	|
ddS)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 singularrGrH)rCr5rrrrrr@rArBrW)rt11t12t21t22m11m12m21m22alfarorpa11a12a21a22s                rrnzRawTurtle.shapetransformqsj(#++++++++++++++++##!-S#s?#C?#C?#C?#C9sSy A%%%&XYYYc3/z3$$$tx/$$B fr#vor#v3 fr#vor#v3@S#s!3hG
F#####rc|j|j\|j\tjzjz}dt
|z|z\fd|DS)zlComputes transformed polygon shapes from a shape
        according to current position and heading.
        rcpg|]2\}}|z|zzjzz|z|zzjzzf3Sr)rr)rrre0e1p0p1rs   rr
z(RawTurtle._polytrafo.<locals>.<listcomp>sjOOO?E1RT"Q$Y
--rB3q5A:v}2L/LMOOOr)rrrrrrr)rrAerrrrrs   @@@@@r
_polytrafozRawTurtle._polytrafosBB"b6=(6=899A,!#BOOOOOOOOIMOOO	Orc|jj|jj}|jdkr$||j|jdkSdS)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))

        r8r:N)rr~rr}r
_getshapepolyr=)rrls  rrHzRawTurtle.get_shapepolysL#DK$:;;)##%%ek5;*3LMMM$#rFc|jdks|r
|j\n<|jdkr$td|jdz}|dd|f\n
|jdkr|St	fd|DS)z`Calculate transformed shape polygon according to resizemode
        and shapetransform.
        rGrFrg@rrc3JK|]\}}|z|zz|z|zzfVdSrr)rrrrrrrs   rrz*RawTurtle._getshapepoly.<locals>.<genexpr>sDJJAc!ec!emSUSU]3JJJJJJr)r7rCmaxr:r)rr8r:r*rrrrs    @@@@rrzRawTurtle._getshapepolysv%%%!%!1Cc33


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


+
+NJJJJJJJ'JJJJJJrc	>|j}|j|jj}|j}|jj}|jr^|jdkrR|jdkrFd|_	|j
}|dkr{|jdkrd}n|jdkr|j}n|j
}|||}|j|j}}||||||ddS|d	kr|||j|dS|d
krt+||D]z\}	\}
}}|||
d}
||	|
|||||j
dydSdS|j	rdS|dkr||dd
d
nV|d	kr-|||j|jdj
n#|d
kr|D]}	||	dd
d
d|_	dS)zpManages the correct rendering of the turtle with respect to
        its shape, resizemode, stretch and tilt etc.rFr8rrrFTrorr{rrr:Nrtrtrtrr)rr~rr}rrr;rrrr=r7r:rDrrr=r<rrrzipr)rrrlrtitemtshaperfcocrrAs           rrzRawTurtle._drawturtlest{56!;	,60A55&/A:M:M',D$[F	!!#z11q11%//T]+a(:(:6(B(BCC$.B  B<=4!IIIII'!!!!%@@@@@*$$,/v,>,>__(D.4R??4+=+=dD+I+IJJD$$T4dhhrll-1XXb\\ASY]%____%$__
'
	!!  (@"bIIII'!!!!%*0.*A*GIIII*$$!MMD$$T+CRLLLL'+D$$$rc	|j}|j|jj}|j}|j}|dkr|}|jdkrd}n|jdkr|j}n|j	}|
||}|j|j
}}||||||dn|dkr2|d}|||j|n|d	krg}|D]+}	|}
||
,t'|}t)||D]x\}
\}}}|
||d}||
||||||j	dy|j||jd
|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)
        r8rrrFTrrrr:rs)rr~rr}rr=rr7r:rDrrr=r<rrrrrrrrrrrL)rrrlrrstitemrrrelementrrAs            rrszRawTurtle.stamps*t{56I''))F:--1qq!V++QQ'!OOD$6$6v$>$>??E_dnBVUR89t

E
E
E
E
g

((,,Ffdnf====
j
 
 F!
$
$))++

d####6]]F(+FF(;(;
[
[$ntRt'9'9$'E'EFF  t$((2,,)-"T=OUY![[[[v&&&gv.///
rc||jvrit|tr |D]}|j|n|j||j|d|f}|j}||jvrdS|j|}|j|||j	kr|j	dz
|j
z|_	|j|j	dz|j
zdgdS)z9does the work for clearstamp() and clearstamps()
        rsNr)rrrrrrrrGindexrHrFinsert)rstampidsubitemrbufrs      r_clearstampzRawTurtle._clearstampsdo%%'5))
-&11GK''00001##G,,,O""7+++!osz!!F
  &&
$CGw{ck1CG
3719ck1D6:::::rcX|||dS)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.clearstamp.s)	
!!!rc||jdd}n%|dkr|jd|}n|j|d}|D]}|||dS)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.clearstamps=s}$
9qqq)HH
!VVrr*HHqrr*H	#	#DT""""rc
|j|j|jt|jt
f}|j}d|j|||j|j	dd|
|j|jddff}|jr|j
||j}|jr	|jdkr||z
}|d|jzdz|d|jzdzz}dt%|dzdd|jzz|jzzz}|d	|zz}	t'd|D]d}
|
dkrd
}nd}||	|
zz|_|jr/||j||jf|j|j||e|jr#||jdd
|j|jr|j	|t|jt
r|j|||_|jr|j|t5|j	dkr||dS)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皙?rTFrtrtrror{*)r>r<r:rrrrrrrrrrrLr?rrrrrrrrrrrrre)rrgo_modesr
undo_entrystartdiffdiffsqnhopsdeltarrs            rrzRawTurtle._gotoYs]^]557DNC+&qqq)''(<==jm%
?	-O  ,,,;	M6?a//ID1gfm+a/476=3H12LLFc63;C,<)=dk)IJKKKECI&E1e__



66CCC!&!2=I$$T%9&+T^%<%)^T]CIII}
M  !57G46dm!MMM=	)##C(((dnd++	'N!!#&&&	#Jc"""t  2%%MMOOOrc|\}}}}|\}}}}	|\}
}}|jt|j|z
dkrtd|
|_||_|ddgkrd}
n|}
|
||
|fd|jD}|D]1}||j	|2|}|j
rjdkr||z
}|djzd	z|dj
zd	zz}dt|dzd
d|j
zz|j
zzz}|d|zz}td|D]U}|dkrd
}nd}|||zz|_|r%|j||jf||||V|r|jdd|||_|jrJt'|jdkr|j|jgkrd|_d|_|	rB|jgkrd|_tdn |j|j|dS)z)Reverse a _goto. Used for undo()
        rz$undogoto: HALLO-DA-STIMMT-WAS-NICHT!rtrrcNg|]!}|vr|dk|"S)r)r)rrrrs  rr
z'RawTurtle._undogoto.<locals>.<listcomp>sBDDD!aunn(.Q6(A(A(A(A(ArrrrrrrTFrNzUnwahrscheinlich in _undogoto!)rrrrrrrrrrr?rrrrrrrrrrrNr)rentryoldnewrcoodatadrawingpcpsrCcLIcLrusepctodeleterrrrrrrrrrs                       @@r	_undogotozRawTurtle._undogotos',#S(G#+ R$RUt~#$$s**9:::"
&&!!!EEEbuB777DDDDDtzDDD	!	!ANN1Ja    ;	B6?a//9D1gfm+a/476=3H12LLFc63;C,<)=dk)IJKKKECI&E1e__



66CCC!$uqy2$$T%9&+T^%<%'S222
B  !57G46b!BBB
	"4:""
   zR%*"!
	%~##!%67777+""$$$rc|jr"|jd||jf||jz}|j|}|jj}|dkr|jdkryd|jz}dtt||zz}d|z|z}t|D]5}|j||_|6||_|dS)z&Turns pen clockwise by angle.
        rotrrg@rN)rrLrrrrrr?rrrr)rr	neworientranglevelr'rrs        rrzRawTurtle._rotates?	EO  %0B!CDDD
##L''..	+&a<<DK!OOT[(HCJJx/000EIeOE5\\

#|22599 rTct|jdkro|j|j|j|j|j|j|_|j	|jn!|j|jdg|_|r|j
g|_dSdS)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)rrrrrr<r:rrrrrrs  rrezRawTurtle._newLines
t  1$$K!!$"68H&*ndm
E
E
E#';#:#:#<#<D Jd23333K!!$"6D!AAA	0 $/D	0	0rc6t|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$.$///rcb|s=|j|_|j|j|jg|_||j	r!|j	
d|jf|dS)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)rCrrrrrrrrerrLrrs rr2zRawTurtle.begin_fills||~~	.![4466DNJdn---.)

?	@O  +t~!>???rcN|rt|jdkrT|j|j|j|j|jr!|jd|jfdx|_|_|	dSdS)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)
rCrrrrrr=rrLrrs rr?zRawTurtle.end_fill
s<<>>	4>""Q&&%%dndn+/?&<<<?EO(((DN)CDDD.22DNT^LLNNNNN		rcZ|svt|ttfr3||}|jt|jdz}n[|j}|s|jt|jdz}n4||jt|jdz}||}t|jdrb|j	|j
||}|j||j
r|j
d|fdSdS|}|j
r'|j
dgd|j
_	|dkr|||||||d||n#||wxYw|j
rd	|j
_dSdS)
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)
        riN_dotr=r!TrFrF)rrrrr:rr<hasattrrrrrrrrLrWrIrbrNrYrZrXrD)rrr:rrWs     rr=z
RawTurtle.dot(
s		*$e--
At,,}s4=!'<'<<A=3t}a+@+@@D|}s4=!'<'<<NN5))E4;''	1;##DND%@@DJd###
4$$eT]33333
4
4((**C
0$$eW---+/(
??$$..GGIIIT"""

e$$$Q








1+0(((
1
1s
'A?G<<Hc|j|j||||j\}}||j||jr|jd|f|S)z)Performs the writing for write()
        wri)	rrrr<rrrrrL)rrrrrrs      rrzRawTurtle._writeX
s|K&&t~sE4:>.JJ	c
$?	0O  %///
rrQArialrbrScV|jr'|jdgd|j_|t	|||}|r-|\}}||||jrd|j_dSdS)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)
        r!TFN)rrLrIrrr;r\rf)rargmoverrrrrs        rr|zRawTurtle.writec
s&?	,O  %)))'+DO$kk#c((EKKMM488	 88::DAqKKQ?	-',DO$$$	-	-rc.|jg|_d|_dS)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
sn%
!rcd|_dS)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#rc<|jt|jSdS)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	rc6|j|S)zDSet delay value which determines speed of turtle animation.
        )rrrs  rrzRawTurtle._delay
s{  '''rrc||j|jj||||dS)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)rrrrrrs    rrSzRawTurtle.onclick
s6$	
T[.S#>>>rc||j|jj||||dS)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)rrrrrrs    rrUzRawTurtle.onrelease
s6,	
t{0#sC@@@rcT|j|jj|||dS)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)rrrrrs    rrTzRawTurtle.ondrags+$	
DK-sC=====rcH|jdS|dkrA|\}}|||z|jz|j}dS|dkr|d}||dS|dkr||dS|dvr>|d}|j||j	|dS|dkr(|d}|j
|dd	d	
dS|dkrW|d}dx|_|_||jvr6|j||j	|dSdS|dkr<t||d|jdSdS)
z2Does the main part of the work for undo()
        Nrrsrr)rr=rrrrrrW)rrrrNr7rrrrrrrrr5rW)ractionr?rdegPAUdummyrrs        r_undozRawTurtle._undos?"FU?? ME6LL%t'99:::O''))EEE
w

!WFOOF#####
t^^NN4     
~
%
%7DK%%%Jd#####
x

7DK!!$(>')2
"
7
7
7
7
7
{
"
"7D.22DNT^tz!!##D)))
!!$'''''"!u__HHT47###O!!!!!_rc&|jdS|j}|d}|dd}|dkr@|r<|}||d|dd|:dSdS|||dS)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!)rrNr)rrrr?s    rrxzRawTurtle.undo8s"?"F""$$aABBxU??
.xxzz

47DH---
.
.
.
.
.
JJvt$$$$$rrrrg)NNNN)Frx)FrQrr1)9rrrrrrr1rariryrr6rrr$rrrr9rlrmrorhrurtrnrrHrrrsrr7r8rrrrerCr2r?r=rr|r3r@rErGrIrFrrSrUrTrrxrwrrrrr	sG"G} $%5 6i&&&&P2,,,&---111


AAA!!!$////*(((+++
+
+
+&&&P6&?&?&?&?P7777.6%3%3%3%3N111&%$%$%$%$P
O
O
ONNN"KKKK$,$,$,P+++Z;;;,


8333j???B$0000 000*(.1.1.1.1`			----:"""###%%% "F((((
*2>>>>*"""@%%%:JJJrrcbtjtt_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~ >rceZdZdZdZedZdZededededfdZd	Z	d
Z
dZdZdS)
rNr*ctjbtxt_|_|jtj|j|jtjtd}td}td}td}td}td}|j	|||||j
t_t|tj|
||||dSdS)Nr{rrrrr)r_rootrir*_titler}_destroyr6rrqrsr	r1r')rr{rrrrrs       rr1z_Screen.__init__is= ).0GMDJJW^,,,J  ///?"ME(^F[)Il+J[)I[)IJ""5&)ZHHH"j3355GO!!$888JJufi;;;;;#"rr{rrrct|jdsdS|j}|j}t	|t
rd|cxkrdkrnn||z}|||z
dz}t	|t
rd|cxkrdkrnn||z}|||z
dz}|j|||||dS)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
        rxNrrr)r	r$rrrrrxr-)rr{rrvrwrshs       rr'z
_Screen.setups2tz>22	F
Z
!
!
#
#
Z
"
"
$
$eU##	UauHE>5jA%Ffe$$	f)9)9)9)9)9)9)9)9)9YF>6kQ&F
vvv>>>




rcttjtj||t_dS)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)rr$r*r%)rtitlestrings  rr*z
_Screen.titles-=$M,,,$rc|j}|tjur0dt_dt_dt_dt_dt_|dS)NF)	r$rrrr!r6r	rr|)rroots  rr&z_Screen._destroysKz7=  FK!FN GM"GO %rc.|dS)z~Shut the turtlegraphics window.

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


rcfd}|tdrdS	tdS#t$rt	dYdSwxYw)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()

        c0dS)z&Screen.bye() with two dummy-parametersN)r)rrrs  rexitGracefullyz+_Screen.exitonclick.<locals>.exitGracefullysHHJJJJJrrNr)rSrrAttributeErrorexit)rr0s` rrz_Screen.exitonclicks&						
^$$$	F	JJJJJ			GGGGGG	s<AA)
rrrr$r6rr%r1r'r*r&rrrrrrrcsEG
']F<<<,w-X+&tK/@&&&&P%%%"rrcLeZdZdZdZdZedededfdZdS)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_t|tj|||dS)N)rlrr)rr!r
rr1)rrlrrs    rr1zTurtle.__init__sM>!#XXFN4!&*8#*		,	,	,	,	,r)rrrrrr!rr1rrrrrsW
DGG} $%5 6i	,	,	,	,	,	,rrturtle_docstringdictci}tD]}d|z}t|j||<tD]}d|z}t|j||<t	d|zd5}td|D}|d|ddD]E}|d	t|z|d
||zF|d}|d	t|z|d||z|d|ddddS#1swxYwYdS)
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.pyrc3^K|](}|ddtv$|V)dS)rrN)r_alias_listrs  rrz&write_docstringdict.<locals>.<genexpr>sF==Aa;;;;;;==rzdocsdict = {

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

z        """%s
"""

z}
)	_tg_screen_functionsrr_tg_turtle_functionsrrr|reprclose)rdocsdict
methodnamerrrs      rrrsH***
#S		)

***

"S		)

	
g 	%	%=======	"###9	?	?C
GGHtCyy()))
GG-
=>>>>2h	499$%%%	(8C=8999					s"C3E""E&)E&cdd|iz}t|}|j}|D]?}	||t|_#t
$rt
d|zY<wxYwdS)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)r;
__import__r=rrrr)langmodnamemoduler=rs     rread_docstringsrD s2Z

4MMG

 
 FH33	3 (
DII	3	3	3+c122222	3	33sAA/.A/zCannot find docsdict forz;Unknown Error when trying to import %s-docstring-dictionarycNdx}}tj|j\}}}|dd}|dd}|jpg}d|D}dgt	|t	|z
z|z}dt||D}	|0|	d|z|d|z|0|	d|z|d|zd|	}d	|z}d|}d	|z}||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.
    rrNcg|]}d|S)rr)rrs  rr
z"getmethparlist.<locals>.<listcomp>Ms777UU 777rcg|]
\}}||zSrr)rrdflts   rr
z"getmethparlist.<locals>.<listcomp>Os 
B
B
BYS$cDj
B
B
Br*z**z, z(%s))inspectgetargs__code____defaults__rrrr)
obdefTextcallTextrZvarargsvarkwitems2realArgsdefaultsitems1s
          rgetmethparlistrW=sEGh#?2;77D'5
!""XFABBxH$"H77h777Hts8}}S]]23h>H
B
B#h*A*A
B
B
BF

cGm$$$

cGm$$$

dUl###

dUl###iiGwGyy  H HHrcddl}|dStd}|d|zd}|d|z}|d|}|S)z<To reduce docstrings from RawTurtle class for functions
    rNr%s.r \(.+ %s\)::rerreplacecompilesub)docstrr]
turtlename	newdocstrparexps     r_turtle_docrevisere\hIII
~to&Juz1"55I
ZZ3
4
4F

3	**Ircddl}|dStd}|d|zd}|d|z}|d|}|S)z?To reduce docstrings from TurtleScreen class for functions
    rNrrYrrZr[r\)rar]
screennamercrds     r_screen_docreviserihrfrardef {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
cH|D]}t||}t|\}}|dkrtd||<t|||||}	t|	t
||jt
|_dS)Nrz>>>>>>)objinitr
paramslistargslist)getattrrWr__func_bodyformatr	globalsr)
	functionsrrkrl	docreviser>rpl1pl2defstrs
          r_make_global_funcsrxs	B	B
j))!&))S"99(C%%%##$Z/2S$BBVWYY(1	&.(A(A		*%%	B	BrzTurtle._screenzScreen()zTurtle._penzTurtle()__main__c^trtdStdSr)rOr^rVrrr	switchpenr{s(88	DDDDDDDDDDrcttdttdt	tdt
dD]}|dkrtt
dD] }tdtd!|dkrtdtttd	t	td
tdtdttdtdtdtdtd
t	tdd
tdd
tdt
dD]>}tdtdtdtd?tdtt
dD]>}tdtdtdtd?tdS)zDemo of old turtle.py - moduleTdrrrirZmaroonrGrrF
startstartrredrdN)rar+rzr1r>r{rr2rDrQr:r?r`r|)rrs  rdemo1rs

t




aq		AAvv1XX

RAvvh


DDDBKKKFFFF
a
gu




b			
b			
c



lA
gq
eq		ABKKKHHHBKKK"IIIItq		ABKKKHHHBKKK"IIII




rc:tdttdtt	ddtdddz}t
dtdD] }tt|d!tdtrttttdtd	d}t!d
tdtdtdd
D]}|dkr(t#t%d	d|zz
dd|ztdD] }t'|td!t)|dz
}tdttdzdztdt+t'dt
dt-t/ddtdt#tdD]?}tddt
dt'dt
d@t)tdt+t'dt-t1dt3}|dt7}|d|d|
|d|d||dd|d||d|dd|d|dtt	|d}||dkr|d|d ||||d|d!zdkr6| | t|dz
}||dk|
d"d#d$%|d&|dd'}tCj"dtr6||t6|d|
d(d)*|#|dd+S),zDemo of some new features.rrrrr~rzwait a moment...rgreenrr[rZxFrGryellowri2rrFi(rjblueorangerg@g333333?rzCAUGHT! )r
rZboldr`)rrrc>ttdSr)rr)rrs  rbabazdemo2.<locals>.baba.sMMMEEEEErz  Click me!)Courierrr)rN)$rqrrrZrervr<rcrr{r5r|ryrxrarRrrXr2rBrAr?r^rVr:rlrIrbrrQrzrJr>rstimesleeprS)r%rlaengertrirrPrs        rdemo2rs%
a



71a==!!!!Q#
2r		AKKK62
 !!!!!	FFF !!	

2#



3r2
	"
	"A1uu#bd(Ar!t,,,1XX

6


3JJJbLFrFFF57719b.!!!!	3

2
2

eH
aq		A2rNNNrFFFrFFFrFFFF



2

2

hkkv&!!!XBQ		C		"





QVH%%%q		!76??###ll6""Q&&IIcNNNIIcNNNNN3;;v..///FF1IIIrzQ		QJEll6""Q&&			*#8	HHHWU				
1


!!	HHJJJKKMMM !!		r


		-(?	AAAD!r)r)r5)Gr_vertkinterr/rrrrJrros.pathrrrcopyrr_tg_classesr9r:
_tg_utilities__all__r8rrrrrrrrrrrr0rr4rkriobjectrrr5rrDr	rr5rzrr
r
rrrrrD	_LANGUAGEImportErrorrWrerirprxrrrr{rrrrrr<module>rsx2LL\7



''''''''''      III)))!!!'/
--0DD(>*,,,	#	4	c		c		T		
	T		

		S				$				W		g		z		D		I	 	!	"")'			,:<1Jt111	E/000001*$*$*$*$*$E*$*$*$j1
....*a#a#a#a#a#RXa#a#a#FI666)))))BE)))0
E5E5E5E5E5vE5E5E5Z					)			)
,1,1,1,1,1F,1,1,1^"6"6"6"6"6f"6"6"6Liiiii#iiiV||||||||~IIIII6IIIXLLLLL6LLL>DDDDDjDDDL$
CCCCClCCCJ,,,,,Y,,,(
    D333"
	MI	"""111	E
$i00000MMM	EHBKLMMMMMM
>





  
B
B
B'#Z1BDDD' *.?AAAz222jaaaF
EGGG	EGGGKMMMMMCs*B((B;:B;G))H<HH