
    F\h7                       S r  SSKrSSKrSSKrSSKrSSK	r	SSK
r
SSKJrJrJr  SSKJr  SSKJr  / SQr/ SQr/ S	QrS
S/r\\-   \-   \-   S/-   r/ SQr0 SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_S S!_S"S#_S$S#_S%S&_S'S(_S)S*_S+S,_S-S.S/S0.ErS1 rS2 r \" \5         " S4 S5\5      rS6 rS7 r S8r!ShS9 jr" " S: S;\RF                  5      r$\"" \$\RJ                  S<5         " S= S>\RL                  5      r'\RJ                  r% " S? S@\(5      r) " SA S\5      r* " SB SC\5      r+ " SD SE\(5      r, " SF SG\(5      r- " SH SI\)5      r. " SJ SK\(5      r/ " SL SM\(5      r0 " SN SO\(5      r1 " SP SQ\0\/5      r2\2r3SR r4 " SS ST\.5      r5 " SU SV\25      r6\6r7SiSW jr8SX r9\S)   r: \:S*:w  a  \9" \:5        S[ r;S\ r<S] r=S^r>S_ r?\?" \\5S`Sa\=5        \?" \\6SbSc\<5        \@rA\BSd:X  a  Se rCSf rDSg rE\D" 5         \E" 5         \F" 5         gg! \ a  r\" \" \5      S-   5      eSrCff = f! \ a    \" S35         GNf = f! \ a    \" SY\:5         N\ a    \" SZ\:-  5         Nf = f)ja  
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.
    Nz', please install the python3-tk package)isfilesplitjoin)deepcopy)simpledialog)	ScrolledCanvasTurtleScreenScreen	RawTurtleTurtleRawPenPenShapeVec2D)addshapebgcolorbgpicbyeclearscreen	colormodedelayexitonclick	getcanvas	getshapeslistenmainloopmodenuminputonkey
onkeypressonkeyreleaseonscreenclickontimerregister_shaperesetscreen
screensizesetupsetworldcoordinates	textinputtitletracerturtlesupdatewindow_heightwindow_width)Obackbackward
begin_fill
begin_polybkcircleclear
clearstampclearstampsclonecolordegreesdistancedotdownend_fillend_polyfd	fillcolorfillingforwardget_polygetpen	getscreenget_shapepoly	getturtlegotoheading
hideturtlehomehtisdown	isvisibleleftltonclickondrag	onreleasepdpenpencolorpendownpensizepenuppospositionpuradiansrightreset
resizemodertseth
setheadingsetpossetpositionsetundobuffersetxsetyshape	shapesizeshapetransformshearfactor
showturtlespeedststampteleporttilt	tiltangletowards
turtlesizeundoundobufferentriesupwidthwritexcorycorwrite_docstringdictdone
Terminator)r   r1   r4   rA   rN   rR   rV   r\   r^   rc   rd   rf   rg   rq   rw   rz   r{   r{         ?heightg      ?	canvwidthi  
canvheighti,  	leftright	topbottomr   standardr         ?r   
   undobuffersizei  rk   classicrX   blackrB   rb   noresizevisibleTlanguageenglishexampleturtleturtlescreenzPython Turtle GraphicsF)examplescreenr*   
using_IDLEc                     [        U S5       nUR                  5       nSSS5        0 nW H  nUR                  5       nU(       a  UR                  S5      (       a  M2   UR	                  S5      u  pVUR                  5       nUR                  5       nUS;   a  [        U5      nO SU;   a  [        U5      nO[        U5      n XcU'   M     U$ ! , (       d  f       N= f! [
         a    [        SU < SU< 35         M  f = f! [
         a     NKf = f)	z/Convert content of config-file into dictionary.rN#=zBad line in config-file z:
)TrueFalseNonez''z"".)
open	readlinesstrip
startswithr   
ValueErrorprintevalfloatint)filenamefcfglinescfgdictlinekeyvalues          /usr/lib/python3.13/turtle.pyconfig_dictr      s    	h	;;= 
Gzz|ts++	CJC iik99KE%<!%LEJE + , N3 
	  	xEF	  s5   CC#D 5D 
CC=<C= 
DDc                 J   Sn0 n0 n[        U5      (       a  [        U5      nSU;   a  SUS   -  n [        [        5      u  pE[	        XA5      n[        U5      (       a  [        U5      n[        R                  U5        [        R                  U5        g! [
         a    Sn NTf = f)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.cfg N)r   r   r   __file__r   	Exception_CFGr-   )r   default_cfgcfgdict1cfgdict2headtail	cfg_file2s          r   
readconfigr      s     KHHk{+!%(@@8_
+	 iy)KKKK  	s   B B"!B"z"No configfile read, reason unknownc                   T    \ rS rSrSrS rS rS rS rS r	S r
S	 rS
 rS rS rSrg)r      a  A 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                 0    [         R                  XU45      $ N)tuple__new__)clsxys      r   r   Vec2D.__new__   s    }}Sa&))    c                 >    [        U S   US   -   U S   US   -   5      $ Nr      r   selfothers     r   __add__Vec2D.__add__   )    T!WU1X%tAwuQx'788r   c                     [        U[        5      (       a  U S   US   -  U S   US   -  -   $ [        U S   U-  U S   U-  5      $ r   )
isinstancer   r   s     r   __mul__Vec2D.__mul__   sQ    eU##758#DGE!H$444T!WU]DGEM22r   c                     [        U[        5      (       d  [        U[        5      (       a  [        U S   U-  U S   U-  5      $ [        $ r   )r   r   r   r   NotImplementedr   s     r   __rmul__Vec2D.__rmul__   s>    eS!!Zu%=%=aQ66r   c                 >    [        U S   US   -
  U S   US   -
  5      $ r   r   r   s     r   __sub__Vec2D.__sub__  r   r   c                 *    [        U S   * U S   * 5      $ r   r   r   s    r   __neg__Vec2D.__neg__  s    d1gXQx((r   c                 (    [         R                  " U 6 $ r   )mathhypotr   s    r   __abs__Vec2D.__abs__  s    zz4  r   c                     [        U S   * U S   5      n[        R                  " U5      n[        R                  " U5      [        R                  " U5      pC[        U S   U-  US   U-  -   U S   U-  US   U-  -   5      $ )z.rotate self counterclockwise by angle
        r   r   )r   r   r_   cossin)r   angleperpcss        r   rotateVec2D.rotate	  sv     d1gXtAw'U#xx1T!WQYtAwqy($q'!)DGAI*=>>r   c                     U S   U S   4$ r    r   s    r   __getnewargs__Vec2D.__getnewargs__  s    Qa!!r   c                     SU -  $ )Nz(%.2f,%.2f)r   r   s    r   __repr__Vec2D.__repr__  s    t##r   r   N)__name__
__module____qualname____firstlineno____doc__r   r   r   r   r   r   r   r   r   r   __static_attributes__r   r   r   r   r      s9    *939)!?"$r   r   c                    [        U R                  5      nUR                  5         U H  n[        X15        M     U R                  R                  5        H(  u  pE[        U5      [        R                  :X  d  M$  XQU'   M*     g)#helper function for Scrolled CanvasN)	list	__bases__reverse__methodDict__dict__itemstypetypesFunctionType)r   _dictbaseList_superr   r   s         r   r  r    s`    CMM"HV# ll((*
;%,,,#J +r   c                 <    0 n[        X5        UR                  5       $ )r   )r  keys)r   r  s     r   	__methodsr  (  s    E::<r   zTdef %(method)s(self, *args, **kw): return self.%(attribute)s.%(method)s(*args, **kw)c                 \   0 n[        X5        0 n[        U 5      nUR                  5        H'  nUS S S:X  d  USS  S:X  d
  Xs;   d  Xv;   a  M!  XG   XW'   M)     UR                  5        HC  u  pXS.n
[	        U[
        5      (       a  [        XS.-  n[        WU
5        [        XX   5        ME     g )Nr   _)methodfunc)r  	attribute)	r  r  r  r  r   str__stringBodyexecsetattr)	fromClasstoClasstoPartexclude_dict_1r  mfcexr  r  d
execStrings               r   __forwardmethodsr!  2  s    G"E
I
Cllnbq6S=BrsGsNbmryEI	  ,fc""6HH Z	19- &r   c                   `    \ rS rSrSr  SS jrSS jrS rS rS r	S	 r
S
 rS rS rS rSrg)r   iG  zModeled after the scrolled canvas class from Grayons's Tkinter book.

Used as the default canvas, which pops up automatically when
using turtle graphics functions or the Turtle class.
c                    [         R                  R                  XX#S9  U R                  5       U l        X#sU l        U l        XEsU l        U l        SU l	        [         R                  " XUU R                  [         R                  SS9U l        [         R                  " XR                  R                  [         R                  S9U l        [         R                  " XR                  R"                  S9U l        U R                  R'                  U R                   R(                  U R$                  R(                  S9  U R+                  SS	SS
9  U R-                  SS	SS
9  U R                  R/                  S	U S	SSS	S	SS9  U R$                  R/                  S	U S	SS	S	S	SS9  U R                   R/                  S	U S	S	SS	S	SS9  U R1                  5         U R                  R3                  SU R4                  5        g )N)r{   r   white   )r{   r   bgreliefborderwidth)commandorient)r)  )xscrollcommandyscrollcommandr   r   )weightminsizenewspadxin_padyrowcolumnrowspan
columnspanstickyz<Configure>)TKFrame__init__winfo_toplevel_rootwindowr{   r   r   r   r&  CanvasSUNKEN_canvas	Scrollbarxview
HORIZONTALhscrollyviewvscroll	configuresetrowconfigurecolumnconfiguregridra   bindonResize)r   masterr{   r   r   r   s         r   r;  ScrolledCanvas.__init__M  s   
$eC..0"'
DK*3'yyV$(GGBII1N||FLL4F4F+-==:||FLL4F4FGdll.>.>.2ll.>.> 	 	@!Aq1Qq!4q1!!& 	 	Bq1!!& 	 	Bq1!!& 	 	B

mT]];r   Nc                 .   U(       a  Xl         U(       a  X l        U(       a  X0l        U R                  R	                  UU R                   * S-  U R                  * S-  U R                   S-  U R                  S-  4S9  U R                  R                  SU R                   U R                  -
  S-   -  U R                   -  5        U R                  R                  SU R                  U R                  -
  S-   -  U R                  -  5        U R                  5         g)z<Adjust canvas and scrollbars according to given canvas size.r%  )r&  scrollregionr      N)
r   r   r&  r@  configxview_movetor{   yview_movetor   adjustScrollsr   r   r   r&  s       r   ra   ScrolledCanvas.resetf  s    &N(OGr'+~~oq&84??:JA:M'+~~q'8$//1:L&N 	 	O 	!!#t~~

'BR'G"H?C~~#N 	O!!#t'Cb'H"I>Boo#N 	Or   c                 r   U R                   R                  5       nU R                   R                  5       nU R                   R                  SU R                  U-
  -  U R                  -  5        U R                   R                  SU R                  U-
  -  U R                  -  5        XR                  :  d  X R                  :  aA  U R                  R                  SU SSSSSSS9  U R                  R                  SU SSSSSSS9  gU R                  R                  5         U R                  R                  5         g)z@Adjust scrollbars according to window- and canvas-size.
        r   r   r   r/  r0  N)r@  winfo_widthwinfo_heightrT  r   rU  r   rD  rK  rF  grid_forget)r   cwidthcheights      r   rV  ScrolledCanvas.adjustScrollsx  s    ))+,,++-!!#t~~f'<"=dnn"LM!!#tw'>"?"OPNN"g&?LL1Dqa%&a  PLL1Dqa%&a  P LL$$&LL$$&r   c                 $    U R                  5         g)zself-explanatoryN)rV  )r   events     r   rM  ScrolledCanvas.onResize  s    r   c                 4    U R                   R                  " U6 $ ?'forward' method, which canvas itself has inherited...
        )r@  bboxr   argss     r   rf  ScrolledCanvas.bbox  s     ||  $''r   c                 :    U R                   R                  " U0 UD6$ rd  )r@  cgetr   rh  kwargss      r   rk  ScrolledCanvas.cget  s     ||  $1&11r   c                 <    U R                   R                  " U0 UD6  gre  N)r@  rS  rl  s      r   rS  ScrolledCanvas.config       	T,V,r   c                 <    U R                   R                  " U0 UD6  grp  )r@  rL  rl  s      r   rL  ScrolledCanvas.bind  s     	4*6*r   c                 <    U R                   R                  " U0 UD6  grp  )r@  unbindrl  s      r   rv  ScrolledCanvas.unbind  rr  r   c                 8    U R                   R                  5         grp  )r@  focus_forcer   s    r   ry  ScrolledCanvas.focus_force  s     	  "r   )	r@  r=  r&  r   r   r   rD  rF  r{   )  i^  iX  r{  NNN)r   r   r   r   r   r;  ra   rV  rM  rf  rk  rS  rL  rv  ry  r   r   r   r   r   r   G  sA    
 25DG<2$' (
2
-
+
-
#r   r   r@  c                   B    \ rS rSrSrS rS rS rS rS r	S r
S	 rS
rg)_Rooti  z'Root class for Screen based on Tkinter.c                 B    [         R                  R                  U 5        g r   )r9  Tkr;  r   s    r   r;  _Root.__init__  s    
tr   c                 \    [        XX#U5      U l        U R                  R                  SSS9  g )Nr   both)expandfill)r   r@  pack)r   r{   r   r]  r^  s        r   setupcanvas_Root.setupcanvas  s)    %d67K0r   c                     U R                   $ r   r@  r   s    r   
_getcanvas_Root._getcanvas  s    ||r   c                 0    U R                  SXX44-  5        g )Nz%dx%d%+d%+d)geometry)r   r{   r   startxstartys        r   set_geometry_Root.set_geometry  s    mUF$CCDr   c                 (    U R                  SU5        g )NWM_DELETE_WINDOW)wm_protocol)r   destroys     r   	ondestroy_Root.ondestroy  s    +W5r   c                 "    U R                  5       $ r   )winfo_screenwidthr   s    r   	win_width_Root.win_width  s    %%''r   c                 "    U R                  5       $ r   )winfo_screenheightr   s    r   
win_height_Root.win_height  s    &&((r   r  N)r   r   r   r   r   r;  r  r  r  r  r  r  r   r   r   r   r~  r~    s)    11E6()r   r~  c                      \ rS rSrSrS rS rS rS r  S&S jr	S	 r
  S&S
 jrS rS rS rS rS'S jrS rS(S jrS(S jrS(S jrS(S jrS rS'S jrS rS rS rS rS rS rS rS rS r S)S  jr!S! r"S" r#S# r$S)S$ jr%S%r&g)*TurtleScreenBasei  zProvide 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.
c                 f    [         R                  " SSU R                  S9nUR                  5         U$ )z$return a blank image object
        r   )r{   r   rN  )r9  
PhotoImagecvblank)r   imgs     r   _blankimageTurtleScreenBase._blankimage  s(     mm!Adgg>		
r   c                 >    [         R                  " XR                  S9$ )zPreturn an image object containing the
imagedata from a gif-file named filename.
)filerN  )r9  r  r  )r   r   s     r   _imageTurtleScreenBase._image  s     }}(77;;r   c                    Xl         [        U[        5      (       a-  U R                   R                  nU R                   R                  nOs[        U R                   R                  S5      5      n[        U R                   R                  S5      5      nU R                   R                  U* S-  U* S-  US-  US-  4S9  X l        X0l        S=U l        U l	        g )Nr{   r   r%  rQ  r   )
r  r   r   r   r   r   rk  rS  xscaleyscale)r   r  whs       r   r;  TurtleScreenBase.__init__  s    b.))!!A""ADGGLL)*ADGGLL*+AGGNNA2q51"a%Aq!t*ENF$''dkr   c                 8    U R                   R                  SSSS9$ )z<Create an invisible polygon item on canvas self.cv)
        )r   r   r   r   r   r   r   r  outline)r  create_polygonr   s    r   _createpolyTurtleScreenBase._createpoly  s!     ww%%&8r2%NNr   Nc                    / nU HA  u  pUR                  XR                  -  5        UR                  U	* U R                  -  5        MC     U R                  R                  " U/UQ76   Ub  U R                  R                  XS9  Ub  U R                  R                  XS9  Ub  U R                  R                  XS9  U(       a  U R                  R                  U5        gg)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.
Nr  )r  r{   appendr  r  r  coordsitemconfigure	tag_raise)
r   polyitem	coordlistr  r  r{   topclr   r   s
             r   	_drawpolyTurtleScreenBase._drawpoly  s     DAIIa++o&IIqb4;;&'  	x%"%GG!!(!6GG!!(!<GG!!(!8GGh' r   c           
      \    U R                   R                  SSSSSS[        R                  S9$ )z9Create an invisible line item on canvas self.cv)
        r   r   r%  )r  r{   capstyle)r  create_liner9  ROUNDr   s    r   _createlineTurtleScreenBase._createline  s3     ww""1aABa.0hh # 8 	8r   c                    Ubf  / nU HA  u  pxUR                  XpR                  -  5        UR                  U* U R                  -  5        MC     U R                  R                  " U/UQ76   Ub  U R                  R                  XS9  Ub  U R                  R                  XS9  U(       a  U R                  R                  U5        gg)a  Configure 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.
Nr  r  r  )	r   lineitemr  r  r{   r  r  r   r   s	            r   	_drawlineTurtleScreenBase._drawline  s      B!		!kk/*		1"t{{*+ " GGNN8)b)GG!!(!6GG!!(!8GGh' r   c                 :    U R                   R                  U5        g)zMDelete graphics item from canvas.
If item is"all" delete all graphics items.
N)r  deleter   items     r   _deleteTurtleScreenBase._delete%  s     	tr   c                 8    U R                   R                  5         g)z(Redraw graphics items on canvas
        N)r  r-   r   s    r   _updateTurtleScreenBase._update+  s     	r   c                 :    U R                   R                  U5        g)z-Delay subsequent canvas actions for delay ms.N)r  afterr   r   s     r   _delayTurtleScreenBase._delay0  s    er   c                 |     U R                   R                  U5      nSnU$ ! [        R                   a    Sn U$ f = f)zCCheck if the string color is a legal Tkinter color string.
        TF)r  	winfo_rgbr9  TclError)r   r:   rgboks       r   _iscolorstringTurtleScreenBase._iscolorstring4  sF    	''##E*CB 	 {{ 	B		s   ! ;;c                     Ub*  U R                   R                  US9  U R                  5         gU R                   R                  S5      $ )zNSet canvas' backgroundcolor if color is not None,
else return backgroundcolor.N)r&  r&  )r  rS  r  rk  )r   r:   s     r   _bgcolorTurtleScreenBase._bgcolor>  s8     GGNNN&LLN77<<%%r   c           	          Uu  pgX`R                   -  nXpR                  -  nSSSS.nU R                  R                  US-
  U* X(U   XTS9n	U R                  R	                  U	5      u  ppXS-
  4$ )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.swr   se)rQ   centerr`   r   )textanchorr  font)r  r  r  create_textrf  )r   r\   txtalignr  rX   r   r   r  r  x0y0x1y1s                 r   _writeTurtleScreenBase._writeG  s|    
 OOT;ww""1Q33/7 # Fd+Tzr   c                    ^ ^ Tc   T R                   R                  USU-  5        gUU 4S jnT R                   R                  USU-  XT5        g)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>c                    > TR                   R                  U R                  5      TR                  -  TR                   R	                  U R
                  5      * TR                  -  p!T" X5        g r   r  canvasxr   r  canvasyr   r  ra  r   r   funr   s      r   eventfun+TurtleScreenBase._onclick.<locals>.eventfun^  L    0<11$++= A	r   r  
tag_unbindtag_bindr   r  r  numaddr  s   ` `   r   _onclickTurtleScreenBase._onclickU  sE     ;GGt]S%89 GGT=3#6Fr   c                    ^ ^ Tc   T R                   R                  USU-  5        gUU 4S jnT R                   R                  USU-  XT5        g)a7  Bind 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>c                    > TR                   R                  U R                  5      TR                  -  TR                   R	                  U R
                  5      * TR                  -  p!T" X5        g r   r  r  s      r   r  -TurtleScreenBase._onrelease.<locals>.eventfunp  r  r   r  r	  s   ` `   r   
_onreleaseTurtleScreenBase._onreleased  sJ     ;GGt%?#%EF GGT#=#C%,r   c                    ^ ^ Tc   T R                   R                  USU-  5        gUU 4S jnT R                   R                  USU-  XT5        g)aA  Bind 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                    >  TR                   R                  U R                  5      TR                  -  TR                   R	                  U R
                  5      * TR                  -  p!T" X5        g ! [         a     g f = fr   )r  r  r   r  r   r   r  r   r  s      r   r  *TurtleScreenBase._ondrag.<locals>.eventfun  sc     GGOOEGG4T[[@ GGOOEGG44T[[@ I  s   A,A0 0
A=<A=r  r	  s   ` `   r   _ondragTurtleScreenBase._ondragw  sG     ;GGt%83%>? GGT#6#<hLr   c                    ^ ^ Tc  T R                   R                  SU-  5        gUU 4S jnT R                   R                  SU-  XC5        g)a  Bind 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.
Nr  c                    > TR                   R                  U R                  5      TR                  -  TR                   R	                  U R
                  5      * TR                  -  p!T" X5        g r   r  r  s      r   r  1TurtleScreenBase._onscreenclick.<locals>.eventfun  r  r   r  rv  rL  )r   r  r
  r  r  s   ``   r   _onscreenclickTurtleScreenBase._onscreenclick  s=     ;GGNN=3./ GGLL,h<r   c                    ^ Tc   U R                   R                  SU-  S5        gU4S jnU R                   R                  SU-  U5        g)zPBind fun to key-release event of key.
Canvas must have focus. See method listen
Nz<KeyRelease-%s>c                    > T" 5         g r   r   ra  r  s    r   r  0TurtleScreenBase._onkeyrelease.<locals>.eventfun      r   r  r   r  r   r  s    `  r   _onkeyreleaseTurtleScreenBase._onkeyrelease  s?     ;GGNN,s2D9GGLL*S0(;r   c                   ^ Tc@  Uc  U R                   R                  SS5        gU R                   R                  SU-  S5        gU4S jnUc  U R                   R                  SU5        gU R                   R                  SU-  U5        g)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>c                    > T" 5         g r   r   r   s    r   r  .TurtleScreenBase._onkeypress.<locals>.eventfun  r"  r   r  r#  s    `  r   _onkeypressTurtleScreenBase._onkeypress  sk    
 ;{|T24d;{\84_s2H=r   c                 8    U R                   R                  5         g)z=Set focus on canvas (in order to collect key-events)
        N)r  ry  r   s    r   _listenTurtleScreenBase._listen  s     	r   c                 ~    US:X  a  U R                   R                  U5        gU R                   R                  X!5        g)z?Install a timer, which calls fun after t milliseconds.
        r   N)r  
after_idler  r   r  ts      r   _ontimerTurtleScreenBase._ontimer  s-     6GGs#GGMM!!r   c                 8    U R                   R                  SSUS9$ )z0Create and return image item on canvas.
        r   image)r  create_image)r   r6  s     r   _createimageTurtleScreenBase._createimage  s      ww##Aq#66r   c                     Uu  pEU R                   R                  XU R                  -  U* U R                  -  45        U R                   R	                  XS9  g)zJConfigure image item as to draw image object
at position (x,y) on canvas)
r5  N)r  r  r  r  
itemconfig)r   r  r\   r6  r   r   s         r   
_drawimageTurtleScreenBase._drawimage  sH     t$++orDKK/?@A4-r   c                 l    U R                   R                  XS9  U R                   R                  U5        g)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 .r5  N)r  r;  	tag_lower)r   r  r6  s      r   	_setbgpicTurtleScreenBase._setbgpic  s+    
 	4-$r   c                 8    U R                   R                  U5      $ )zAReturn 'line' or 'polygon' or 'image' depending on
type of item.
)r  r  r  s     r   _typeTurtleScreenBase._type  s     ww||D!!r   c                     U R                   R                  U5      n[        S[        U5      S5       Vs/ s H  o2U   X#S-      * 4PM     nnU$ s  snf )zreturns 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)]
>>> r   r%  r   )r  r  rangelen)r   r  r  ipls        r   
_pointlistTurtleScreenBase._pointlist  sR     WW^^D!).q#b'1)=>)=A!urA#wh)=>
 ?s   Ac                 :    U R                   R                  XX44S9  g )Nr  )r  rS  )r   srx1sry1srx2sry2s        r   _setscrollregion!TurtleScreenBase._setscrollregion  s    T$<=r   c                 T   U R                   R                  5       nU H  n[        U R                   R                  U5      5      n/ nU(       a;  US S u  pxUR	                  Xq-  5        UR	                  X-  5        USS  nU(       a  M;  U R                   R                  " U/UQ76   M     g )Nr%  )r  find_allr   r  r  )	r   xscalefactoryscalefactorr  r  coordinatesnewcoordlistr   r   s	            r   _rescaleTurtleScreenBase._rescale  s      "Dtww~~d34KL"2A##A$45##A$45)!"o	 +
 GGNN4/,/ r   c                 H   [        U R                  [        5      (       d  U R                  U R                  4$ Xs=L a	  Us=L a  c/  O  O,U R                  R                  U R                  R                  4$ Ub  Xl        Ub  X l        U R                  R                  XU5        g)zQResize the canvas the turtles are drawing on. Does
not alter the drawing window.
N)r   r  r   r   r   ra   rW  s       r   _resizeTurtleScreenBase._resize  s}    
 $''>22>>4??220b0077$$dgg&8&888 &N!(OiR0r   c                     U R                   R                  5       nUS::  a  U R                   S   nU R                   R                  5       nUS::  a  U R                   S   nX4$ )z:Return the width and height of the turtle window.
        r   r{   r   )r  rZ  r[  )r   r{   r   s      r   _window_sizeTurtleScreenBase._window_size  sZ     ##%A:GGG$E%%'Q;WWX&F}r   c                 L    U R                   R                  R                  5         g)aC  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)r  tkr   r   s    r   r   TurtleScreenBase.mainloop  s     	

r   c                 @    [         R                  " XU R                  S9$ )aM  Pop 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  )r   r*   prompts      r   r)   TurtleScreenBase.textinput'  s     %%eDGGDDr   c           	      D    [         R                  " XUXEU R                  S9$ )aW  Pop 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)

)initialvalueminvaluemaxvaluere  )r   askfloatr  )r   r*   rg  defaultminvalmaxvals         r   r   TurtleScreenBase.numinput6  s%    $ $$U.4,0GG5 	5r   )r   r   r  r  r  )NNNFr   r   Nr|  )'r   r   r   r   r   r  r  r;  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r$  r)  r,  r2  r8  r<  r@  rC  rJ  rQ  rY  r\  r_  r   r)   r   r   r   r   r   r  r    s    <(O
 3705(28 -1-2(.
&G,&M*=$	<>$
"7
. "
>
01	E5r   r  c                       \ rS rSrSrSrg)r   iR  zWill 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.
r   Nr   r   r   r   r   r   r   r   r   r   r   R  s    
 	r   c                       \ rS rSrSrSrg)TurtleGraphicsErrori[  zSome TurtleGraphics Error
    r   Nrt  r   r   r   rv  rv  [  s    r   rv  c                   ,    \ rS rSrSrSS jrSS jrSrg)r   i`  zData 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                 b   Xl         US:X  a!  [        U[        5      (       a  [        U5      nO|US:X  a_  [        U[        5      (       aI  UR                  5       R                  S5      (       a%  [        U5      (       a  [        R                  U5      nOUS:X  a  / nO[        SU-  5      eX l        g )Npolygonr6  .gifcompoundzThere is no shape type %s)rC  r   r   r   r  lowerendswithr   r	   r  rv  _data)r   type_datas      r   r;  Shape.__init__g  s    
I$%%T{g$$$::<((00VD\\'..t4Dj D%&AE&IJJ
r   c                     U R                   S:w  a  [        SU R                   -  5      eUc  UnU R                  R                  XU/5        g)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)rC  rv  r~  r  )r   polyr  r  s       r   addcomponentShape.addcomponentw  sP      ::#%&HBF**'M N N?G

4w/0r   )r~  rC  r   )r   r   r   r   r   r;  r  r   r   r   r   r   r   `  s     1r   r   c                   D    \ rS rSrSrSS jrSS jrS rS rS r	S	 r
S
rg)Tbufferi  z5Ring buffer used as undobuffer for RawTurtle objects.c                 D    Xl         S //U-  U l        SU l        SU l        g )Nr  F)bufsizebufferptrcumulate)r   r  s     r   r;  Tbuffer.__init__  s%    vh(r   Nc                     Uc-  [        U R                  5       H  nS /U R                  U'   M     OXl        S //U-  U l        SU l        g )Nr  )rF  r  r  r  )r   r  rH  s      r   ra   Tbuffer.reset  sG    ?4<<("&A ) #L 6(W,DKr   c                    U R                   S:  at  U R                  (       d:  U R                  S-   U R                   -  U l        XR                  U R                  '   g U R                  U R                     R	                  U5        g g r   )r  r  r  r  r  r  s     r   pushTbuffer.push  s]    <<!== HHqLDLL8(,DHH%DHH%,,T2 r   c                     U R                   S:  aZ  U R                  U R                     nUc  g S /U R                  U R                  '   U R                  S-
  U R                   -  U l        U$ g r   )r  r  r  r  s     r   popTbuffer.pop  s^    <<!;;txx(D|)-DHH% HHqLDLL8 r   c                 T    U R                   U R                  R                  S /5      -
  $ r   )r  r  countr   s    r   nr_of_itemsTbuffer.nr_of_items  s"    ||dkk//777r   c                 ^    [        U R                  5      S-   [        U R                  5      -   $ )N )r  r  r  r   s    r   r   Tbuffer.__repr__  s#    4;;#%DHH55r   )r  r  r  r  )r   r   )r   r   r   r   r   r;  ra   r  r  r  r   r   r   r   r   r  r    s#    ?
386r   r  c                      \ rS rSrSrSr\S   \S   \S   4S jrS rS#S
 jr	S r
S#S jrS rS rS#S jrS rS rS rS$S jrS#S jrS rS rS rS rS rS rS%S jrS rS#S jrS$S jrS&S jrS#S  jrS'S! jr \r!\r"\r#\r$\r%S"r&g	)(r	   i  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.
Tr   r   r   c                    [         R                  X5        [        SS5      [        SS5      [        SS5      [        SS5      [        SS5      [        SS5      [        SU R                  5       5      S	.U l        S
S0U l        X l        X@l        [        S   U l	        / U l
        U R                  5         [        R                  S:X  a;  UR                  5       nUR                  SSSSS5        UR                  SSSSS5        g g )Nry  )r   r   r   r   r   ))r      )   )r  r   )   )	   )   )   )r  r   ))r  )r  r  )r  r  r   r  )   r  )   r  )r  r  )r  r  )r  r   )r  r  )r  r  )r  r  )r  r  )r   r   )r%  r  )r  )Q#@Q@)Gz. @Q@)r  r  )r  r  r  )Qr  )Qr  )Gz. r  )Q#r  r  )r  r  )r  r  )r  r  )r  r  )g       g      $)r  r  )r  r  )r  r  )r  r  ))r   r  )r   r   )r  r   )r  r  ))r   Gz)r   g'@)r  r  )r   r   )r  r  r  )r  r  r6  )arrowr   r5   squaretriangler   r  nopicr   r   darwinwm
attributesr   z-topmost10)r  r;  r   r  _shapes_bgpics_mode_delayvaluer   
_colormode_keysr6   sysplatformr<  call)r   r  r   r   r   
rootwindows         r   r;  TurtleScreen.__init__  s   !!$+ #9.GH"9 /& '
 #9 /H I #9 /) *"9 /+ ,"9.KL"7D,<,<,>?%*  "~
 {+


<<8# **,JOOD,ZEOOD,ZE $r   c                    [         S   U l        [         S   U l        U R                  S5        U R	                  S5      U l        SU l        SU l        SU l        / U l	        U R                  S5        S	 H  nU R                  S
U5        M     U R                  S
5        U R                  S
S
  H'  nU R                  S
U5        U R                  S
U5        M)     S
[        l        g
)a9  Delete 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.
r   r   allr   r  r   r   r$  )r   r%     N)r   r  r  r  r8  _bgpic
_bgpicname_tracing_updatecounter_turtlesr   rS   r    r  r   r   _pen)r   btnr   s      r   r6   TurtleScreen.clear  s      ={+U''+!WCLLs# ::a=CJJtS!OOD#& ! r   Nc                 R   Uc  U R                   $ UR                  5       nUS;  a  [        SU-  5      eXl         US;   aX  U R                  U R                  * S-  U R
                  * S-  U R                  S-  U R
                  S-  5        S=U l        U l        U R                  5         g)a  Set 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'
Nr   logoworldzNo turtle-graphics-mode %s)r   r  r%  r   )	r  r|  rv  rQ  r   r   r  r  ra   r   r   s     r   r   TurtleScreen.mode  s    , <::zz|44%&BT&IJJ
''!!4>>/1"4t6F6I'+~~q'8$//1:LN(++DK$+

r   c                 h   U R                  5       S:w  a  U R                  S5        [        X1-
  5      n[        XB-
  5      nU R                  5       u  pxU R                  US-
  US-
  5        U R                  U R
                  pU R                  U-  U l        U R                  U-  U l        XR                  -  nU* U R
                  -  nU R                  U-   nU R                  U-   nU R                  XX5        U R                  U R                  U	-  U R
                  U
-  5        U R                  5         g)a  Set 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)
r     N)r   r   r_  r&   r  r  r   r   rQ  rY  r-   )r   llxllyurxuryxspanyspanwxwy	oldxscale	oldyscalerM  rN  rO  rP  s                  r   r(    TurtleScreen.setworldcoordinates&  s    , 99;'!IIgci ci ""$2r"u%#{{DKK9nnu,oo-[[ tdkk!~~$%d$5dkk)+T[[-BCr   c                     UcK  UR                  5       R                  S5      (       a  [        SU R                  U5      5      nO,[	        S5      e[        U[        5      (       a  [        SU5      nX R                  U'   g)a  Adds 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)))

Nrz  r6  z;Bad arguments for register_shape.
Use  help(register_shape)ry  )r|  r}  r   r  rv  r   r   r  )r   namerk   s      r   r$   TurtleScreen.register_shapeM  so    . =zz|$$V,,gt{{4'89) +H J Ju%%)U+E"Tr   c                 ,   [        U5      S:X  a  US   n[        U[        5      (       a5  U R                  U5      (       d  US:X  a  U$ [	        S[        U5      -  5      e Uu  p#nU R                  S:X  a$  X#U4 Vs/ s H  n[        SU-  5      PM     snu  p#nSUs=::  a  S::  a"  O  OSUs=::  a  S::  a  O  OSUs=::  a  S::  d  O  [	        S	[        U5      -  5      eS
X#U4-  $ ! [
        [        4 a    [	        S[        U5      -  5      ef = fs  snf )zReturn 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.
r   r   r   zbad color string: %sbad color arguments: %sr        o@   bad color sequence: %s#%02x%02x%02x)	rG  r   r  r  rv  	TypeErrorr   r  round)r   r:   r   gbr   s         r   	_colorstrTurtleScreen._colorstrp  s    u:?!HEeS!!""5))Ub[)*@3u:*MNN	NGA! ??c!01ay9y!uU1W~y9GA!a3Q!]s]a3%&>U&KLL!** :& 	N%&?#e*&LMM	N :s    C& ;D&(Dc           	      X  ^  UR                  S5      (       d  U$ [        U5      S:X  a"  S Vs/ s H  n[        XUS-    S5      PM     nnOB[        U5      S:X  a%  USS   Vs/ s H  nS[        X   S5      -  PM     nnO[        SU-  5      e[	        U 4S	 jU 5       5      $ s  snf s  snf )
Nr   r  )r   r  r  r%  r  r  r   zbad colorstring: %sc              3   F   >#    U  H  oTR                   -  S -  v   M     g7f)r  N)r  ).0r   r   s     r   	<genexpr>&TurtleScreen._color.<locals>.<genexpr>  s     9b(,bs   !)r   rG  r   rv  r   )r   cstrrH  r  r  s   `    r   _colorTurtleScreen._color  s    s##Kt9>09:	1#dQqSk2&	B:BY!^/3ABx8x!"S"%%xB8B%&;d&BCC9b999 ;8s   B"!B'c                 ~    Uc  U R                   $ US:X  a  [        U5      U l         gUS:X  a  [        U5      U l         gg)a)  Return 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)
Nr   r  )r  r   r   )r   cmodes     r   r   TurtleScreen.colormode  s<     =??"C<#ElDOc\!%jDO r   c                     U R                    H.  nUR                  U R                  5        UR                  5         M0     g)zReset all Turtles on the Screen to their initial state.

No argument.

Example (for a TurtleScreen instance named screen):
>>> screen.reset()
N)r  _setmoder  ra   )r   r   s     r   ra   TurtleScreen.reset  s+     mmFOODJJ'LLN $r   c                     U R                   $ )zReturn the list of turtles on the screen.

Example (for a TurtleScreen instance named screen):
>>> screen.turtles()
[<turtle.Turtle object at 0x00E11FB0>]
)r  r   s    r   r,   TurtleScreen.turtles  s     }}r   c                     U(       a  U R                  U5      nOSnU R                  U5      nUb  U R                  U5      nU$ )aO  Set 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)r  r  r  r   rh  r:   s      r   r   TurtleScreen.bgcolor  sA     NN4(EEe$KK&Er   c                     Uc  U R                   $ [        U5      U l         SU l        Ub  [        U5      U l        U R                   (       a  U R	                  5         gg)a  Turns 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   )r  r   r  r  r-   )r   nr   s      r   r+   TurtleScreen.tracer  sM    & 9== A"5zD==KKM r   c                 B    Uc  U R                   $ [        U5      U l         g)zReturn or set the drawing delay in milliseconds.

Optional argument:
delay -- positive integer

Example (for a TurtleScreen instance named screen):
>>> screen.delay(15)
>>> screen.delay()
15
N)r  r   r  s     r   r   TurtleScreen.delay  s!     =###u:r   c                     [         R                  (       d  S[         l        [        eU R                  S:  a5  U =R                  S-  sl        U =R                  U R                  -  sl        gg)zIncrement update counter.Tr   r   N)r	   _RUNNINGr   r  r  r   s    r   _incrementudcTurtleScreen._incrementudc  sP    $$$(L!==11$4==0 r   c                     U R                   nSU l         U R                  5        H#  nUR                  5         UR                  5         M%     Xl         U R	                  5         g)z'Perform a TurtleScreen update.
        TN)r  r,   _update_data_drawturtler  )r   tracingr1  s      r   r-   TurtleScreen.update  sG     --ANNMMO    r   c                 (    U R                  5       S   $ )zzReturn the width of the turtle window.

Example (for a TurtleScreen instance named screen):
>>> screen.window_width()
640
r   r_  r   s    r   r/   TurtleScreen.window_width         "1%%r   c                 (    U R                  5       S   $ )z|Return the height of the turtle window.

Example (for a TurtleScreen instance named screen):
>>> screen.window_height()
480
r   r!  r   s    r   r.   TurtleScreen.window_height  r#  r   c                     U R                   $ )zReturn the Canvas of this TurtleScreen.

No argument.

Example (for a Screen instance named screen):
>>> cv = screen.getcanvas()
>>> cv
<turtle.ScrolledCanvas instance at 0x010742D8>
)r  r   s    r   r   TurtleScreen.getcanvas(  s     wwr   c                 H    [        U R                  R                  5       5      $ )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  r  r   s    r   r   TurtleScreen.getshapes4  s     dll'')**r   c                 (    U R                  XU5        g)a  Bind 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)r  r   r  r  r  s       r   rS   TurtleScreen.onclick?  s     	Cc*r   c                     Uc+  X R                   ;   a  U R                   R                  U5        O*X R                   ;  a  U R                   R                  U5        U R                  X5        g)a  Bind 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)r  remover  r$  r   r  r   s      r   r   TurtleScreen.onkeyP  sP    . ;jj 

!!#&

"JJc"3$r   c                     Uc+  X R                   ;   a  U R                   R                  U5        O-Ub*  X R                   ;  a  U R                   R                  U5        U R                  X5        g)a  Bind 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)r  r/  r  r)  r0  s      r   r    TurtleScreen.onkeypressn  sT    2 ;jj 

!!#&_JJ!6JJc""r   c                 $    U R                  5         g)zSet 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,  )r   xdummyydummys      r   r   TurtleScreen.listen  s     	r   c                 &    U R                  X5        g)a  Install 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)r2  r0  s      r   r#   TurtleScreen.ontimer  s    & 	cr   c                     Uc  U R                   $ XR                  ;  a  U R                  U5      U R                  U'   U R                  U R                  U R                  U   5        Xl         g)a  Set 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)r  r  r  r@  r  )r   picnames     r   r   TurtleScreen.bgpic  sT    " ???",,&$(KK$8DLL!t{{DLL$9:!r   c                 &    U R                  XU5      $ )av  Resize 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\  rW  s       r   r&   TurtleScreen.screensize  s    " ||I266r   )r  r  r  r  r  r  r  r  r  r  r  r  r  r   NNrr  r   r|  )'r   r   r   r   r   r  r   r;  r6   r   r(   r$   r  r  r   ra   r,   r   r+   r   r  r-   r/   r.   r   r   rS   r   r    r   r#   r   r&   r"   r%   r   r   r!   r   r   r   r   r	   r	     s     H $V,DM&FP< D%N!#F+6	:)*
.8&1	&&
	++"%<#@
*"07& MKKHLr   r	   c                   n   \ rS rSrSr\" SS5      \" SS5      \" SS5      S.rSrSrSr	\4S	 jr
S
 rS,S jrS rS-S jrS rS rS rS rS.SS.S\SS4S jjjrS rS rS rS rS rS rS rS,S jrS  rS! rS" rS,S# jr S,S$ jr!S% r"S& r#S.S' jr$S/S( jr%S.S) jr&S,S* jr'\r(\r)\r*\r+\r,\r-\r.\r/\#r0S+r1g)0
TNavigatori  zJNavigation part of the RawTurtle.
Implements methods for turtle movement.
r           )r   r  r  r   r   r   c                     U R                   U l        U R                  U l        Xl        S U l        U R                  5         S U l        U R                  U5        [        R                  U 5        g r   )
DEFAULT_ANGLEOFFSET_angleOffsetDEFAULT_ANGLEORIENT_angleOrientr  
undobufferr;   r  rB  ra   r  s     r   r;  TNavigator.__init__  sT     44 44

dr   c                 j    [        SS5      U l        [        R                  U R                     U l        g)zHreset turtle to its initial values

Will be overwritten by parent class
rC  N)r   	_positionrB  START_ORIENTATIONr  _orientr   s    r   ra   TNavigator.reset  s'    
 sC"44TZZ@r   Nc                     Uc  U R                   $ US;  a  gXl         US;   a  SU l        SU l        gU R                  S-  U l        SU l        g)z:Set turtle-mode to 'standard', 'world' or 'logo'.
        Nr  )r   r  r   r         @r  )r  rF  rH  _fullcircler  s     r   r  TNavigator._setmode  sX     <::44
(( !D !D $ 0 0 3D "Dr   c                 h    Xl         SU-  U l        U R                  S:X  a  SU l        gUS-  U l        g)z+Helper function for degrees() and radians()ih  r   r   rQ  N)rR  _degreesPerAUr  rF  r   
fullcircles     r   _setDegreesPerAUTNavigator._setDegreesPerAU  s4    % ^::# !D *2Dr   c                 &    U R                  U5        g)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)rX  rV  s     r   r;   TNavigator.degrees  s    , 	j)r   c                 B    U R                  [        R                  5        g)zSet 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)rX  r   taur   s    r   r_   TNavigator.radians.  s     	dhh'r   c                 ^    U R                   U R                  U-  -   nU R                  U5        g)z)move turtle forward by specified distanceN)rL  rN  _goto)r   r<   endes      r   _goTNavigator._go<  s%    ~~x 77

4r   c                 `    XR                   -  nU R                  R                  U5      U l        g)z=Turn turtle counterclockwise by specified angle if angle > 0.N)rU  rN  r   r   r   s     r   _rotateTNavigator._rotateA  s&    ###||**51r   c                     Xl         g)zmove turtle to position end.NrL  )r   ends     r   r`  TNavigator._gotoF  s    r   Ffill_gaprm  returnc                t    Ub  UOU R                   S   nUb  UOU R                   S   n[        XE5      U l         g)zHTo be overwritten by child class RawTurtle.
Includes no TPen references.Nr   r   )rL  r   )r   r   r   rm  new_xnew_ys         r   rs   TNavigator.teleportJ  s8     ]q(9]q(9u,r   c                 &    U R                  U5        g)a  Move 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)
Nrb  r   r<   s     r   rD   TNavigator.forwardQ  s    * 	r   c                 (    U R                  U* 5        g)ao  Move 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)
Nrt  ru  s     r   r0   TNavigator.backh  s    $ 	(r   c                 (    U R                  U* 5        g)a  Turn 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
Nrf  re  s     r   r`   TNavigator.right|  s    & 	eVr   c                 &    U R                  U5        g)a  Turn 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
Nrz  re  s     r   rQ   TNavigator.left  s    & 	Ur   c                     U R                   $ )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)
ri  r   s    r   r\   TNavigator.pos  s     ~~r   c                      U R                   S   $ )zReturn 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
r   ri  r   s    r   r}   TNavigator.xcor       ~~a  r   c                      U R                   S   $ )zReturn 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
r   ri  r   s    r   r~   TNavigator.ycor  r  r   c                 n    Uc  U R                  [        U6 5        gU R                  [        X5      5        g)a  Move 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)r`  r   )r   r   r   s      r   rJ   TNavigator.goto  s)    < 9JJuay!JJuQ{#r   c                 J    U R                  SS5        U R                  S5        g)zMove 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()
r   N)rJ   re   r   s    r   rM   TNavigator.home  s     			!Qr   c                 R    U R                  [        XR                  S   5      5        g)a-  Set 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)
r   Nr`  r   rL  )r   r   s     r   ri   TNavigator.setx  s      	

5NN1-./r   c                 T    U R                  [        U R                  S   U5      5        g)a/  Set 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)
r   Nr  )r   r   s     r   rj   TNavigator.sety  s       	

5*A./r   c                     Ub  [        X5      n[        U[         5      (       a  UnO?[        U[        5      (       a	  [        U6 nO![        U[        5      (       a  UR                  n[        WU R                  -
  5      $ )ac  Return 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
)r   r   r   rB  rL  abs)r   r   r   r\   s       r   r<   TNavigator.distance%  sd    , =+CaC5!!)C:&&++C3'((r   c                    Ub  [        X5      n[        U[         5      (       a  UnO?[        U[        5      (       a	  [        U6 nO![        U[        5      (       a  UR                  nWU R                  -
  u  p[        [        R                  " [        R                  " X!5      5      S5      S-  nX@R                  -  nU R                  U R                  U-  -   U R                  -  $ )a  Return 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
r        v@)r   r   r   rB  rL  r  r   r;   atan2rU  rF  rH  rR  )r   r   r   r\   results        r   rv   TNavigator.towardsE  s    , =+CaC5!!)C:&&++CT^^#t||DJJq$45r:UB$$$!!D$5$5f$<<@P@PPPr   c                     U R                   u  p[        [        R                  " [        R                  " X!5      5      S5      S-  nX0R
                  -  nU R                  U R                  U-  -   U R                  -  $ )zReturn the turtle's current heading.

No arguments.

Example (for a Turtle instance named turtle):
>>> turtle.left(67)
>>> turtle.heading()
67.0
r   r  )	rN  r  r   r;   r  rU  rF  rH  rR  )r   r   r   r  s       r   rK   TNavigator.headingh  sg     ||t||DJJq$45r:UB$$$!!D$5$5f$<<@P@PPPr   c                     XR                  5       -
  U R                  -  nU R                  nX#S-  -   U-  US-  -
  nU R                  U5        g)a  Set 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)rK   rH  rR  rf  )r   to_angler   fulls       r   re   TNavigator.setheadingw  sM    . LLN*D,=,==Bw$tBw.Ur   c           	         U R                   (       a-  U R                   R                  S/5        SU R                   l        U R                  5       nUc  U R                  nUcB  [        U5      U R                  -  nS[        [        S[        U5      S-  -   S5      U-  5      -   nSU-  U-  nS	U-  nS
U-  [        R                  " [        R                  " U5      U R                  -  5      -  nUS:  a  U* U* U* pvnU R                  5       n	U R                  5       n
US:X  a  U R                  SS5        OU R                  S5        U R                  U5        [        U5       HG  nU R                  U5        U R!                  U5        U R                  S5        U R                  U5        MI     U R                  U* 5        US:X  a  U R                  X5        U R                  U5        U R                   (       a  SU R                   l        gg)a2  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
seqTNr      g      @g     M@r   r   r  r   F)rI  r  r  rp   rR  r  r   minr   r   r_   rU  _tracerr  rf  rF  rb  )r   radiusextentstepsrp   fracr  w2ltrdlrH  s               r   r5   TNavigator.circle  s   < ??OO  %)'+DOO$

>%%F=v;t///Dc#bVS0$7<==E&L5 1W&L488DLL$4T5G5G$GHHA:rA2s"A\\^[[]A:LLAJJqMRuAJJuHHQKJJqMLLO	 
 	bSA:LL 

5??',DOO$ r   c                     gz/dummy method - to be overwritten by child classNr   )r   r   s     r   rp   TNavigator.speed      r   c                     gr  r   )r   ar  s      r   r  TNavigator._tracer  r  r   c                     gr  r   )r   r  s     r   r  TNavigator._delay  r  r   )rF  rH  rU  rR  r  rN  rL  rI  r   )r  r?  r@  )2r   r   r   r   r   r   rM  DEFAULT_MODErE  rG  r;  ra   r  rX  r;   r_   rb  rf  r`  boolrs   rD   r0   r`   rQ   r\   r}   r~   rJ   rM   ri   rj   r<   rv   rK   re   r5   rp   r  r  rA   r4   r1   rc   rR   r]   rf   rg   rd   r   r   r   r   rB  rB    s    #sO#sO#sO' L( A#.*0(
2
-5 -D -T -.(**!!!$F0$0$)@!QFQ8=-B>>> 
B	BH	B	BHFKDr   rB  c                       \ rS rSrSr\S   4S jr\S   \S   4S jrS S	 jrS S
 jr	S r
S rS rS S jrS rS rS rS!SS.S\SS4S jjjrS rS rS rS S jrS"S jrS#S jrS rS r\	r\
r\
r\r\r\r \r!Sr"g)$TPeni  z>Drawing part of the RawTurtle.
Implements drawing properties.
rb   c                 H    Xl         S U l        [        R                  U 5        g r   )_resizemoderI  r  _reset)r   rb   s     r   r;  TPen.__init__  s    %Dr   rX   rB   c                     SU l         SU l        Xl        X l        SU l        SU l        SU l        SU l        SU l        SU l	        SU l
        g )Nr   Tr  )r   r   rC  )r   rC  rC  r   )_pensize_shown	_pencolor
_fillcolor_drawing_speed_stretchfactor_shearfactor_tilt_shapetrafo_outlinewidth)r   rX   rB   s      r   r  TPen._reset  sO    !#&
+r   Nc                 n    Uc  U R                   $ UR                  5       nUS;   a  U R                  US9  gg)a  Set 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)autouserr   rb   )r  r|  rW   )r   rmodes     r   rb   TPen.resizemode  s<    , =###00HHH& 1r   c                 @    Uc  U R                   $ U R                  US9  g)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   )r   r{   s     r   rZ   TPen.pensize  s!    $ === r   c                 F    U R                   (       d  gU R                  SS9  g)zPull the pen up -- no drawing when moving.

Aliases: penup | pu | up

No argument

Example (for a Turtle instance named turtle):
>>> turtle.penup()
NFrY   r  rW   r   s    r   r[   
TPen.penup0  s     }}r   c                 F    U R                   (       a  gU R                  SS9  g)zPull the pen down -- drawing when moving.

Aliases: pendown | pd | down

No argument.

Example (for a Turtle instance named turtle):
>>> turtle.pendown()
NTr  r  r   s    r   rY   TPen.pendown>  s     ==r   c                     U R                   $ )zReturn 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  r   s    r   rO   TPen.isdownL  s     }}r   c                     SSSSSS.nUc  U R                   $ X;   a  X!   nO'SUs=:  a  S	:  a  O  O[        [        U5      5      nOSnU R                  US
9  g)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)
r   r   r  r  r   )fastestfastnormalslowslowestNr   g      %@)rp   )r  r   r  rW   )r   rp   speedss      r   rp   
TPen.speed[  s]    6 b1Q!M=;;?ME54e%EEur   c                 8   U(       a^  [        U5      nUS:X  a  US   =p4OUS:X  a  Uu  p4O	US:X  a  U=p4U R                  W5      nU R                  W5      nU R                  X4S9  gU R                  U R                  5      U R                  U R
                  5      4$ )a  Return 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')
r   r   r%  r  )rX   rB   N)rG  r  rW   r  r  r  )r   rh  r  pcolorfcolors        r   r:   
TPen.color  s    @ D	AAv"&q')a!%a"&&^^F+F^^F+FHHfH7;;t~~.DOO0LLLr   c                     U(       a1  U R                  U5      nX R                  :X  a  gU R                  US9  gU R                  U R                  5      $ )a  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   )r  r  rW   r  r  s      r   rX   TPen.pencolor  sC    : NN4(E&HHeH$;;t~~..r   c                     U(       a1  U R                  U5      nX R                  :X  a  gU R                  US9  gU R                  U R                  5      $ )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   )r  r  rW   r  r  s      r   rB   TPen.fillcolor  sC    8 NN4(E'HHuH%;;t//r   Frl  rm  rn  c                n    U R                  5       nU(       a  U R                  SS9  U R                  US9  g)zOTo be overwritten by child class RawTurtle.
Includes no TNavigator references.
Fr  N)rO   rW   )r   r   r   rm  rY   s        r   rs   TPen.teleport  s.     ++-HHUH#!r   c                 "    U R                  SS9  g)zMakes the turtle visible.

Aliases: showturtle | st

No argument.

Example (for a Turtle instance named turtle):
>>> turtle.hideturtle()
>>> turtle.showturtle()
TshownNrW   r   s    r   ro   TPen.showturtle	  s     	tr   c                 "    U R                  SS9  g)a  Makes 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  r   s    r   rL   TPen.hideturtle	  s     	ur   c                     U R                   $ )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  r   s    r   rP   TPen.isvisible	  s     {{r   c                 X   U R                   U R                  U R                  U R                  U R                  U R
                  U R                  U R                  U R                  U R                  U R                  S.nU(       d	  U(       d  U$ [        U[        5      (       a  UnO0 nUR                  U5        0 nU H	  nX6   XV'   M     U R                  (       a  U R                  R                  SU45        SnSU;   a  U R                  US   :w  a  SnSU;   aE  [        US   [         5      (       a  U R#                  US   45      US'   U R                  US   :w  a  SnSU;   a  U R                  US   :w  a  SnU(       a  U R%                  5         SU;   a
  US   U l        SU;   a
  US   U l        SU;   a
  US   U l        SU;   a:  [        US   [         5      (       a  U R#                  US   45      US'   US   U l        S	U;   a
  US	   U l        S
U;   a
  US
   U l        SU;   a)  US   n[        U[&        [(        45      (       a  X4nXl        SU;   a
  US   U l        SU;   a
  US   U l	        SU;   a
  US   U l         SU;   a
  US   U l
        SU;   d  SU;   d  SU;   ay  U R                  u  pU R                  n[*        R,                  " U R                  5      [*        R.                  " U R                  5      pX-  XU-  U-   -  U	* U-  XX-  -
  -  4U l        U R3                  5         g)a  Return 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  rY   rX   rB   rZ   rp   rb   stretchfactorrn   r  rt   rW   FrY   TrX   rZ   rB   rp   rb   r  rn   r  r  rt   N)r  r  r  r  r  r  r  r  r  r  r  r   dictr-   rI  r  r   r  _newLiner   r   r   r   r   r  r  )r   rW   pendict_pdp_p_bufr   newLinesfscxscyshfsacas                 r   rW   TPen.pen*	  s   ^ #'++"&--"&.."&//"&--"&++"&"2"2"&"5"5"&"3"3"&"4"4"&** wJc4  AA	C(FK  ??OO  %1>}}),?!J-// $*/? @*~~:.>}}),MMO>iLDM?z]DN>iLDM!!K.%00!%;0A!B+nDOa<G*DK1 Da?#B"sEl++X"$A !- 0D>!"9Da<G*DKQ;6DJa6Q;-12D**HC##CXXdjj)488DJJ+?!$"frk):!$R36k): <Dr   c                     gr  r   r   usePoss     r   r  TPen._newLine	  r  r   c                     gr  r   )r   r  forceds      r   r  TPen._update	  r  r   c                     gr  r   rg  s     r   r  TPen._color	  r  r   c                     gr  r   rg  s     r   r  TPen._colorstr	  r  r   )r  r  r  r  r  r  r  r  r  r  r  r  rI  r   r?  T)TF)#r   r   r   r   r   r   r;  r  rb   rZ   r[   rY   rO   rp   r:   rX   rB   r  rs   ro   rL   rP   rW   r  r  r  r  r{   rz   r^   rV   r>   rq   rN   r   r   r   r   r  r    s     #'|"4 
 #:.#K0'8 . $L,M\#/J"0H"5 "D "T " 
{~>>>> E	B	B	BD	B	Br   r  c                   $    \ rS rSrSrS rS rSrg)_TurtleImagei	  z6Helper class: Datatype to store Turtle attributes
    c                 @    Xl         S U l        U R                  U5        g r   )r   rC  	_setshape)r   r   
shapeIndexs      r   r;  _TurtleImage.__init__	  s    
z"r   c                 T   U R                   nXl        U R                  Ss=:X  a  UR                  U   R                  :X  a   g   U R                  Ss=:X  a  UR                  U   R                  :X  a   g   U R                  S;   a  UR	                  U R
                  5        O4U R                  S:X  a$  U R
                   H  nUR	                  U5        M     UR                  U   R                  U l        U R                  S:X  a  UR                  5       U l        g U R                  S:X  a.  UR                  UR                  S   R                  5      U l        g U R                  S:X  a=  UR                  U   R                   Vs/ s H  o2R                  5       PM     snU l        g g s  snf )Nry  r6  )r6  ry  r{  r  )	r   r  rC  r  r  _itemr  r8  r~  )r   r  r   r  s       r   r  _TurtleImage._setshape	  sR   $::FfnnZ&@&F&FF G::DFNN:$>$D$DD E::--NN4::&ZZ:%

t$ #^^J/55
::"++-DJZZ7",,V^^G-D-J-JKDJZZ:%*0..*D*J*JL*J 48,,.*JLDJ &Ls   F%)r  rC  r   r  N)r   r   r   r   r   r;  r  r   r   r   r   r  r  	  s    #
Lr   r  c                      \ rS rSrSr/ rS\S   \S   \S   4S jrS rS	 r	S
 r
S rS rS rS rS=S jrS rS rS rS=SS.S\SS4S jjjrS rS>S jrS?S jrS>S jrS>S jrS rS@S jrS rS  rSAS! jrS" rS# r S$ r!S% r"S>S& jr#S' r$S( r%S) r&SBS* jr'S+ r(S, r)S- r*S>S. jr+S/ r,SCS0 jr-S1 r.S2 r/S3 r0S4 r1S5 r2\2r3S>S6 jr4SDS7 jr5SDS8 jr6SDS9 jr7S: r8S; r9\r:S<r;g)Er   i	  zjAnimation part of the RawTurtle.
Puts RawTurtle upon a TurtleScreen and provides tools for
its animation.
Nrk   r   r   c                 $   [        U[        5      (       a  Xl        O[        U[        5      (       a:  U[        R
                  ;  a  [        R
                  R                  U5        Xl        O[        U[        [        45      (       ai  [        R
                   H  nUR                  U:X  d  M  XPl          OJ   [        U5      U l        [        R
                  R                  U R                  5        O[        SU-  5      eU R                  n[        R                  XR                  5       5        [        R                  U 5        UR                  R                  U 5        UR!                  5       U l        [%        XR5      U l        S U l        SU l        S =U l        U l        X@l        SU l        UR!                  5       U l        U R6                  /U l        U R4                  /U l        / U l        X0l        [A        U5      U l!        U RE                  5         g )Nzbad canvas argument %sF)#r   _Screenr   r	   r   screensr  r   r>  r  rv  rB  r;  r   r  r  r  drawingLineItemr  r   _poly_creatingPoly	_fillitem	_fillpathr  _hidden_from_screencurrentLineItemrL  currentLiner  
stampItems_undobuffersizer  rI  r  )r   canvasrk   r   r   r   s         r   r;  RawTurtle.__init__	  s    fg&& K--Y...!!((0 K 899#++99&"(K ,
 +62!!((5%&>&GHHD++-0dt$%113"61
"*..#( %113 NN+**+
-!.1r   c                     [         R                  U 5        [        R                  U 5        U R	                  5         U R                  5         U R                  5         g)at  Delete 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)rB  ra   r  r  _clearr  r  r   s    r   ra   RawTurtle.reset	
  s<    & 	Dr   c                 F    Ub  US::  a  SU l         g[        U5      U l         g)aZ  Set 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   )rI  r  )r   sizes     r   rh   RawTurtle.setundobuffer"
  s!     <419"DO%dmDOr   c                 R    U R                   c  gU R                   R                  5       $ )zReturn count of entries in the undobuffer.

No argument.

Example (for a Turtle instance named turtle):
>>> while undobufferentries():
...     undo()
r   )rI  r  r   s    r   ry   RawTurtle.undobufferentries5
  s$     ??"**,,r   c                    S=U l         U l        U R                   H  nU R                  R	                  U5        M      U R                  R                  5       U l        / U l        U R                  (       a%  U R                  R                  U R                  5        U R                  /U l        U R                  5         U R                  U R                  5        g)zDelete all of pen's drawingsN)r   r!  r  r   r  r  r#  r$  r  r  rL  r8   rh   r&  r  s     r   r*  RawTurtle._clearB
  s    *..JJDKK% #{{668==##DNN3**+
4//0r   c                 D    U R                  5         U R                  5         g)a/  Delete 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)r*  r  r   s    r   r6   RawTurtle.clearP
  s     	r   c                 .   U R                   R                  5         U R                   R                  S:w  a  g [        U R                  5      S:  aG  U R                   R                  U R                  U R                  U R                  U R                  5        g g r   )	r   r  r  rG  r$  r  r#  r  r  r   s    r   r  RawTurtle._update_data_
  so    !!#;;%%*t "KK!!$"6"68H8H"&..$--A #r   c                    U R                   nUR                  S:X  a  gUR                  S:X  aL  U R                  5         U R                  5         UR	                  5         UR                  UR                  5        gU R                  5         UR                  S:X  a8  UR                  5        H  nUR                  5         M     UR	                  5         gg)z&Perform a Turtle-data update.
        r   Nr   )	r   r  r  r  r  r  r  r  r,   )r   r   r1  s      r   r  RawTurtle._updateg
  s     ??a__!NNMM&,,-$$))AMMO *  *r   c                 8    U R                   R                  X5      $ )a  Turns 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
)r   r+   )r   flagr   s      r   r  RawTurtle._tracery
  s    & {{!!$..r   c                 8    U R                   R                  U5      $ r   )r   r  rg  s     r   r  RawTurtle._color
  s    {{!!$''r   c                 8    U R                   R                  U5      $ r   )r   r  rg  s     r   r  RawTurtle._colorstr
  s    {{$$T**r   c                    [        U[        5      (       a  U$  Uu  p#nU R
                  R                  S:X  a$  X#U4 Vs/ s H  n[        SU-  5      PM     snu  p#nSUs=::  a  S::  a"  O  OSUs=::  a  S::  a  O  OSUs=::  a  S::  d  O  [	        S[        U5      -  5      eSX#U4-  $ ! [        [        4 a    [	        S[        U5      -  5      ef = fs  snf )z,Convert colortriples to hexstrings.
        r  r   r  r   r  r  r  )r   r  r  r   rv  r   r  r  )r   rh  r   r  r  r   s         r   _ccRawTurtle._cc
  s     dC  K	MGA! ;;!!S(01ay9y!uU1W~y9GA!a3Q!]s]a3%&>T&JKK!** :& 	M%&?#d)&KLL	M :s   B) C)(CFrl  rm  rn  c                z   U R                  5       nU R                  5       nU(       a  U R                  SS9  U(       a  U(       d  U R                  5         Ub  UOU R                  S   nUb  UOU R                  S   n[        Xg5      U l        U R                  US9  U(       a  U(       d  U R                  5         ggg)ar  Instantly move turtle to an absolute position.

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

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

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

Example (for a Turtle instance named turtle):
>>> tp = turtle.pos()
>>> tp
(0.00,0.00)
>>> turtle.teleport(60)
>>> turtle.pos()
(60.00,0.00)
>>> turtle.teleport(y=10)
>>> turtle.pos()
(60.00,10.00)
>>> turtle.teleport(20, 30)
>>> turtle.pos()
(20.00,30.00)
Fr  Nr   r   )rO   rC   rW   r?   rL  r   r2   )r   r   r   rm  rY   was_fillingrp  rq  s           r   rs   RawTurtle.teleport
  s    F ++-llnHHUH#xMMO]q(9]q(9u,!xOO  (;r   c                 v   U R                   nU R                  U R                  5        U R                  nSU l         SU l        [	        U 5      nXl         X l        Xl         [        XR                  R                  5      Ul        UR                  R                  U5        UR                  U R                  R                     R                  nUS:X  a   UR                  5       UR                  l        OUS:X  a8  UR                  UR                  S   R                  5      UR                  l        O`US:X  aZ  UR                  U R                  R                     R                   Vs/ s H  oQR                  5       PM     snUR                  l        UR                  5       Ul        UR#                  5         U$ s  snf )zCreate 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()
Nry  r6  r  r{  )r   r  r  r   r   r  r  r  r  r  rC  r  r  r8  r~  r  r#  r  )r   r   r   qttyper  s         r   r9   RawTurtle.clone
  sM    dmm$TN(>(>?q!t{{556<<I#//1AHHNg#001H1N1NOAHHNj $nnT[[-C-CDJJLJ 8<002JLAHHN"..0				Ls   $F6c                     Uc  U R                   R                  $ XR                  R                  5       ;  a  [	        SU-  5      eU R                   R                  U5        U R                  5         g)ag  Set 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'
NzThere is no shape named %s)r   r  r   r   rv  r  r  )r   r  s     r   rk   RawTurtle.shape
  sX    ( <;;))){{,,..%&BT&IJJd#r   c                 (   Xs=L a	  Us=L a  c  O  OU R                   u  pXU R                  4$ US:X  d  US:X  a  [        S5      eUb  Uc  X4nO%X4nO!Ub  U R                   S   U4nOU R                   nUc  U R                  nU R                  SXCS9  g)a  Set/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)
Nr   z(stretch_wid/stretch_len must not be zeror  )rb   r  r  )r  r  rv  rW   )r   stretch_widstretch_lenr  r  s        r   rl   RawTurtle.shapesize  s    * 888'+':':$KT-?-???!{a/%&PQQ"" + 8 + 8$ //2K?M //M?((GF, 	 	?r   c                 B    Uc  U R                   $ U R                  SUS9  g)aN  Set 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
Nr  )rb   rn   )r  rW   )r   shears     r   rn   RawTurtle.shearfactor>  s%    & =$$$F6r   c                 D   UcI  [         R                  " U R                  5      * U R                  -  nX R                  -  U R
                  -  $ U* U R                  -  U R                  -  n[         R                  " U5      [         R                  -  nU R                  SUS9  g)a  Set 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).

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)
Nr  )rb   rt   )	r   r;   r  rH  rU  rR  r_   r]  rW   )r   r   rt   s      r   ru   RawTurtle.tiltangleU  s    8 =LL,,t/@/@@D---1A1AAA6D...1B1BBD<<%0DHHTH2r   c                 F    U R                  XR                  5       -   5        g)al  Rotate 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)ru   re  s     r   rt   RawTurtle.tilty  s    " 	u~~//0r   c                    Xs=L a  Us=L a  Us=L a  c   U R                   $   U R                   u  pVpxUb  UnUb  UnUb  UnUb  UnX-  X#-  -
  S:X  a  [        S5      eXVXx4U l         [        R                  " U* U5      [        R                  -  n	[        R
                  " U	5      [        R                  " U	5      pX-  X-  -
  X-  X-  -
  X-  X-  -   X-  X-  -   4u  ppX4U l        X-  U l        Xl	        U R                  SS9  g)aZ  Set 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)
Nr   z0Bad shape transform matrix: must not be singularr  r  )r  rv  r   r  r]  r   r   r  r  r  rW   )r   t11t12t21t22m11m12m21m22alfar  r  a11a12a21a22s                   r   rm   RawTurtle.shapetransform  s   ( +++### ,!--#?#C?#C?#C?#C9sy A%%&XYYc/zz3$$txx/$$B frvorv frvorv@#!hG
F#r   c           	      ^   U R                   nU R                  u  p4U R                  u  pV[        XVUR                  -  UR
                  -  5      nS[        U5      -  U-  u  pVU VV	s/ s H8  u  pX6U-  XY-  -   UR
                  -  -   XE* U-  Xi-  -   UR                  -  -   4PM:     sn	n$ s  sn	nf )z\Computes transformed polygon shapes from a shape
according to current position and heading.
r   )r   rL  rN  r   r  r  r  )
r   r  r   p0p1e0e1er   r   s
             r   
_polytrafoRawTurtle._polytrafo  s     "6==(6==89A,!#IMOIMv T"$Y--r3q5:v}}2L/LMIMO 	O Os   &?B)c                     U R                   R                  U R                  R                     nUR                  S:X  a)  U R                  UR                  UR                  S:H  5      $ g)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))

ry  r{  N)r   r  r   r  rC  _getshapepolyr~  )r   rk   s     r   rH   RawTurtle.get_shapepoly  sS     ##DKK$:$:;;;)#%%ekk5;;*3LMM $r   c                   ^^^^ U R                   S:X  d  U(       a  U R                  u  mmmmOGU R                   S:X  a%  [        SU R                  S-  5      nUSSU4u  mmmmOU R                   S:X  a  U$ [	        UUUU4S jU 5       5      $ )zPCalculate transformed shape polygon according to resizemode
and shapetransform.
r  r  r   g      @r   r   c              3   T   >#    U  H  u  pTU-  TU-  -   TU-  TU-  -   4v   M     g 7fr   r   )r  r   r   rX  rY  rZ  r[  s      r   r  *RawTurtle._getshapepoly.<locals>.<genexpr>  s0     J'c!ec!emSUSU]3's   %()r  r  maxr  r   )r   ry  r{  r  rX  rY  rZ  r[  s       @@@@r   ro  RawTurtle._getshapepoly  s     v%!%!1!1Cc3'At}}S()A!"Aq!Cc3+NJ'JJJr   c           
         U R                   nUR                  U R                  R                     nUR                  nU R                  R
                  nU R                  (       Ga`  UR                  S:X  GaO  UR                  S:  Ga>  SU l	        UR                  nUS:X  a  U R                  S:X  a  SnO)U R                  S:X  a  U R                  nOU R                  nU R                  U R                  U5      5      nU R                   U R"                  pUR%                  XBXxUSS9  gUS	:X  a  UR'                  X@R(                  U5        gUS
:X  au  [+        XE5       He  u  n	u  pnU R                  U R                  U
S5      5      n
UR%                  XU R-                  U5      U R-                  U5      U R                  SS9  Mg     ggU R                  (       a  gUS:X  a  UR%                  USSS5        O]US	:X  a4  UR'                  X@R(                  UR                  S   R                  5        O#US
:X  a  U H  n	UR%                  U	SSS5        M     SU l	        g)zhManages the correct rendering of the turtle with respect to
its shape, resizemode, stretch and tilt etc.r   Fry  r   r   r  Tr  r  r{   r  r6  r{  Nr  r  r  r   r  )r   r  r   r  rC  r  r  r  r  r"  r~  r  r  r  rl  ro  r  r  r  r<  rL  ziprA  )r   r   rk   rH  titemtshaper  fcocr  r  s              r   r  RawTurtle._drawturtle  s
    t{{556!!;;;600A5&//A:M',D$[[F	!##z1q1%%/T]]++a(:(:6(BC$..B  B<=4 ! I'!!!%@*$,/,>(D.4R??4+=+=dD+IJD$$Tdhhrl-1XXb\ASASY] % _ -? % ''	!  (@"bI'!!!%*0..*A*G*GI*$!D$$T+CRL "'+D$r   c           
         U R                   nUR                  U R                  R                     nUR                  nUR
                  nUS:X  a  UR                  5       nU R                  S:X  a  SnO)U R                  S:X  a  U R                  nOU R                  nU R                  U R                  U5      5      nU R                  U R                  pUR                  XRXxUSS9  OUS:X  a.  UR                  S5      nUR!                  XPR"                  U5        OUS	:X  a  / nU H$  n	UR                  5       n
UR%                  U
5        M&     ['        U5      n[)        XT5       He  u  n
u  pnU R                  U R                  US5      5      nUR                  XU R+                  U5      U R+                  U5      U R                  SS9  Mg     U R,                  R%                  W5        U R.                  R1                  S
U45        U$ )au  Stamp 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)
ry  r   r   r  Trw  r6  r   r{  rr   )r   r  r   r  rC  r~  r  r  r  r  rl  ro  r  r  r  r8  r<  rL  r  r   ry  rA  r%  rI  r  )r   r   rk   rH  r{  stitemr  r|  r}  elementr  r  s               r   rr   RawTurtle.stamp  s    t{{556I'')F:-1q!!V+Q''!OOD$6$6v$>?E__dnnV89t  Eg((,Ffnnf=j F!))+d# " 6]F(+F(;$ntt'9'9$'EF  $((2,)-"T=O=OUY ! [ )< 	v&gv./r   c                 |   XR                   ;   ap  [        U[        5      (       a%  U H  nU R                  R	                  U5        M      OU R                  R	                  U5        U R                   R                  U5        SU4nU R                  nX4R                  ;  a  gUR                  R                  U5      nUR                  R                  U5        XTR                  ::  a!  UR                  S-
  UR                  -  Ul	        UR                  R                  UR                  S-   UR                  -  S/5        g)z9does the work for clearstamp() and clearstamps()
        rr   Nr   )r%  r   r   r   r  r/  rI  r  indexr  r  insert)r   stampidsubitemr  bufr  s         r   _clearstampRawTurtle._clearstamp3  s     oo%'5))&GKK''0  ' ##G,OO""7+ !oozz!

  &

$GGww{ckk1CG

37719ckk1D6:r   c                 F    U R                  U5        U R                  5         g)a  Delete 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)r  r  )r   r  s     r   r7   RawTurtle.clearstampI  s     	!r   c                     Uc  U R                   SS nO%US:  a  U R                   SU nOU R                   US nU H  nU R                  U5        M     U R                  5         g)a  Delete 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   )r%  r  r  )r   r  toDeleter  s       r   r8   RawTurtle.clearstampsX  s_    $ 9q)H!Vr*Hqr*HDT" r   c           
         U R                   U R                  U R                  [        U R                  [
        5      4nU R                  nSU R                  XU R                  U R                  SS UR                  U R                  5      U R                  SS 44nU R                  (       a  U R                  R                  U5        U R                  nU R                  (       Ga9  UR                  S:X  Ga(  X-
  nUS   UR                   -  S-  US   UR"                  -  S-  -   nS[%        US-  SSU R                  -  -  U R                  -  -  5      -   nUS	U-  -  n	['        SU5       Hy  n
U
S:X  a  S
nOSnXYU
-  -   U l        U R                   (       a>  UR)                  U R*                  XPR                  4U R                  U R                  U5        U R-                  5         M{     U R                   (       a&  UR)                  U R*                  SSU R                  S9  U R                   (       a  U R                  R/                  U5        [        U R                  [
        5      (       a  U R                  R/                  U5        Xl        U R0                  (       a  U R2                  R/                  U5        [5        U R                  5      S:  a  U R7                  5         U R-                  5         g)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.
goNr   r   r%  r   r  皙?r   TFr  r  r   r  r{   *   )r  r  r  r   r!  r   r   rL  r#  r$  rJ  r  rI  r  r  r  r  r  r   rF  r  r  r  r  r  r  rG  r  )r   rj  go_modesr   
undo_entrystartdiffdiffsqnhopsdeltar  r  s               r   r`  RawTurtle._gotot  sW    ]]^^]]57 DNNC++&&q)''(<(<=jjm%
 ??OO  ,;;;6??a/ID1gfmm+a/476==3H12LLFc63;C,<)=dkk)IJKKECI&E1e_6CC!&!2==$$T%9%9&+^^%<%)^^T]]CI  % }}  !5!57G46dmm ! M ==##C(dnnd++NN!!#&JJc"t 2%MMOr   c                    Uu  p#pEUu  pgpUu  ppU R                   n[        U R                  U-
  5      S:  a  [        S5        Xl        Xl        USS/:X  a  SnOUnUR                  XXS9  U R                   Vs/ s H$  nUU;  d  M  UR                  U5      S:X  d  M"  UPM&     nnU H/  nUR                  U5        U R                  R                  U5        M1     UnU R                  (       Ga  UR                  S:X  a  X#-
  nUS   UR                  -  S	-  US   UR                  -  S	-  -   nS[        US-  S
SU R                  -  -  U R                  -  -  5      -   nUSU-  -  n[!        SU5       H\  nUS:X  a  SnOSnUUU-  -   U l        U(       a*  UR                  U R"                  UU R                  4XxU5        U R%                  5         M^     U(       a  UR                  U R"                  SSUS9  X l        U R&                  (       aQ  [)        U R*                  5      S:  a  U R*                  R-                  5         U R*                  / :X  a  SU l        SU l        U	(       aJ  U R.                  / :X  a  SU l        [        S5        O'U R.                  b  U R.                  R-                  5         U R%                  5         gs  snf )z)Reverse a _goto. Used for undo()
        r   z$undogoto: HALLO-DA-STIMMT-WAS-NICHT!r  r   r  r   r   r   r%  r  r  r   TFr  NzUnwahrscheinlich in _undogoto!)r   r  rL  r   r#  r$  r  r  rC  r  r/  r  r  r  r  r   rF  r  r  r  rG  r  r  r!  )r   entryoldnewr  coodatadrawingpcpsrC   cLIcLrI  r  r   usepcrH  todeleter  r  r  r  r  r  r  s                            r   	_undogotoRawTurtle._undogoto  s    ',#(#+ R$t~~#$s*9:"&&!!EEu7#zz Dz!aunA(.Q6(A z DANN1JJa   ;;;6??a/9D1gfmm+a/476==3H12LLFc63;C,<)=dkk)IJKKECI&E1e_6CC!$uqy$$T%9%9&+T^^%<%'S2  %   !5!57G46b ! B 
 4::"

 zzR%*"!
~~#!%67+""$YDs   :
KKKc                 0   U R                   (       a'  U R                   R                  SXR                  45        XR                  -  nU R                  R	                  U5      nU R
                  R                  nUS:X  a  U R                  S:  as  SU R                  -  nS[        [        U5      U-  5      -   nSU-  U-  n[        U5       H3  nU R                  R	                  U5      U l        U R                  5         M5     X l        U R                  5         g)z&Turns pen clockwise by angle.
        rotr   r   g      @r   N)rI  r  rU  rN  r   r   r  r  r   r  rF  r  )r   r   	neworientr  anglevelr  r  r  s           r   rf  RawTurtle._rotate  s     ??OO  %0B0B!CD###LL''.	++&&a<DKK!OT[[(HCJx/00EIeOE5\#||2259 " !r   c                    [        U R                  5      S:  a  U R                  R                  U R                  U R                  U R
                  U R                  5        U R                  R                  5       U l        U R                  R                  U R                  5        O$U R                  R                  U R                  SS9  / U l        U(       a  U R                  /U l        gg)zCloses current line item and starts a new one.
Remark: if current line became too long, animation
performance (via _drawline) slowed down considerably.
r   T)r  N)rG  r$  r   r  r#  r  r  r  r  r  rL  r  s     r   r  RawTurtle._newLine  s    
 t 1$KK!!$"6"68H8H&*nndmmE#';;#:#:#<D JJd223KK!!$"6"6D!A $/D r   c                 6    [        U R                  [        5      $ )zReturn 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)
)r   r!  r   r   s    r   rC   RawTurtle.filling  s     $..$//r   c                    U R                  5       (       dD  U R                  R                  5       U l        U R                  R                  U R                  5        U R                  /U l        U R                  5         U R                  (       a'  U R                  R                  SU R                  45        U R                  5         g)zCalled 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)rC   r   r  r   r  r  rL  r!  r  rI  r  r  r   s    r   r2   RawTurtle.begin_fill  s{     ||~~![[446DNJJdnn-..)??OO  +t~~!>?r   c                    U R                  5       (       a  [        U R                  5      S:  aq  U R                  R	                  U R
                  U R                  U R                  S9  U R                  (       a'  U R                  R                  SU R
                  45        S=U l        U l        U R                  5         gg)zFill 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()
r%  r  dofillN)
rC   rG  r!  r   r  r   r  rI  r  r  r   s    r   r?   RawTurtle.end_fill/  s     <<>>4>>"Q&%%dnndnn+/?? & <??OO(((DNN)CD.22DNT^LLN r   c                    U(       d  [        U[        [        45      (       a5  U R                  U5      nU R                  [        U R                  S5      -   nOnU R                  nU(       d#  U R                  [        U R                  S5      -   nO7Uc#  U R                  [        U R                  S5      -   nU R                  U5      nU R                  5       nU R                  (       a-  U R                  R                  S/5        SU R                  l
         U R                  5       S:X  a  U R                  5         U R                  5         U R                  U5        U R                  U5        U R!                  S5        U R                  U5        U R                  (       a  SU R                  l
        gg! U R                  U5        f = f)a  Draw 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)
r  Nr  Tr  r   F)r   r  r   r  r  rt  r  rW   rI  r  r  rb   rN   rY   rZ   rX   rD   )r   r-  r:   rW   s       r   r=   RawTurtle.dotC  s>    $e--t,}}s4==!'<<==3t}}a+@@D|}}s4==!'<<NN5)Ehhj??OO  %)'+DOO$	 F*	LLNLLMM% LLOHHSM??',DOO$  HHSMs   A'F1 1Gc                     U R                   R                  U R                  XUU R                  5      u  pEU R	                  5         U R
                  R                  U5        U R                  (       a  U R                  R                  SU45        U$ )z)Performs the writing for write()
        wri)	r   r  rL  r  r  r  r  rI  r  )r   r  r  r  r  rj  s         r   r  RawTurtle._writen  si     KK&&t~~s4:>..J	

$??OO  %/
r   c                 n   U R                   (       a-  U R                   R                  S/5        SU R                   l        U R                  [	        U5      UR                  5       U5      nU(       a#  U R                  5       u  pgU R                  XW5        U R                   (       a  SU R                   l        gg)a  Write 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)rI  r  r  r  r  r|  r\   rf   )r   argmover  r  rj  r   r   s           r   r|   RawTurtle.writey  s{    & ??OO  %)'+DOO$kk#c(EKKM4888:DAKK??',DOO$ r   c                 6    U R                   /U l        SU l        g)zStart 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)rL  r  r  r   s    r   r3   RawTurtle.begin_poly  s     nn%
!r   c                     SU l         g)a  Stop 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)r  r   s    r   r@   RawTurtle.end_poly  s     #r   c                 H    U R                   b  [        U R                   5      $ g)zReturn the lastly recorded polygon.

No argument.

Example (for a Turtle instance named turtle):
>>> p = turtle.get_poly()
>>> turtle.register_shape("myFavouriteShape", p)
N)r  r   r   s    r   rE   RawTurtle.get_poly  s"     ::!$$ "r   c                     U R                   $ )aP  Return 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")
)r   r   s    r   rG   RawTurtle.getscreen  s     {{r   c                     U $ )a  Return 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>]
r   r   s    r   rI   RawTurtle.getturtle  s	     r   c                 8    U R                   R                  U5      $ )zDSet delay value which determines speed of turtle animation.
        )r   r   r  s     r   r  RawTurtle._delay  s     {{  ''r   c                     U R                   R                  U R                  R                  XU5        U R	                  5         g)aQ  Bind 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)r   r  r   r  r  r,  s       r   rS   RawTurtle.onclick  s-    $ 	T[[..#>r   c                     U R                   R                  U R                  R                  XU5        U R	                  5         g)aw  Bind 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)r   r  r   r  r  r,  s       r   rU   RawTurtle.onrelease   s-    , 	t{{00#C@r   c                 f    U R                   R                  U R                  R                  XU5        g)a2  Bind 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)r   r  r   r  r,  s       r   rT   RawTurtle.ondrag  s$    $ 	DKK--s=r   c                    U R                   c  gUS:X  aA  Uu  p4U R                  U* U-  U R                  -  5        U R                   R                  5       ngUS:X  a  US   nU R	                  U5        gUS:X  a  U R                  U5        gUS;   a<  US   nU R                  R                  U5        U R                  R                  U5        gUS:X  a"  US   nU R                  R                  USS	S	S
9  gUS:X  aZ  US   nS=U l        U l        XpR                  ;   a7  U R                  R                  U5        U R                  R                  U5        ggUS:X  a3  [        R                  XS   5        U R                   R                  5         gg)z2Does the main part of the work for undo()
        Nr  rr   r   r  )r  r=   r  rx  r   r  r  rW   )rI  rf  rU  r  r7   r  r   r  r  r/  r  r   r!  r  rW   )r   actionr  r   degPAUdummyr  r  s           r   _undoRawTurtle._undo.  se    ??"U? MELL%t'9'99:OO'')Ew!WFOOF#t^NN4 ~%7DKK%JJd#x7DKK!!$(>')2 " 7{"7D.22DNT^zz!##D)

!!$' " u_HHT7#OO! r   c                 
   U R                   c  gU R                   R                  5       nUS   nUSS nUS:X  a:  U(       a2  UR                  5       nU R                  US   USS 5        U(       a  M1  ggU R                  X#5        g)aQ  undo (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()
...
Nr   r   r  )rI  r  r  )r   r  r  r  s       r   rx   RawTurtle.undoN  sy    " ??"""$aABxU?xxz

47DH- $ JJv$r   )r  r   r!  r"  rN  r  rL  r  r  r  r  r  r&  r$  r#  r  r  r   r%  r   rI  r?  r   r|  )NNNN)Fr  )FrQ   )Arialr  r  rr  )<r   r   r   r   r   r  r   r;  ra   rh   ry   r*  r6   r  r  r  r  r  rA  r  rs   r9   rk   rl   rn   ru   rt   rm   rl  rH   ro  r  rr   r  r7   r8   r`  r  rf  r  rC   r2   r?   r=   r  r|   r3   r@   rE   rG   rI   rF   r  rS   rU   rT   r  rx   rw   r   r   r   r   r   r   	  sP    G"G} $%5 6i&P2,&-1A!$/*(++.5 .D .T .`&P6&?P7."3H1&%$P
ON"K$,P+Z;,83j?B$0 0*()-V	-:"#% " F(
*2>*"@%: Jr   r   c                  j    [         R                  c  [        5       [         l        [         R                  $ )zReturn the singleton screen object.
If none exists at the moment, create a new one and return it,
else return the existing one.)r   _screenr  r   r   r   r
   r
   q  s!     ~~ >>r   c                   n    \ rS rSrSrSr\S   rS r\S   \S   \S   \S   4S	 jr	S
 r
S rS rS rSrg)r  iy  Nr*   c                 p   [         R                  ch  [        5       =[         l        U l        U R                  R                  [         R                  5        U R                  R                  U R                  5        [         R                  c  [        S   n[        S   n[        S   n[        S   n[        S   n[        S   nU R                  R                  XX45        U R                  R                  5       [         l        [        R                  U [         R                  5        U R                  XXV5        g g )Nr{   r   r   r   r   r   )r  _rootr~  r*   _titler  _destroyr@  r   r  r  r	   r;  r'   )r   r{   r   r   r   r   r   s          r   r;  _Screen.__init__  s    == ).0GMDJJJW^^,JJ  /??"ME(^F[)Il+J[)I[)IJJ""5)H"jj335GO!!$8JJui; #r   r{   r   r   r   c                    [        U R                  S5      (       d  gU R                  R                  5       nU R                  R                  5       n[	        U[
        5      (       a  SUs=::  a  S::  a  O  OXQ-  nUc  XQ-
  S-  n[	        U[
        5      (       a  SUs=::  a  S::  a  O  OXb-  nUc  Xb-
  S-  nU R                  R                  XX45        U R                  5         g)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
r  Nr   r   r%  )hasattrr  r  r  r   r   r  r-   )r   r{   r   r  r  r  shs          r   r'   _Screen.setup  s    2 tzz>22ZZ!!#ZZ""$eU##UaHE>jA%Ffe$$f)9)9YF>kQ&F

v>r   c                 z    [         R                  b  [         R                  R                  U5        U[         l        g)a1  Set 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)r  r  r*   r  )r   titlestrings     r   r*   _Screen.title  s'     ==$MM,$r   c                     U R                   nU[        R                   L a,  S [        l        S [        l        S [        l         S [        l        S[        l        UR                  5         g )NF)	r  r  r   r  r  r@  r	   r  r  )r   roots     r   r  _Screen._destroy  sD    zz7== FK!FN GM"GO %r   c                 $    U R                  5         g)zfShut the turtlegraphics window.

Example (for a TurtleScreen instance named screen):
>>> screen.bye()
N)r  r   s    r   r   _Screen.bye  s     	r   c                    ^  U 4S jnT R                  U5        [        S   (       a  g [        5         g! [         a    [	        S5         gf = f)a  Go into mainloop until the mouse is clicked.

No arguments.

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

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

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

c                 &   > TR                  5         g)z&Screen.bye() with two dummy-parametersN)r   )r   r   r   s     r   exitGracefully+_Screen.exitonclick.<locals>.exitGracefully  s    HHJr   r   Nr   )rS   r   r   AttributeErrorexit)r   r  s   ` r   r   _Screen.exitonclick  sA    &	 	^$	J 	G	s   
4 AA)r  )r   r   r   r   r  r@  r   r  r;  r'   r*   r  r   r   r   r   r   r   r  r  y  sR    EG']F<" w-X+&tK/@&P%"r   r  c                   B    \ rS rSrSrSrSr\S   \S   \S   4S jrSr	g)	r   i  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.
Nrk   r   r   c                     [         R                  c  [        5       [         l        [        R	                  U [         R                  UUUS9  g )N)rk   r   r   )r   r  r
   r   r;  )r   rk   r   r   s       r   r;  Turtle.__init__  s;     >>!#XFN4!&*8#* 	 	,r   r   )
r   r   r   r   r   r  r  r   r;  r   r   r   r   r   r     s1    
 DG G} $%5 6i	,r   r   c                 t   0 n[          H  nSU-   n[        U5      R                  X'   M!     [         H  nSU-   n[        U5      R                  X'   M!     [	        SU -  S5       n[        S U 5       5      nUR                  S5        USS  H6  nUR                  S	[        U5      -  5        UR                  S
X   -  5        M8     US   nUR                  S	[        U5      -  5        UR                  SX   -  5        UR                  S5        UR                  5         SSS5        g! , (       d  f       g= f)a  Create 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.zTurtle.z%s.pyr  c              3   b   #    U  H%  nUR                  S 5      S   [        ;  d  M!  Uv   M'     g7f)r   r   N)r   _alias_list)r  r   s     r   r  &write_docstringdict.<locals>.<genexpr>%  s+      =Aa; as    /	/zdocsdict = {

Nr  z%s :
z        """%s
""",

z        """%s
"""

z}
)	_tg_screen_functionsr   r   _tg_turtle_functionsr   r)  r|   reprclose)r   docsdict
methodnamer   r   r  s         r   r   r     s    H*
#S	)) + +

"S	)) + 
g 	% = = =	"#9CGGHtCy()GG-=>  2h	49$%	(8=89			 
&	%	%s   $B<D))
D7c                     SSU R                  5       0-  n[        U5      nUR                  nU H  n X4   [        U5      l        M     g! [
         a    [        SU-  5         M6  f = f)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)sr   zBad docstring-entry: %sN)r|  
__import__r  r   r   r   r   )langmodnamemoduler  r   s        r   read_docstringsr  1  sh     2Z

4MMG FH	3 (DI   	3+c12	3s   A

A&%A&zCannot find docsdict forz;Unknown Error when trying to import %s-docstring-dictionaryc                    [         R                  " U 5      nUR                  [        UR                  R                  5       5      SS S9n/ nUR                  R                  5        GHK  nUR                  ==[         R                  R                  :X  a  O!=[         R                  R                  :X  a  O  O    UR                  UR                  5        Mo  =[         R                  R                  :X  a!    UR                  SUR                   35        M  =[         R                  R                  :X  a-    UR                  UR                   SUR                   35        M  [         R                  R                  :X  a!  UR                  SUR                   35        GM7   [        SUR                  5      e   SS	R!                  U5       S
3n[#        U5      U4$ )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.
r   N)
parameters*r   z**zUnsupported parameter kind(z, ))inspect	signaturereplacer   r  valueskind	ParameterPOSITIONAL_ONLYPOSITIONAL_OR_KEYWORDr  r  VAR_POSITIONALKEYWORD_ONLYVAR_KEYWORDRuntimeErrorr   r  )oborig_sigfunc_sig	call_argsparam	call_texts         r   getmethparlistr$  N  sr      $H ++2245ab9   H I$$++-jj:1!!119'##99:   ,1""11  1UZZL!12/""//  EJJ<q!=>""..  2ejj\!23"#?LL . DIIi()+Ix=)##r   c                     SSK nU c  g[        S   nU R                  SU-  S5      nUR                  SU-  5      nUR	                  SU5      nU$ )z<To reduce docstrings from RawTurtle class for functions
    r   Nr   %s.r    \(.+ %s\)::rer   r  compilesub)docstrr*  
turtlename	newdocstrparexps        r   _turtle_docreviser1  r  W     ~o&Juz1"5IZZ34F

3	*Ir   c                     SSK nU c  g[        S   nU R                  SU-  S5      nUR                  SU-  5      nUR	                  SU5      nU$ )z?To reduce docstrings from TurtleScreen class for functions
    r   Nr   r&  r   r'  r(  r)  )r-  r*  
screennamer/  r0  s        r   _screen_docreviser5  ~  r2  r   ar  def {name}{paramslist}:
    if {obj} is None:
        if not TurtleScreen._RUNNING:
            TurtleScreen._RUNNING = True
            raise Terminator
        {obj} = {init}
    try:
        return {obj}.{name}{argslist}
    except TK.TclError:
        if not TurtleScreen._RUNNING:
            TurtleScreen._RUNNING = True
            raise Terminator
        raise
c           	         U  Hz  n[        X5      n[        U5      u  pxUS:X  a  [        SXx5        M/  [        R	                  X#UXxS9n	[        U	[        5       5        U" UR                  5      [        5       U   l        M|     g )Nr   z>>>>>>)objinitr  
paramslistargslist)getattrr$  r   __func_bodyformatr  globalsr   )
	functionsr   r7  r8  	docreviser  r  pl1pl2defstrs
             r   _make_global_funcsrD    sw    
)!&)"9(C%##Z/2 $ BVWY(1&..(A	*%  r   zTurtle._screenzScreen()zTurtle._penzTurtle()__main__c                  L    [        5       (       a  [        5         g [        5         g r   )rO   r^   rV   r   r   r   	switchpenrG    s    88DDr   c                     [        5         [        S5        [        5         [        S5        [	        5         [        S5        [        S5       Hu  n U S:X  a
  [        5         [        S5       H  n[        S5        [        S5        M     U S:X  a  [        S5        [        5         [        5         [        S	5        [	        5         Mw     [        S
5        [        S5        [        S5        [        5         [        S5        [        S5        [        S5        [        S5        [        S5        [	        5         [        SS
5        [        SS
5        [        S5        [        S5       H/  n [        S5        [        S5        [        S5        [        S5        M1     [        S5        [        5         [        S5       H/  n [        S5        [        S5        [        S5        [        S5        M1     [        5         g)zDemo of old turtle.py - moduleTd   r  r%  r  r  Z   maroonrR  r   r   F   
startstartr  redr  N)ra   r+   rz   r1   r>   r{   rF  r2   rD   rQ   r:   r?   r`   r|   )rH  r  s     r   demo1rO    sJ   t
aqAAv1XR  Avh
DBKF  	agu
b	b	c
lAgqeqABKHBK"I	  	tqABKHBK"I	 
 	
r   c                  	   [        S5        [        5         [        S5        [        [	        SS5      5        [        SS5      S-  n [        S5        [        S5       H  n[        5         [        U S5        M     [        S5        [        5       (       a  [        5         [        5       (       a  M  [        5         [        S5        [        S	5        Sn[!        S
5        [        S5        [        S5        [        SS5       H  nUS:  a   [#        5         [%        S	SU-  -
  SSU-  5        [        S5       H  n['        U5        [        S5        M     [)        5         US-  n[        S5        [        [        5       S-   S-  5        M     [        S5        [+        5         ['        S5        [        S5        [-        5         [/        SS5        [        S5        [#        5         [        S5       H0  n[        SS5        [        S5        ['        S5        [        S5        M2     [)        5         [        S5        [+        5         ['        S5        [-        5         [1        S5        [3        5       nUR5                  S5        [7        5       nUR5                  S5        UR1                  S5        UR                  5         UR9                  S5        UR                  S5        UR;                  5         UR=                  SS5        UR                  S5        UR?                  5         UR                  S5        UR/                  SS5        UR                  S5        UR                  S5        [        [	        U5      5        SnUR                  U5      S:  a  UR'                  S5        UR                  S 5        UR                  UR	                  U5      5        UR'                  S5        US!-  S:X  a*  URA                  5         URA                  5         [        5         US-  nUR                  U5      S:  a  M  UR                  S"S#S$S%9  UR!                  S&5        UR!                  S5        S' n[B        RD                  " S5        [        5       (       a1  UR                  5         UR                  5         [        5       (       a  M1  UR'                  S5        UR                  S(S)S*9  URG                  US5        g+),zDemo of some new features.r   r  r   r  rJ     r   zwait a moment...r  greenrL  r  r     x      F   rR  rN  yellowr  2   r   r  i  (   r  blueoranger%  g      @g333333?r  zCAUGHT! )r  r  boldr`   )r  r  r   c                 ,    [        5         [        5         g r   )r   r   )r5  r6  s     r   babademo2.<locals>.babaD  s    MEr   z  Click me!)CourierrU  r\  )r  N)$rp   rq   rZ   re   rv   r<   rc   rF  rG  r5   r|   ry   rx   ra   rR   r   rX   r2   rB   rA   r?   r^   rV   r:   rk   rI   rb   r   rQ   rz   rJ   r>   rr   timesleeprS   )r  r  laengerH  trir   r  r^  s           r   demo2re    s   a

71a=!!Q#
2rAK62  	 !!!F  !!
2#

3r2A1u#bd(Ar!t,1X6
3  JbLFrF5719b.!  	3

2
2
eHaqA2rNrFrFrF	 
 	

2

2
hkv&!XBQ		C		"QVH%q		!76?#ll6"Q&IIcNIIcNNN3;;v./FF1IrzQ		QJE ll6"Q& 			*#8	HWU	 	

1!!HHJKKM  !! 	r
		-(?	AD!r   )r   )turtle_docstringdict)Gr   tkinterr9  ImportErrormsgr  r  r   ra  r  r  os.pathr   r   r   copyr   r   _tg_classesr  r  _tg_utilities__all__r  r   r   r   r   r   r   r   r  r  r  r!  r:  r   r>  r  r~  objectr  r   rv  r   r  r	   rB  r  r  r   r   r
   r  r   r   r   r  	_LANGUAGEr$  r1  r5  r<  rD  r   r   r   rG  rO  re  r   r   r   r   <module>rq     s  0KZL     
 ' '   I) !  '/--0DD(>*,	# 	4	c	 	c	 	T		
 	T	 	
	 	S	 		 	$	 		 	W	 	g	 	z	 	D	 	I	  	!	" ")'	,:<1t
*$E *$j1 .*a#RXX a#F I 6)BEE )0 
B5v B5T	) 	) 
,1F ,1^"6f "6Li# iVC CLR6 RjL6 L>Qj Qf$ 
~l ~@,Y ,(  D3" 	MI	""$H

  
B '#Z1BD ' *.?A z2jaF 
G	GMC Wz  L
c#h!JJ
KKL|  1	/01Ds  1	
$i0 M	HBKL MMsA   G7 H H+ 7H=HHH('H(+I<II