e?7dSrSSKrSSKrSSKrSSKrSSKrSSKrSSKJ r J r J r SSK J r SSKJr /SQr/SQr/SQrS S /r\\-\-\-S /-r/S Qr0S S_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS _S!S"_S#S"_S$S%_S&S'_S(S)_S*S+_S,S-S.S/.ErS0rS1r\"\5 "S3S4\5rS5rS6rS7rSgS8jr"S9S:\R@5r!\"\!\RDS;5 "S<S=\RF5r$\RDr""S>S?\%5r&"S@S \5r'"SASB\5r("SCSD\%5r)"SESF\%5r*"SGSH\&5r+"SISJ\%5r,"SKSL\%5r-"SMSN\%5r."SOSP\-\,5r/\/r0SQr1"SRSS\+5r2"STSU\/5r3\3r4ShSVjr5SWr6\S(r7\7S):wa\6"\75 SZr9S[r:S\r;S]r[USUS-USUS-5$Nrrselfothers r__add__ Vec2D.__add__)T!WU1X%tAwuQx'788rc[U[5(aUSUS-USUS--$[USU-USU-5$r) isinstancerrs r__mul__ Vec2D.__mul__sQ eU # #758#DGE!H$44 4T!WU]DGEM22rc[U[5(d[U[5(a[USU-USU-5$[$r)rrrrNotImplementedrs r__rmul__Vec2D.__rmul__s> eS ! !Zu%=%=aQ 6 6rc>[USUS- USUS- 5$rrrs r__sub__ Vec2D.__sub__rrc*[US*US*5$rrrs r__neg__ Vec2D.__neg__sd1gXQx((rc([R"U6$r)mathhypotrs r__abs__ Vec2D.__abs__szz4  rc[US*US5n[R"U5n[R"U5[R"U5pC[USU-USU--USU-USU--5$)z.rotate self counterclockwise by angle rr)rrr_cossin)rangleperpcss rrotate Vec2D.rotatesvd1gXtAw' U#xx1T!WQYtAwqy($q'!)DGAI*=>>rcUSUS4$rrs r__getnewargs__Vec2D.__getnewargs__ sQa!!rc SU-$)Nz (%.2f,%.2f)rrs r__repr__Vec2D.__repr__s t##rrN)__name__ __module__ __qualname____firstlineno____doc__rrrrrrrrrr__static_attributes__rrrrrs9 *939)!?"$rrc[UR5nUR5 UHn[X15 M URR 5H(upE[ U5[R:XdM$XQU'M* g)#helper function for Scrolled CanvasN) list __bases__reverse __methodDict__dict__itemstypetypes FunctionType)r_dictbaseList_superrrs rrrs`CMM"H V#ll((*  ;%,, ,#J+rc<0n[X5 UR5$)r)rkeys)rrs r __methodsr %s E ::<rzTdef %(method)s(self, *args, **kw): return self.%(attribute)s.%(method)s(*args, **kw)c\0n[X5 0n[U5nUR5H'nUSSS:XdUSSS:Xd Xs;dXv;aM!XGXW'M) UR5HCupXS.n [ U[ 5(a [ XS.-n [W U 5 [XX5 ME g)Nr_)methodfunc)r attribute) rr r rrstr __stringBodyexecsetattr) fromClasstoClasstoPartexclude_dict_1rmfcexrrd execStrings r__forwardmethodsr!/sG" E I Clln bq6S=BrsGsNbmry  EI    , fc " "6HH  Z 19- &rc`\rSrSrSrSSjrSSjrSrSrSr S r S r S r S r S rSrg)riDzModeled 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 [RRXX#S9 UR5UlX#sUlUlXEsUlUlSUl [R"XUUR[RSS9Ul [R"XRR[RS9Ul[R"XRR"S9UlURR'UR R(UR$R(S9 UR+SS SS 9 UR-SS SS 9 URR/S US SSS S S S 9 UR$R/S US SS S S S S 9 UR R/S US S SS S S S 9 UR15 URR3S UR45 g)N)r{rwhite)r{rbgrelief borderwidth)commandorient)r))xscrollcommandyscrollcommandrr)weightminsizenewspadxin_padyrowcolumnrowspan columnspanstickyz )TKFrame__init__winfo_toplevel _rootwindowr{rrrr&CanvasSUNKEN_canvas Scrollbarxview HORIZONTALhscrollyviewvscroll configureset rowconfigurecolumnconfiguregridrabindonResize)rmasterr{rrrs rr;ScrolledCanvas.__init__Js $eC..0"' DK*3'yyV$(GGBII1N ||FLL4F4F+-==: ||FLL4F4FG  dll.>.>.2ll.>.>  @ !Aq1 Qq!4 q1!!&  B q1!!&  B q1!!&  B  mT]];rNc.U(aXlU(aX lU(aX0lURR UUR*S-UR*S-URS-URS-4S9 URR SURUR - S--UR- 5 URRSURUR- S--UR- 5 UR5 g)zBoo#N O rc rURR5nURR5nURRSURU- -UR- 5 URR SUR U- -UR - 5 XR:dX R :aAURRSUSSSSSSS9 URRSUSSSSSSS9 gURR5 URR5 g)z@Adjust scrollbars according to window- and canvas-size. rrrr/r0N) r@ winfo_width winfo_heightrTrrUrrDrKrF grid_forget)rcwidthcheights rrVScrolledCanvas.adjustScrollsus))+,,++- !!#t~~f'<"=dnn"LM !!#tw'>"?"OP NN "g&? LL  1Dqa%&a  P LL  1Dqa%&a  P LL $ $ & LL $ $ &rc$UR5 g)zself-explanatoryN)rV)revents rrMScrolledCanvas.onResizes rc4URR"U6$?'forward' method, which canvas itself has inherited... )r@bboxrargss rrfScrolledCanvas.bboxs||  $''rc:URR"U0UD6$rd)r@cgetrrhkwargss rrkScrolledCanvas.cgets||  $1&11rc<URR"U0UD6 greN)r@rSrls rrSScrolledCanvas.config T,V,rc<URR"U0UD6 grp)r@rLrls rrLScrolledCanvas.binds 4*6*rc<URR"U0UD6 grp)r@unbindrls rrvScrolledCanvas.unbindrrrc8URR5 grp)r@ focus_forcers rryScrolledCanvas.focus_forces   "r) r@r=r&rrrrDrFr{)i^iXr{NNN)rrrrrr;rarVrMrfrkrSrLrvryrrrrrrDsA 25DG<2$' ( 2 - + - #rrr@cB\rSrSrSrSrSrSrSrSr Sr S r S r g ) _Rootiz'Root class for Screen based on Tkinter.cB[RRU5 gr)r9Tkr;rs rr;_Root.__init__s trc\[XX#U5UlURRSSS9 g)Nrboth)expandfill)rr@pack)rr{rr]r^s r setupcanvas_Root.setupcanvass)%d67K  0rcUR$rr@rs r _getcanvas_Root._getcanvass ||rc0URSXX44-5 g)Nz %dx%d%+d%+d)geometry)rr{rstartxstartys r set_geometry_Root.set_geometrys mUF$CCDrc(URSU5 g)NWM_DELETE_WINDOW) wm_protocol)rdestroys r ondestroy_Root.ondestroys +W5rc"UR5$r)winfo_screenwidthrs r win_width_Root.win_widths%%''rc"UR5$r)winfo_screenheightrs r win_height_Root.win_heights&&((rrN) rrrrrr;rrrrrrrrrrr~r~s)11E6()rr~c\rSrSrSrSrSrSrSrS&Sjr S r S&S jr S r S r S rSrS'SjrSrS(SjrS(SjrS(SjrS(SjrSrS'SjrSrSrSrSrSrSrSrSrSr S)S jr!S!r"S"r#S#r$S)S$jr%S%r&g)*TurtleScreenBaseizProvide 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. cf[R"SSURS9nUR5 U$)z$return a blank image object r)r{rrN)r9 PhotoImagecvblank)rimgs r _blankimageTurtleScreenBase._blankimages(mm!Adgg>  rc>[R"XRS9$)zPreturn an image object containing the imagedata from a gif-file named filename. )filerN)r9rr)rrs r_imageTurtleScreenBase._images}}(77;;rcXl[U[5(a-URRnURRnOs[ URR S55n[ URR S55nURRU*S-U*S-US-US-4S9 X lX0lS=UlUl g)Nr{rr%rQr) rrrrrrrkrSxscaleyscale)rrwhs rr;TurtleScreenBase.__init__s b. ) )!!A""ADGGLL)*ADGGLL*+A GGNNA2q51"a%Aq!t*EN F$'' dkrc8URRSSSS9$)zc>TRRUR5TR- TRR UR 5*TR - p!T"X5 grrcanvasxrrcanvasyrrrarrfunrs reventfun+TurtleScreenBase._onclick..eventfun[L0<11$++=A rr tag_unbindtag_bindrrrnumaddrs` ` r_onclickTurtleScreenBase._onclickRsE ; GG  t]S%8 9  GG  T=3#6 Frc^^Tc TRRUSU-5 gUU4SjnTRRUSU-XT5 g)a7Bind 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. Nzc>TRRUR5TR- TRR UR 5*TR - p!T"X5 grrrs rr-TurtleScreenBase._onrelease..eventfunmrrrr s` ` r _onreleaseTurtleScreenBase._onreleaseasJ ; GG  t%?#%E F  GG  T#=#C% ,rc^^Tc TRRUSU-5 gUU4SjnTRRUSU-XT5 g)aABind 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. Nzc>TRRUR5TR- TRR UR 5*TR - p!T"X5 g![a gf=fr)rrrrrrrrrs rr*TurtleScreenBase._ondrag..eventfunsc GGOOEGG4T[[@ GGOOEGG44T[[@I sA,A00 A=<A=rr s` ` r_ondragTurtleScreenBase._ondragtsG ; GG  t%83%> ?  GG  T#6#TRRUR5TR- TRR UR 5*TR - p!T"X5 grrrs rr1TurtleScreenBase._onscreenclick..eventfunrrrrvrL)rrr r rs`` r_onscreenclickTurtleScreenBase._onscreenclicks= ; GGNN=3. /  GGLL,h c>T"5 grrrars rr0TurtleScreenBase._onkeyrelease..eventfunrrrrrrs ` r _onkeyreleaseTurtleScreenBase._onkeyreleases? ; GGNN,s2D 9  GGLL*S0( ;rc^Tc@UcURRSS5 gURRSU-S5 gU4SjnUcURRSU5 gURRSU-U5 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 z c>T"5 grrr s rr.TurtleScreenBase._onkeypress..eventfunr"rrr#s ` r _onkeypressTurtleScreenBase._onkeypresssk ;{|T24d; { \84 _s2H=rc8URR5 g)z=Set focus on canvas (in order to collect key-events) N)rryrs r_listenTurtleScreenBase._listens rc~US:XaURRU5 gURRX!5 g)z?Install a timer, which calls fun after t milliseconds. rN)r after_idlerrrts r_ontimerTurtleScreenBase._ontimers- 6 GG  s # GGMM! !rc8URRSSUS9$)z0Create and return image item on canvas. rimage)r create_image)rr6s r _createimageTurtleScreenBase._createimages ww##Aq#66rcUupEURRXUR-U*UR-45 URR XS9 g)zJConfigure image item as to draw image object at position (x,y) on canvas) r5N)rrrr itemconfig)rrr\r6rrs r _drawimageTurtleScreenBase._drawimagesH t$++orDKK/?@A 4-rclURRXS9 URRU5 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 .r5N)rr; tag_lower)rrr6s r _setbgpicTurtleScreenBase._setbgpics+ 4- $rc8URRU5$)zAReturn 'line' or 'polygon' or 'image' depending on type of item. )rrrs r_typeTurtleScreenBase._typesww||D!!rcURRU5n[S[U5S5Vs/sHo2UX#S-*4PM nnU$s snf)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)] >>> rr%r)rrrangelen)rrripls r _pointlistTurtleScreenBase._pointlistsRWW^^D !).q#b'1)= >)=A!urA#wh)= > ?sAc:URRXX44S9 g)Nr)rrS)rsrx1sry1srx2sry2s r_setscrollregion!TurtleScreenBase._setscrollregions T$<=rcTURR5nUHn[URRU55n/nU(a;USSupxUR Xq-5 UR X-5 USSnU(aM;URR"U/UQ76 M g)Nr%)rfind_allrrr) r xscalefactor yscalefactorrr coordinates newcoordlistrrs r_rescaleTurtleScreenBase._rescales  "Dtww~~d34KL"2A##A$45##A$45)!"o + GGNN4 /, /rcH[UR[5(dURUR4$Xs=La Us=Lac/O O,URRURR4$UbXlUbX lURR XU5 g)zQResize the canvas the turtles are drawing on. Does not alter the drawing window. N)rrrrrrarWs r_resizeTurtleScreenBase._resizes} $''>22>>4??2 2  0b 0 077$$dgg&8&88 8  &N  !(O  iR0rcURR5nUS::aURSnURR5nUS::aURSnX4$)z:Return the width and height of the turtle window. rr{r)rrZr[)rr{rs r _window_sizeTurtleScreenBase._window_size sZ##% A:GGG$E%%' Q;WWX&F}rcLURRR5 g)aCStarts event loop - calling Tkinter's mainloop function. No argument. Must be last statement in a turtle graphics program. Must NOT be used if a script is run from within IDLE in -n mode (No subprocess) - for interactive use of turtle graphics. Example (for a TurtleScreen instance named screen): >>> screen.mainloop() N)rtkrrs rrTurtleScreenBase.mainloops  rc@[R"XURS9$)aMPop up a dialog window for input of a string. Arguments: title is the title of the dialog window, prompt is a text mostly describing what information to input. Return the string input If the dialog is canceled, return None. Example (for a TurtleScreen instance named screen): >>> screen.textinput("NIM", "Name of first player:") )parent)r askstringr)rr*prompts rr)TurtleScreenBase.textinput$s%%eDGGDDrc D[R"XUXEURS9$)aWPop 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) ) initialvalueminvaluemaxvaluere)raskfloatr)rr*rgdefaultminvalmaxvals rrTurtleScreenBase.numinput3s%$$$U.4,0GG5 5r)rrrrr)NNNFrrNr|)'rrrrrrrr;rrrrrrrrrrr rrrr$r)r,r2r8r<r@rCrJrQrYr\r_rr)rrrrrrrs< (O 3705(28 -1-2(.  &  G,&M*=$ <>$ "7 . " > 0 1   E5rrc\rSrSrSrSrg)riOzWill 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. rNrrrrrrrrrrrOs   rc\rSrSrSrSrg)TurtleGraphicsErroriXzSome TurtleGraphics Error rNrtrrrrvrvXsrrvc,\rSrSrSrSSjrSSjrSrg)ri]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. NcbXlUS:Xa![U[5(a [U5nO|US:Xa_[U[5(aIUR 5R S5(a%[U5(a[RU5nOUS:Xa/nO[SU-5eX l g)Npolygonr6.gifcompoundzThere is no shape type %s) rCrrrrlowerendswithrr rrv_data)rtype_datas rr;Shape.__init__ds I $%%T{ g $$$::<((00VD\\'..t4D j D%&AE&IJ J rcURS:wa[SUR-5eUcUnURRXU/5 g)aAdd 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)rCrvr~r)rpolyrrs r addcomponentShape.addcomponenttsP :: #%&HBF**'MN N ?G 4w/0r)r~rCr)rrrrrr;rrrrrrr]s  1rrcD\rSrSrSrS SjrS SjrSrSrSr S r S r g) Tbufferiz5Ring buffer used as undobuffer for RawTurtle objects.cDXlS//U-UlSUlSUlg)NrF)bufsizebufferptrcumulate)rrs rr;Tbuffer.__init__s% vh(  rNcUc-[UR5HnS/URU'M OXlS//U-UlSUlg)Nr)rFrrr)rrrHs rra Tbuffer.resetsG ?4<<("& A)#L 6(W,DKrc URS:atUR(d:URS-UR-UlXRUR'gURURR U5 ggr)rrrrrrs rpush Tbuffer.pushs] <?% * "~   {+  <<8 #**,J OOD,Z E OOD,Z E $rc[SUl[SUlURS5 UR S5UlSUlSUlSUl/Ul URS5 S HnURS U5 M URS 5 URS S H'nURS U5 URS U5 M) S [lg ) a9Delete 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. rrallrrrrr$)rr%N)rrrrr8_bgpic _bgpicname_tracing_updatecounter_turtlesrrSr rrr _pen)rbtnrs rr6TurtleScreen.clears ={+ U''+ !   WC LLs # ::a=C JJtS ! OOD# &! rNcRUc UR$UR5nUS;a[SU-5eXlUS;aXURUR*S-UR *S-URS-UR S-5 S=UlUlUR5 g)aSet turtle-mode ('standard', 'logo' or 'world') and perform reset. Optional argument: mode -- one of the strings 'standard', 'logo' or 'world' Mode 'standard' is compatible with turtle.py. Mode 'logo' is compatible with most Logo-Turtle-Graphics. Mode 'world' uses userdefined 'worldcoordinates'. *Attention*: in this mode angles appear distorted if x/y unit-ratio doesn't equal 1. If mode is not given, return the current mode. Mode Initial turtle heading positive angles ------------|-------------------------|------------------- 'standard' to the right (east) counterclockwise 'logo' upward (north) clockwise Examples: >>> mode('logo') # resets turtle heading to north >>> mode() 'logo' NrlogoworldzNo turtle-graphics-mode %s)rrr%r) rr|rvrQrrrrrarrs rrTurtleScreen.modes, <:: zz| 4 4%&BT&IJ J ' '  ! !4>>/1"4t6F6I'+~~q'8$//1:L N(+ +DK$+ rchUR5S:waURS5 [X1- 5n[XB- 5nUR5upxURUS- US- 5 URUR pUR U- UlURU- UlXR-n U*UR -n UR U -n URU -nURXX5 URURU - UR U - 5 UR5 g)aSet up a user defined coordinate-system. Arguments: llx -- a number, x-coordinate of lower left corner of canvas lly -- a number, y-coordinate of lower left corner of canvas urx -- a number, x-coordinate of upper right corner of canvas ury -- a number, y-coordinate of upper right corner of canvas Set up user coodinat-system and switch to mode 'world' if necessary. This performs a screen.reset. If mode 'world' is already active, all drawings are redrawn according to the new coordinates. But ATTENTION: in user-defined coordinatesystems angles may appear distorted. (see Screen.mode()) Example (for a TurtleScreen instance named screen): >>> screen.setworldcoordinates(-10,-0.5,50,1.5) >>> for _ in range(36): ... left(10) ... forward(0.5) rN) rrr_r&rrrrrQrYr-)rllxllyurxuryxspanyspanwxwy oldxscale oldyscalerMrNrOrPs rr( TurtleScreen.setworldcoordinates#s, 99;' ! IIg ci ci ""$ 2r"u%#{{DKK9nnu, oo- [[ tdkk!~~$% d$5 dkk)+T[[-BC rcUcKUR5RS5(a[SURU55nO,[ S5e[ U[ 5(a [SU5nX RU'g)aAdds a turtle shape to TurtleScreen's shapelist. Arguments: (1) name is the name of a gif-file and shape is None. Installs the corresponding image shape. !! Image-shapes DO NOT rotate when turning the turtle, !! so they do not display the heading of the turtle! (2) name is an arbitrary string and shape is a tuple of pairs of coordinates. Installs the corresponding polygon shape (3) name is an arbitrary string and shape is a (compound) Shape object. Installs the corresponding compound shape. To use a shape, you have to issue the command shape(shapename). call: register_shape("turtle.gif") --or: register_shape("tri", ((0,0), (10,10), (-10,10))) Example (for a TurtleScreen instance named screen): >>> screen.register_shape("triangle", ((5,-3),(0,5),(-5,-3))) Nrzr6z;Bad arguments for register_shape. Use help(register_shape)ry)r|r}rrrvrrr)rnamerks rr$TurtleScreen.register_shapeJso. =zz|$$V,,gt{{4'89)+HJJ u % %)U+E" Trc,[U5S:XaUSn[U[5(a5URU5(dUS:XaU$[ S[U5-5eUup#nURS:Xa$X#U4Vs/sHn[SU-5PM snup#nSUs=::aS::a"O OSUs=::aS::aO OSUs=::aS::dO [ S [U5-5eS X#U4-$![ [ 4a [ S[U5-5ef=fs snf) 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. rrrzbad color string: %sbad color arguments: %sro@bad color sequence: %s #%02x%02x%02x) rGrrrrv TypeErrorrrround)rr:rgbrs r _colorstrTurtleScreen._colorstrms  u:?!HE eS ! !""5))Ub[ )*@3u:*MNN NGA! ??c !01ay9y!uU1W~y9GA!a3Q!]s]a3%&>U&KL L!** :& N%&?#e*&LM M N:s C&;D&(Dc X^URS5(dU$[U5S:Xa"SVs/sHn[XUS-S5PM nnOB[U5S:Xa%USSVs/sHnS[XS5-PM nnO[SU-5e[ U4S jU55$s snfs snf) Nrr)rrrr%rrrzbad colorstring: %sc3F># UHoTR-S- v M g7f)rN)r).0rrs r &TurtleScreen._color..s9b(,bs!)rrGrrvr)rcstrrHrrs` r_colorTurtleScreen._colorss##K t9>09: 1#dQqSk2& B:B Y!^/3ABx8x!"S"%%xB8B%&;d&BC C9b999 ;8s B"!B'c~Uc UR$US:Xa[U5UlgUS:Xa[U5Ulgg)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) Nrr)rrr)rcmodes rrTurtleScreen.colormodes< =?? " C<#ElDO c\!%jDOrcURH.nURUR5 UR5 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_setmoderra)rrs rraTurtleScreen.resets+mmF OODJJ ' LLN$rcUR$)zReturn the list of turtles on the screen. Example (for a TurtleScreen instance named screen): >>> screen.turtles() [] )rrs rr,TurtleScreen.turtless}}rcU(aURU5nOSnURU5nUbURU5nU$)aOSet 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)rrrrrhr:s rrTurtleScreen.bgcolorsA NN4(EE e$  KK&E rcUc UR$[U5UlSUlUb[U5UlUR(aUR 5 gg)aTurns turtle animation on/off and set delay for update drawings. Optional arguments: n -- nonnegative integer delay -- nonnegative integer If n is given, only each n-th regular screen update is really performed. (Can be used to accelerate the drawing of complex graphics.) Second arguments sets delay value (see RawTurtle.delay()) Example (for a TurtleScreen instance named screen): >>> screen.tracer(8, 25) >>> dist = 2 >>> for i in range(200): ... fd(dist) ... rt(90) ... dist += 2 Nr)rrrrr-)rnrs rr+TurtleScreen.tracersM& 9== A   "5zD  == KKM rcBUc UR$[U5Ulg)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)rrrs rrTurtleScreen.delays! =## #u:rc[R(dS[l[eURS:a5U=RS- slU=RUR-slgg)zIncrement update counter.TrrN)r _RUNNINGrrrrs r _incrementudcTurtleScreen._incrementudcsP$$$(L !  ==1    1 $    4== 0  rcURnSUlUR5H#nUR5 UR5 M% XlUR 5 g)z'Perform a TurtleScreen update. TN)rr, _update_data _drawturtler)rtracingr1s rr-TurtleScreen.updatesG-- A NN  MMO   rc(UR5S$)zzReturn the width of the turtle window. Example (for a TurtleScreen instance named screen): >>> screen.window_width() 640 rr_rs rr/TurtleScreen.window_width  "1%%rc(UR5S$)z|Return the height of the turtle window. Example (for a TurtleScreen instance named screen): >>> screen.window_height() 480 rr!rs rr.TurtleScreen.window_heightr#rcUR$)zReturn the Canvas of this TurtleScreen. No argument. Example (for a Screen instance named screen): >>> cv = screen.getcanvas() >>> cv )rrs rrTurtleScreen.getcanvas%s wwrcH[URR55$)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'] )sortedrr rs rrTurtleScreen.getshapes1sdll'')**rc(URXU5 g)aBind fun to mouse-click event on canvas. Arguments: fun -- a function with two arguments, the coordinates of the clicked point on the canvas. btn -- the number of the mouse-button, defaults to 1 Example (for a TurtleScreen instance named screen) >>> screen.onclick(goto) >>> # Subsequently clicking into the TurtleScreen will >>> # make the turtle move to the clicked point. >>> screen.onclick(None) N)rrrrr s rrSTurtleScreen.onclick<s Cc*rcUc+X R;aURRU5 O*X R;aURRU5 URX5 g)aBind 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)rremoverr$rrrs rrTurtleScreen.onkeyMsP. ;jj  !!#&  " JJ  c " 3$rcUc+X R;aURRU5 O-Ub*X R;aURRU5 URX5 g)aBind fun to key-press event of key if key is given, or to any key-press-event if no key is given. Arguments: fun -- a function with no arguments key -- a string: key (e.g. "a") or key-symbol (e.g. "space") In order to be able to register key-events, TurtleScreen must have focus. (See method listen.) Example (for a TurtleScreen instance named screen and a Turtle instance named turtle): >>> def f(): ... fd(50) ... lt(60) ... >>> screen.onkeypress(f, "Up") >>> screen.listen() Subsequently the turtle can be moved by repeatedly pressing the up-arrow key, or by keeping pressed the up-arrow key. consequently drawing a hexagon. N)rr/rr)r0s rr TurtleScreen.onkeypressksT2 ;jj  !!#& _JJ!6 JJ  c " "rc$UR5 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,)rxdummyydummys rrTurtleScreen.listens  rc&URX5 g)aInstall a timer, which calls fun after t milliseconds. Arguments: fun -- a function with no arguments. t -- a number >= 0 Example (for a TurtleScreen instance named screen): >>> running = True >>> def f(): ... if running: ... fd(50) ... lt(60) ... screen.ontimer(f, 250) ... >>> f() # makes the turtle marching around >>> running = False N)r2r0s rr#TurtleScreen.ontimers& crcUc UR$XR;aURU5URU'URURURU5 Xlg)aSet 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)rrrr@r)rpicnames rrTurtleScreen.bgpicsT" ??? " ,, &$(KK$8DLL ! t{{DLL$9:!rc&URXU5$)avResize 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\rWs rr&TurtleScreen.screensizes"||I266r) rrrrrrrrrrrrrrNNrrrr|)'rrrrrrrr;r6rr(r$rrrrar,rr+rrr-r/r.rrrSrr rr#rr&r"r%rrr!rrrrr r s H $V  ,DM&FP< D%N!#F+6 :)* .8 &1 &&  ++"%<#@ *"07&MKKHLrr cn\rSrSrSr\"SS5\"SS5\"SS5S.rSrSrSr \4S jr S r S,S jr S r S-SjrSrSrSrSrS.SS.S\SS 4SjjjrSrSrSrSrSrSrSrS,SjrS rS!rS"rS,S#jr S,S$jr!S%r"S&r#S.S'jr$S/S(jr%S.S)jr&S,S*jr'\r(\r)\r*\r+\r,\r-\r.\r/\#r0S+r1g )0 TNavigatorizJNavigation part of the RawTurtle. Implements methods for turtle movement. r)rrrrrrcURUlURUlXlSUlUR 5 SUlURU5 [RU5 gr) DEFAULT_ANGLEOFFSET _angleOffsetDEFAULT_ANGLEORIENT _angleOrientr undobufferr;r rBrars rr;TNavigator.__init__sT 44 44    drcj[SS5Ul[RURUlg)zHreset turtle to its initial values Will be overwritten by parent class rCN)r _positionrBSTART_ORIENTATIONr_orientrs rraTNavigator.resets' sC"44TZZ@ rNcUc UR$US;agXlUS;aSUlSUlgURS- UlSUlg)z:Set turtle-mode to 'standard', 'world' or 'logo'. Nr)rrrr@r)rrFrH _fullcirclers rr TNavigator._setmodesX <::  4 4  ( ( !D  !D  $ 0 0 3D  "D rchXlSU- UlURS:XaSUlgUS- Ulg)z+Helper function for degrees() and radians()ihrrrQN)rR _degreesPerAUrrFr fullcircles r_setDegreesPerAUTNavigator._setDegreesPerAU s4% ^ :: # !D  *2 D rc&URU5 g)aSet 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)rXrVs rr;TNavigator.degreess, j)rcBUR[R5 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)rXrtaurs rr_TNavigator.radians+s dhh'rc^URURU--nURU5 g)z)move turtle forward by specified distanceN)rLrN_goto)rr<endes r_goTNavigator._go9s%~~ x 77 4rc`XR-nURRU5Ulg)z=Turn turtle counterclockwise by specified angle if angle > 0.N)rUrNrrrs r_rotateTNavigator._rotate>s& ###||**51 rcXlg)zmove turtle to position end.NrL)rends rr`TNavigator._gotoCsrFfill_gaprmreturnctUbUOURSnUbUOURSn[XE5Ulg)zHTo be overwritten by child class RawTurtle. Includes no TPen references.Nrr)rLr)rrrrmnew_xnew_ys rrsTNavigator.teleportGs8]q(9]q(9u,rc&URU5 g)aMove the turtle forward by the specified distance. Aliases: forward | fd Argument: distance -- a number (integer or float) Move the turtle forward by the specified distance, in the direction the turtle is headed. Example (for a Turtle instance named turtle): >>> turtle.position() (0.00, 0.00) >>> turtle.forward(25) >>> turtle.position() (25.00,0.00) >>> turtle.forward(-75) >>> turtle.position() (-50.00,0.00) Nrbrr<s rrDTNavigator.forwardNs* rc(URU*5 g)aoMove 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) Nrtrus rr0TNavigator.backes$ (rc(URU*5 g)aTurn turtle right by angle units. Aliases: right | rt Argument: angle -- a number (integer or float) Turn turtle right by angle units. (Units are by default degrees, but can be set via the degrees() and radians() functions.) Angle orientation depends on mode. (See this.) Example (for a Turtle instance named turtle): >>> turtle.heading() 22.0 >>> turtle.right(45) >>> turtle.heading() 337.0 Nrfres rr`TNavigator.rightys& eVrc&URU5 g)aTurn turtle left by angle units. Aliases: left | lt Argument: angle -- a number (integer or float) Turn turtle left by angle units. (Units are by default degrees, but can be set via the degrees() and radians() functions.) Angle orientation depends on mode. (See this.) Example (for a Turtle instance named turtle): >>> turtle.heading() 22.0 >>> turtle.left(45) >>> turtle.heading() 67.0 Nrzres rrQTNavigator.lefts& UrcUR$)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) rirs rr\TNavigator.poss~~rc URS$)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 rrirs rr}TNavigator.xcor~~a  rc URS$)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 rrirs rr~TNavigator.ycorrrcnUcUR[U65 gUR[X55 g)aMove 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)rrrs rrJTNavigator.gotos)< 9 JJuay ! JJuQ{ #rcJURSS5 URS5 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() rN)rJrers rrMTNavigator.homes !Q rcRUR[XRS55 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) rNr`rrL)rrs rriTNavigator.setxs 5NN1-./rcTUR[URSU55 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) rNr)rrs rrjTNavigator.setys 5*A./rcUb [X5n[U[5(aUnO?[U[5(a [U6nO![U[5(a URn[ WUR- 5$)acReturn 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 )rrrrBrLabs)rrrr\s rr<TNavigator.distance"sd, =+C a  C 5 ! !)C : & &++C3'((rcUb [X5n[U[5(aUnO?[U[5(a [U6nO![U[5(a URnWUR- up[ [ R"[ R"X!55S5S-nX@R-nURURU--UR-$)aReturn the angle of the line from the turtle's position to (x, y). Arguments: x -- a number or a pair/vector of numbers or a turtle instance y -- a number None None call: distance(x, y) # two coordinates --or: distance((x, y)) # a pair (tuple) of coordinates --or: distance(vec) # e.g. as returned by pos() --or: distance(mypen) # where mypen is another turtle Return the angle, between the line from turtle-position to position specified by x, y and the turtle's start orientation. (Depends on modes - "standard" or "logo") Example (for a Turtle instance named turtle): >>> turtle.pos() (10.00, 10.00) >>> turtle.towards(0,0) 225.0 rv@) rrrrBrLrrr;atan2rUrFrHrR)rrrr\results rrvTNavigator.towardsBs, =+C a  C 5 ! !)C : & &++CT^^#t||DJJq$45r:UB$$$!!D$5$5f$<<@P@PPPrcURup[[R"[R"X!55S5S-nX0R -nUR URU--UR-$)zReturn the turtle's current heading. No arguments. Example (for a Turtle instance named turtle): >>> turtle.left(67) >>> turtle.heading() 67.0 rr) rNrrr;rrUrFrHrR)rrrrs rrKTNavigator.headingesg||t||DJJq$45r:UB$$$!!D$5$5f$<<@P@PPPrcXR5- UR-nURnX#S- -U-US- - nURU5 g)aSet the orientation of the turtle to to_angle. Aliases: setheading | seth Argument: to_angle -- a number (integer or float) Set the orientation of the turtle to to_angle. Here are some common directions in degrees: standard - mode: logo-mode: -------------------|-------------------- 0 - east 0 - north 90 - north 90 - east 180 - west 180 - south 270 - south 270 - west Example (for a Turtle instance named turtle): >>> turtle.setheading(90) >>> turtle.heading() 90 @N)rKrHrRrf)rto_anglerfulls rreTNavigator.setheadingtsM.LLN*D,=,==Bw$tBw. Urc UR(a-URRS/5 SURlUR5nUc URnUcB[ U5UR- nS[ [S[ U5S- -S5U-5-nSU-U- nS U-nS U-[R"[R"U5UR-5-nUS :aU*U*U*pvnUR5n UR5n US :XaURS S 5 OURS 5 URU5 [U5HGn URU5 UR!U5 URS 5 URU5 MI URU*5 US :XaURX5 URU5 UR(aS URlgg) a2Draw 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@gM@rrrrF)rIrrrprRrrminrrr_rU_tracerrrfrFrb) rradiusextentstepsrpfracrw2ltrdlrHs rr5TNavigator.circles< ?? OO % )'+DOO $  >%%F =v;t///Dc#bVS0$7<==E &L5  1W &L488DLL$4T5G5G$GH H A:rA2s"A \\^ [[] A: LLA  JJqM RuA JJu  HHQK JJqM LLO  bS A: LL  5 ??',DOO $ rcgz/dummy method - to be overwritten by child classNr)rrs rrpTNavigator.speedrcgrr)rars rrTNavigator._tracerrrcgrr)rrs rrTNavigator._delayrr)rFrHrUrRrrNrLrIr)rr?r@)2rrrrrrrM DEFAULT_MODErErGr;rar rXr;r_rbrfr`boolrsrDr0r`rQr\r}r~rJrMrirjr<rvrKrer5rprrrAr4r1rcrRr]rfrgrdrrrrrBrBs#sO#sO#sO'L(A #.*0 ( 2 -5-D-T-.(**  ! !!$F 0$0$)@!QF Q8=-B>>> B BH B BH FK DrrBc\rSrSrSr\S4Sjr\S\S4SjrS S jrS S jr S r S r S r S Sjr SrSrSrS!SS.S\SS4SjjjrSrSrSrS SjrS"SjrS#SjrSrSr\ r\ r\ r\ r\ r\r \r!Sr"g)$TPeniz>Drawing part of the RawTurtle. Implements drawing properties. rbcHXlSUl[RU5 gr) _resizemoderIr_reset)rrbs rr; TPen.__init__s% DrrXrBcSUlSUlXlX lSUlSUlSUlSUlSUlSUl SUl g)NrTr)rrrC)rrCrCr) _pensize_shown _pencolor _fillcolor_drawing_speed_stretchfactor _shearfactor_tilt _shapetrafo _outlinewidth)rrXrBs rr TPen._resetsO  !#  & +rNcnUc UR$UR5nUS;aURUS9 gg)aSet resizemode to one of the values: "auto", "user", "noresize". (Optional) Argument: rmode -- one of the strings "auto", "user", "noresize" Different resizemodes have the following effects: - "auto" adapts the appearance of the turtle corresponding to the value of pensize. - "user" adapts the appearance of the turtle according to the values of stretchfactor and outlinewidth (outline), which are set by shapesize() - "noresize" no adaption of the turtle's appearance takes place. If no argument is given, return current resizemode. resizemode("user") is called by a call of shapesize with arguments. Examples (for a Turtle instance named turtle): >>> turtle.resizemode("noresize") >>> turtle.resizemode() 'noresize' N)autouserrrb)rr|rW)rrmodes rrbTPen.resizemodes<, =## #  0 0 HHH & 1rc@Uc UR$URUS9 g)aSet 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)rrW)rr{s rrZ TPen.pensizes!$ ===  rcFUR(dgURSS9 g)zPull the pen up -- no drawing when moving. Aliases: penup | pu | up No argument Example (for a Turtle instance named turtle): >>> turtle.penup() NFrYrrWrs rr[ TPen.penup-s}}  rcFUR(agURSS9 g)zPull the pen down -- drawing when moving. Aliases: pendown | pd | down No argument. Example (for a Turtle instance named turtle): >>> turtle.pendown() NTrrrs rrY TPen.pendown;s ==  rcUR$)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 )rrs rrO TPen.isdownIs}}rcSSSSSS.nUc UR$X;aX!nO'SUs=:aS :aO O[[U55nOSnURUS 9 g) aReturn 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) rrrrr)fastestfastnormalslowslowestNrg%@)rp)rrrrW)rrpspeedss rrp TPen.speedXs]6b1Q!M =;;  ?ME 5 4 e %EE urc8U(a^[U5nUS:XaUS=p4OUS:XaUup4O US:XaU=p4URW5nURW5nURX4S9 gURUR5URUR 54$)aReturn or set the pencolor and fillcolor. Arguments: Several input formats are allowed. They use 0, 1, 2, or 3 arguments as follows: color() Return the current pencolor and the current fillcolor as a pair of color specification strings as are returned by pencolor and fillcolor. color(colorstring), color((r,g,b)), color(r,g,b) inputs as in pencolor, set both, fillcolor and pencolor, to the given value. color(colorstring1, colorstring2), color((r1,g1,b1), (r2,g2,b2)) equivalent to pencolor(colorstring1) and fillcolor(colorstring2) and analogously, if the other input format is used. If turtleshape is a polygon, outline and interior of that polygon is drawn with the newly set colors. For more info see: pencolor, fillcolor Example (for a Turtle instance named turtle): >>> turtle.color('red', 'green') >>> turtle.color() ('red', 'green') >>> colormode(255) >>> color((40, 80, 120), (160, 200, 240)) >>> color() ('#285078', '#a0c8f0') rrr%r)rXrBN)rGrrWrrr)rrhrpcolorfcolors rr: TPen.color~s@ D AAv"&q')a!%a"&&^^F+F^^F+F HHfH 7;;t~~. DOO0LL LrcU(a1URU5nX R:XagURUS9 gURUR5$)aReturn 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)rrrWrrs rrX TPen.pencolorsC: NN4(E& HHeH $;;t~~. .rcU(a1URU5nX R:XagURUS9 gURUR5$)aReturn 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)rrrWrrs rrBTPen.fillcolorsC8 NN4(E' HHuH %;;t/ /rFrlrmrncnUR5nU(aURSS9 URUS9 g)zOTo be overwritten by child class RawTurtle. Includes no TNavigator references. FrN)rOrW)rrrrmrYs rrs TPen.teleports.++-  HHUH # !rc"URSS9 g)zMakes the turtle visible. Aliases: showturtle | st No argument. Example (for a Turtle instance named turtle): >>> turtle.hideturtle() >>> turtle.showturtle() TshownNrWrs rroTPen.showturtles trc"URSS9 g)aMakes 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() FrNrrs rrLTPen.hideturtle s urcUR$)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 )rrs rrPTPen.isvisible s{{rc XURURURURURUR UR URURURURS. nU(d U(dU$[U[5(aUnO0nURU5 0nUH nX6XV'M UR(aURRSU45 SnSU;aURUS:waSnSU;aE[US[ 5(aUR#US45US'URUS:waSnSU;aURUS:waSnU(aUR%5 SU;a USUlSU;a USUlSU;a USUlSU;a:[US[ 5(aUR#US45US'USUlS U;a US UlS U;a US UlS U;a)US n[U[&[(45(aX4nXlS U;a US UlS U;a US Ul SU;a USUlSU;a USUl S U;d SU;dS U;ayURupURn [*R,"UR5[*R."UR5pX-XU -U --U *U -XX-- -4UlUR35 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} ) rrYrXrBrZrprb stretchfactorrnrrtrWFrYTrXrZrBrprbrrnrrrtN)rrrrrrrrrrrrdictr-rIrrr_newLinerrrrrrr)rrWpendict_pdp_p_bufrnewLinesfscxscyshfsacas rrWTPen.pen' s^#'++"&--"&.."&//"&--"&++"&"2"2"&"5"5"&"3"3"&"4"4"&** wJ c4 AA C(FK ?? OO % 1 >}}) , ?!J-// $* /? @* ~~:. >}}) ,  MMO >iLDM ?z]DN >iLDM ! !K.%00!%;0A!B+ nDO a<G*DK 1  D  a ?#B"sEl++X"$  A  !- 0D  >!"9D  a<G*DK Q;6DJ a 6Q;-12D**HC##CXXdjj)488DJJ+?!$"frk):!$R36k): rqrNrrrrrrs#'|"4 #:.#K0 '8 .    $L,M\#/J"0H"5"D"T"  {~>>>> E B B B D B Brrc$\rSrSrSrSrSrSrg) _TurtleImagei z6Helper class: Datatype to store Turtle attributes c@XlSUlURU5 gr)rrC _setshape)rr shapeIndexs rr;_TurtleImage.__init__ s   z"rcTURnXlURSs=:XaURUR:Xag URSs=:XaURUR:Xag URS;aUR UR 5 O4URS:Xa$UR HnUR U5 M URURUlURS:XaUR 5UlgURS:Xa.URURSR5UlgURS:Xa=URURVs/sHo2R 5PM snUlggs snf)Nryr6)r6ryr{r) rrrCrr_itemrr8r~)rrrrs rr_TurtleImage._setshape sR$ :: FfnnZ&@&F&F F  G :: DFNN:$>$D$D D  E ::- - NN4:: & ZZ: % t$#^^J/55 :: "++-DJ ZZ7 ",,V^^G-D-J-JKDJ ZZ: %*0..*D*J*JL*J48,,.*JLDJ&LsF%)rrCrrN)rrrrrr;rrrrrrr s# Lrrc\rSrSrSr/rS\S\S\S4SjrSrS r S r S r S r S r SrS=SjrSrSrSrS=SS.S\SS4SjjjrSrS>SjrS?SjrS>SjrS>SjrSrS@SjrSrS rSAS!jrS"rS#r S$r!S%r"S>S&jr#S'r$S(r%S)r&SBS*jr'S+r(S,r)S-r*S>S.jr+S/r,SCS0jr-S1r.S2r/S3r0S4r1S5r2\2r3S>S6jr4SDS7jr5SDS8jr6SDS9jr7S:r8S;r9\r:SrrvrBr;rrrrdrawingLineItemrr_poly _creatingPoly _fillitem _fillpathr_hidden_from_screencurrentLineItemrL currentLiner stampItems_undobuffersizerrIr)rcanvasrkrrrs rr;RawTurtle.__init__ s fg & & K  - -Y...!!((0 K  8 9 9#++99&"(K, +62 !!((5%&>&GH HD++-0 dt$%113"61  "*.. #( %113 NN+**+ -!.1 rc[RU5 [RU5 UR 5 UR 5 UR 5 g)atDelete 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)rBrarr_clearrrrs rraRawTurtle.reset s<&  D   rcFUbUS::aSUlg[U5Ulg)aZSet 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)rIr)rsizes rrhRawTurtle.setundobuffer s! <419"DO%dmDOrcRURcgURR5$)zReturn count of entries in the undobuffer. No argument. Example (for a Turtle instance named turtle): >>> while undobufferentries(): ... undo() r)rIrrs rryRawTurtle.undobufferentries2 s$ ?? "**,,rcS=UlUlURHnURR U5 M URR 5Ul/UlUR(a%URRUR5 UR /UlUR5 URUR5 g)zDelete all of pen's drawingsN)r r!rrrrr#r$rrrLr8rhr&rs rr*RawTurtle._clear? s*..JJD KK   %#{{668 ==    # #DNN 3**+   4//0rcDUR5 UR5 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*rrs rr6RawTurtle.clearM s  rc.URR5 URRS:wag[UR5S:aGURR UR URURUR5 ggr) rrrrGr$rr#rrrs rrRawTurtle._update_data\ so !!# ;; % % *  t  " KK ! !$"6"68H8H"&..$-- A #rcURnURS:XagURS:XaLUR5 UR5 UR 5 UR UR 5 gUR5 URS:Xa8UR5HnUR5 M UR 5 gg)z&Perform a Turtle-data update. rNr) rrrrrrrrr,)rrr1s rrRawTurtle._updated s ??a   __ !         NN  MM&,, -    $$))AMMO* *rc8URRX5$)aTurns turtle animation on/off and set delay for update drawings. Optional arguments: n -- nonnegative integer delay -- nonnegative integer If n is given, only each n-th regular screen update is really performed. (Can be used to accelerate the drawing of complex graphics.) Second arguments sets delay value (see RawTurtle.delay()) Example (for a Turtle instance named turtle): >>> turtle.tracer(8, 25) >>> dist = 2 >>> for i in range(200): ... turtle.fd(dist) ... turtle.rt(90) ... dist += 2 )rr+)rflagrs rrRawTurtle._tracerv s&{{!!$..rc8URRU5$r)rrrgs rrRawTurtle._color s{{!!$''rc8URRU5$r)rrrgs rrRawTurtle._colorstr s{{$$T**rc[U[5(aU$Uup#nUR R S:Xa$X#U4Vs/sHn[SU-5PM snup#nSUs=::aS::a"O OSUs=::aS::aO OSUs=::aS::dO [ S[U5-5eSX#U4-$![[4a [ S[U5-5ef=fs snf)z,Convert colortriples to hexstrings. rrrrrrr)rrrrrvrrr)rrhrrrrs r_cc RawTurtle._cc s dC K MGA! ;; ! !S (01ay9y!uU1W~y9GA!a3Q!]s]a3%&>T&JK K!** :& M%&?#d)&KL L M:sB)C)(CFrlrmrnczUR5nUR5nU(aURSS9 U(aU(dUR5 UbUOURSnUbUOURSn[ Xg5UlURUS9 U(aU(dUR 5 ggg)arInstantly 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) FrNrr)rOrCrWr?rLrr2)rrrrmrY was_fillingrprqs rrsRawTurtle.teleport sF++-lln  HHUH # x MMO]q(9]q(9u, ! x OO  (;rcvURnURUR5 URnSUlSUl[ U5nXlX lXl[ XRR 5UlURRU5 URURR RnUS:Xa UR5URl OUS:Xa8URURSR5URl O`US:XaZURURR RVs/sHoQR5PM snURl UR5UlUR#5 U$s snf)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() Nryr6rr{)rrrrrrrrrrrCrrr8r~rr#r)rrrqttypers rr9RawTurtle.clone sM dmm$  TN   (>(>?q!t{{556<< I #//1AHHN g #001H1N1NOAHHN j $nnT[[-C-CDJJLJ8<002JLAHHN"..0  Ls$F6cUcURR$XRR5;a[ SU-5eURR U5 UR 5 g)agSet turtle shape to shape with given name / return current shapename. Optional argument: name -- a string, which is a valid shapename Set turtle shape to shape with given name or, if name is not given, return name of current shape. Shape with name must exist in the TurtleScreen's shape dictionary. Initially there are the following polygon shapes: 'arrow', 'turtle', 'circle', 'square', 'triangle', 'classic'. To learn about how to deal with shapes see Screen-method register_shape. Example (for a Turtle instance named turtle): >>> turtle.shape() 'arrow' >>> turtle.shape("turtle") >>> turtle.shape() 'turtle' NzThere is no shape named %s)rrrrrvrr)rrs rrkRawTurtle.shape sX( <;;)) ){{,,..%&BT&IJ J d# rc(Xs=La Us=LacO OURupXUR4$US:XdUS:Xa [S5eUb UcX4nO%X4nO!UbURSU4nO URnUc URnURSXCS9 g)aSet/return turtle's stretchfactors/outline. Set resizemode to "user". Optional arguments: stretch_wid : positive number stretch_len : positive number outline : positive number Return or set the pen's attributes x/y-stretchfactors and/or outline. Set resizemode to "user". If and only if resizemode is set to "user", the turtle will be displayed stretched according to its stretchfactors: stretch_wid is stretchfactor perpendicular to orientation stretch_len is stretchfactor in direction of turtles orientation. outline determines the width of the shapes's outline. Examples (for a Turtle instance named turtle): >>> turtle.resizemode("user") >>> turtle.shapesize(5, 5, 12) >>> turtle.shapesize(outline=8) Nrz(stretch_wid/stretch_len must not be zeror)rbrr)rrrvrW)r stretch_wid stretch_lenrrs rrlRawTurtle.shapesize s*  8 8 8'+':': $KT-?-?? ? ! {a/%&PQ Q  "" + 8 + 8  $ //2K?M //M ?((G F,  ?rcBUc UR$URSUS9 g)aNSet 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)rbrn)rrW)rshears rrnRawTurtle.shearfactor; s%& =$$ $ F6rcDUcI[R"UR5*UR-nX R- UR -$U*UR-UR-n[R "U5[R-nURSUS9 g)aSet or return the current tilt-angle. Optional argument: angle -- number Rotate the turtleshape to point in the direction specified by angle, regardless of its current tilt-angle. DO NOT change the turtle's heading (direction of movement). If angle is not given: return the current tilt-angle, i. e. the angle between the orientation of the turtleshape and the heading of the turtle (its direction of movement). 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)rbrt) rr;rrHrUrRr_r]rW)rrrts rruRawTurtle.tiltangleR s8 =LL,,t/@/@@D---1A1AA A6D...1B1BBD<<%0D HHTH 2rcFURXR5-5 g)alRotate 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)rures rrtRawTurtle.tiltv s" u~~//0rcXs=LaUs=LaUs=LacUR$ URupVpxUbUnUbUnUbUnUbUnX-X#-- S:Xa [S5eXVXx4Ul[R"U*U5[R-n [R "U 5[R "U 5pX-X-- X-X-- X-X--X-X--4uppX4UlX- UlXl URSS9 g)aZSet or return the current transformation matrix of the turtle shape. Optional arguments: t11, t12, t21, t22 -- numbers. If none of the matrix elements are given, return the transformation matrix. Otherwise set the given elements and transform the turtleshape according to the matrix consisting of first row t11, t12 and second row t21, 22. Modify stretchfactor, shearfactor and tiltangle according to the given matrix. Examples (for a Turtle instance named turtle): >>> turtle.shape("square") >>> turtle.shapesize(4,2) >>> turtle.shearfactor(-0.5) >>> turtle.shapetransform() (4.0, -1.0, -0.0, 2.0) Nrz0Bad shape transform matrix: must not be singularrr) rrvrrr]rrrrrrW)rt11t12t21t22m11m12m21m22alfarra11a12a21a22s rrmRawTurtle.shapetransform s(  + + +## # ,!--# ?#C ?#C ?#C ?#C 9sy A %%&XY Yc/zz3$$txx/$$B frvorv frvorv@#!hG  F#rc ^URnURup4URupV[XVUR-UR - 5nS[ U5- U-upVUVV s/sH8upX6U-XY--UR - -XE*U-Xi--UR- -4PM: sn n$s sn nf)z\Computes transformed polygon shapes from a shape according to current position and heading. r)rrLrNrrrr) rrrp0p1e0e1errs r _polytrafoRawTurtle._polytrafo s "6==(6==8 9A,!#IMOIMvT"$Y --r3q5:v}}2L/LMIMO OOs&?B)cURRURRnURS:Xa)UR UR URS:H5$g)aReturn 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)) ryr{N)rrrrrC _getshapepolyr~)rrks rrHRawTurtle.get_shapepoly sS ##DKK$:$:; ;;) #%%ekk5;;*3LM M $rc^^^^URS:XdU(aURummmmOGURS:Xa%[SURS- 5nUSSU4ummmmOURS:XaU$[ UUUU4SjU55$)zPCalculate transformed shape polygon according to resizemode and shapetransform. rrrg@rrc3T># UHupTU-TU--TU-TU--4v M g7frr)rrrrXrYrZr[s rr*RawTurtle._getshapepoly.. s0J'c!ec!emSUSU]3's%()rrmaxrr)rryr{rrXrYrZr[s @@@@rroRawTurtle._getshapepoly s   v %!%!1!1 Cc3    'At}}S()A!"Aq! Cc3    +NJ'JJJrc URnURURRnURnURR nUR (Ga`URS:XGaOURS:Ga>SUl URnUS:XaURS:XaSnO)URS:Xa URnO URnURURU55nUR UR"pUR%XBXxUSS9 g US :XaUR'X@R(U5 g US :Xau[+XE5Heun upnURURU S55n UR%XUR-U5UR-U5URSS9 Mg g g UR(ag US:XaUR%US S S 5 O]US :Xa4UR'X@R(URSR5 O#US :XaUHn UR%U S S S 5 M SUl g )zhManages the correct rendering of the turtle with respect to its shape, resizemode, stretch and tilt etc.rFryrrrTrrr{rr6r{Nrrrrr)rrrrrCrrrrr"r~rrrrlrorrrr<rLziprA) rrrkrHtitemtshaperfcocrrs rrRawTurtle._drawturtle s t{{556  !! ;;;600A5&//A:M',D $[[F !##z1q1%%/T]]++a(:(:6(BC$..B  B<=4!I'!!!%@*$,/,>(D.4R??4+=+=dD+IJD$$Tdhhrl-1XXb\ASASY]%_-?% '' !  (@"bI'!!!%*0..*A*G*GI*$!D$$T+CRL"'+D $rc URnURURRnURnUR nUS:XaUR 5nURS:XaSnO)URS:Xa URnO URnURURU55nURURpURXRXxUSS9 OUS:Xa.URS5nUR!XPR"U5 OUS :Xa/nUH$n UR 5n UR%U 5 M& ['U5n[)XT5Heun upnURURU S55n URXUR+U5UR+U5URSS9 Mg UR,R%W5 UR.R1S U45 U$) auStamp 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) ryrrrTrwr6rr{rr)rrrrrCr~rrrrrlrorrrr8r<rLrrryrAr%rIr) rrrkrHr{stitemrr|r}elementrrs rrrRawTurtle.stamp st{{556  I '')F:-1q!!V+Q''!OOD$6$6v$>?E__dnn   V89t  E g ((,F   fnnf = j F!))+ d#"6]F(+F(;$ntt'9'9$'EF  $((2,)-"T=O=OUY![)< v& gv./ rc|XR;ap[U[5(a%UHnURR U5 M OURR U5 URR U5 SU4nUR nX4R;agURRU5nURR U5 XTR::a!URS- UR-Ul URRURS-UR-S/5 g)z9does the work for clearstamp() and clearstamps() rrNr) r%rrrrr/rIrindexrrinsert)rstampidsubitemrbufrs r _clearstampRawTurtle._clearstamp0 s oo %'5))&GKK''0 ' ##G, OO " "7 +!oo zz !    & $ GG ww{ckk1CG 37719ckk1D6:rcFURU5 UR5 g)aDelete stamp with given stampid Argument: stampid - an integer, must be return value of previous stamp() call. Example (for a Turtle instance named turtle): >>> turtle.color("blue") >>> astamp = turtle.stamp() >>> turtle.fd(50) >>> turtle.clearstamp(astamp) N)rr)rrs rr7RawTurtle.clearstampF s ! rcUcURSSnO%US:aURSUnOURUSnUHnURU5 M UR5 g)aDelete all or first/last n of turtle's stamps. Optional argument: n -- an integer If n is None, delete all of pen's stamps, else if n > 0 delete first n stamps else if n < 0 delete last n stamps. Example (for a Turtle instance named turtle): >>> for i in range(8): ... turtle.stamp(); turtle.fd(30) ... >>> turtle.clearstamps(2) >>> turtle.clearstamps(-2) >>> turtle.clearstamps() Nr)r%rr)rrtoDeleters rr8RawTurtle.clearstampsU s_$ 9q)H !Vr*Hqr*HD   T " rc URURUR[UR[ 54nUR nSURXURURSSURUR5URSS44nUR(aURRU5 URnUR(Ga9URS:XGa(X- nUSUR -S-USUR"-S--nS[%US-SSUR--UR-- 5-nUS U- -n ['SU5Hyn U S:XaS n OS n XYU --UlUR(a>UR)UR*XPR4URURU 5 UR-5 M{ UR(a&UR)UR*S S URS9 UR(aURR/U5 [UR[ 5(aURR/U5 XlUR0(aUR2R/U5 [5UR5S:aUR75 UR-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. goNrrr%rr皙?rTFrrrrr{*)rrrrr!rrrLr#r$rJrrIrrrrrrrFrrrrrrrGr) rrjgo_modesr undo_entrystartdiffdiffsqnhopsdeltarrs rr`RawTurtle._gotoq sW ]]^^]]57DNNC++&&q)''(<(<=jjm% ?? OO  , ;;;6??a/ID1gfmm+a/476==3H12LLFc63;C,<)=dkk)IJKKECI&E1e_6CC!&!2==$$T%9%9&+^^%<%)^^T]]CI %}}  !5!57G46dmm!M ==    # #C ( dnnd + + NN ! !# &    JJ  c " t 2 % MMO rcUup#pEUupgpUuppURn[URU- 5S:a [S5 XlXlU SS/:XaSnOUnUR XXS9 URVs/sH$nUU ;dM URU5S:XdM"UPM& nnUH/nURU5 URRU5 M1 UnUR(GaURS:XaX#- nUSUR-S -USUR-S --nS[US-S S UR--UR-- 5-nUS U- -n[!SU5H\nUS:XaS nOSnUUU--UlU(a*UR UR"UUR4XxU5 UR%5 M^ U(aUR UR"SSUS9 X lUR&(aQ[)UR*5S:aUR*R-5 UR*/:XaSUlSUlU (aJUR./:XaSUl[S5 O'UR.bUR.R-5 UR%5 gs snf)z)Reverse a _goto. Used for undo() rz$undogoto: HALLO-DA-STIMMT-WAS-NICHT!rrrrrrr%rrrTFrNzUnwahrscheinlich in _undogoto!)rrrLrr#r$rrrCrr/rrrrrrFrrrrGrrr!)rentryoldnewrcoodatadrawingpcpsrCcLIcLrIrrusepcrHtodeleterrrrrrrs r _undogotoRawTurtle._undogoto s',#(#+ R$ t~~# $s * 9 :" &&! !EEu7#zzDz!aunA(. Q6(AzDA NN1  JJ  a  ;;;6??a/9D1gfmm+a/476==3H12LLFc63;C,<)=dkk)IJKKECI&E1e_6CC!$uqy$$T%9%9&+T^^%<%'S2 %  !5!57G46b!B   4::"  zzR%*"! ~~#!%67+""$ YDs: KKKc0UR(a'URRSXR45 XR-nURR U5nUR R nUS:XaURS:asSUR-nS[[U5U- 5-nSU-U- n[U5H3nURR U5UlUR5 M5 X lUR5 g)z&Turns pen clockwise by angle. rotrrg@rN) rIrrUrNrrrrrrrFr)rr neworientranglevelrrrs rrfRawTurtle._rotate s ?? OO %0B0B!C D ###LL''. ++&& a>> turtle.begin_fill() >>> if turtle.filling(): ... turtle.pensize(5) ... else: ... turtle.pensize(3) )rr!rrs rrCRawTurtle.filling s$..$//rcUR5(dDURR5UlURR UR5 UR /UlUR5 UR(a'URRSUR45 UR5 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) rCrrr rrrLr!rrIrrrs rr2RawTurtle.begin_fill s{||~~![[446DN JJ  dnn -..)  ?? OO +t~~!> ? rcUR5(a[UR5S:aqURR UR URUR S9 UR(a'URRSUR 45 S=UlUlUR5 gg)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%rdofillN) rCrGr!rrr rrIrrrs rr?RawTurtle.end_fill, s <<>>4>>"Q& %%dnndnn+/??&<??OO(((DNN)CD.2 2DNT^ LLN rcU(d[U[[45(a5URU5nUR[ URS5-nOnUR nU(d#UR[ URS5-nO7Uc#UR[ URS5-nURU5nUR5nUR(a-URRS/5 SURl UR5S:XaUR5 UR5 URU5 URU5 UR!S5 URU5 UR(aSURl gg!URU5 f=f)aDraw a dot with diameter size, using color. Optional arguments: size -- an integer >= 1 (if given) color -- a colorstring or a numeric color tuple Draw a circular dot with diameter size, using color. If size is not given, the maximum of pensize+4 and 2*pensize is used. Example (for a Turtle instance named turtle): >>> turtle.dot() >>> turtle.fd(50); turtle.dot(20, "blue"); turtle.fd(50) rNrTrrF)rrrrrrtrrWrIrrrbrNrYrZrXrD)rr-r:rWs rr= RawTurtle.dot@ s>$e --t,}}s4==!'<<==3t}}a+@@D|}}s4==!'<<NN5)Ehhj ?? OO % )'+DOO $  F* LLN LL  MM% LLO HHSM ??',DOO $  HHSMs A'F11Gc URRURXUUR5upEUR 5 UR R U5 UR(aURRSU45 U$)z)Performs the writing for write() wri) rrrLrrrrrIr)rrrrrrjs rrRawTurtle._writek siKK&&t~~s4:>..J   $ ?? OO % / rcnUR(a-URRS/5 SURlUR[ U5UR 5U5nU(a#UR 5upgURXW5 UR(aSURlgg)aWrite text at the current turtle position. Arguments: arg -- info, which is to be written to the TurtleScreen move (optional) -- True/False align (optional) -- one of the strings "left", "center" or right" font (optional) -- a triple (fontname, fontsize, fonttype) Write text - the string representation of arg - at the current turtle position according to align ("left", "center" or right") and with the given font. If move is True, the pen is moved to the bottom-right corner of the text. By default, move is False. Example (for a Turtle instance named turtle): >>> turtle.write('Home = ', True, align="center") >>> turtle.write((0,0), True) rTFN)rIrrrrr|r\rf)rargmoverrrjrrs rr|RawTurtle.writev s{& ?? OO % )'+DOO $kk#c(EKKM48 88:DA KK  ??',DOO $ rc6UR/UlSUlg)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)rLrrrs rr3RawTurtle.begin_poly snn% !rcSUlg)aStop recording the vertices of a polygon. No argument. Stop recording the vertices of a polygon. Current turtle position is last point of polygon. This will be connected with the first point. Example (for a Turtle instance named turtle): >>> turtle.end_poly() FN)rrs rr@RawTurtle.end_poly s #rcHURb[UR5$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)rrrs rrERawTurtle.get_poly s" :: !$ $ "rcUR$)aPReturn 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 >>> ts.bgcolor("pink") )rrs rrGRawTurtle.getscreen s{{rcU$)aReturn the Turtleobject itself. No argument. Only reasonable use: as a function to return the 'anonymous turtle': Example: >>> pet = getturtle() >>> pet.fd(50) >>> pet >>> turtles() [] rrs rrIRawTurtle.getturtle s  rc8URRU5$)zDSet delay value which determines speed of turtle animation. )rrrs rrRawTurtle._delay s{{  ''rcURRURRXU5 UR 5 g)aQBind 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)rr rrrr,s rrSRawTurtle.onclick s-$ T[[..#> rcURRURRXU5 UR 5 g)awBind 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)rrrrrr,s rrURawTurtle.onrelease s-, t{{00#C@ rcfURRURRXU5 g)a2Bind 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)rrrrr,s rrTRawTurtle.ondrags$$ DKK--s=rcURcgUS:XaAUup4URU*U-UR- 5 URR5ngUS:XaUSnUR U5 gUS:XaUR U5 gUS;a<USnUR RU5 URRU5 gUS:Xa"USnUR RUSS S S 9 gUS :XaZUSnS=Ul Ul XpR;a7UR RU5 URRU5 ggUS :Xa3[RXS5 URR5 gg) z2Does the main part of the work for undo() Nrrrrr)rr=rrxrrrrW)rIrfrUrr7rrrrr/rr r!rrW)ractionrrdegPAUdummyrrs r_undoRawTurtle._undo+se ?? "  U? ME LL%t'9'99 :OO'')E w !WF OOF # t^ NN4 ~ %7D KK   % JJ  d # x 7D KK ! !$(>')2 " 7 { "7D.2 2DNT^zz! ##D) !!$'"u_ HHT7 # OO   !rc URcgURR5nUSnUSSnUS:Xa:U(a2UR5nURUSUSS5 U(aM1ggURX#5 g)aQundo (repeatedly) the last turtle action. No argument. undo (repeatedly) the last turtle action. Number of available undo actions is determined by the size of the undobuffer. Example (for a Turtle instance named turtle): >>> for i in range(4): ... turtle.fd(50); turtle.lt(80) ... >>> for i in range(8): ... turtle.undo() ... Nrrr)rIrr)rrrrs rrxRawTurtle.undoKsy" ?? " ""$aABx U?xxz 47DH-$ JJv $r)rr r!r"rNrrLrrrrrr&r$r#rrrr%rrIr?rr|)NNNN)Fr)FrQ)Arialrrrr)*"@%:Jrr cj[Rc[5[l[R$)zReturn the singleton screen object. If none exists at the moment, create a new one and return it, else return the existing one.)r _screenrrrrr r ns!~~  >>rcn\rSrSrSrSr\SrSr\S\S\S\S4S jr S r S r S r S r Srg)rivNr*cp[Rch[5=[lUlURR[R5 URR UR 5 [Rc[Sn[Sn[Sn[Sn[Sn[SnURRXX45 URR5[l[RU[R5 URXXV5 gg)Nr{rrrrr)r_rootr~r*_titler_destroyr@rrrr r;r')rr{rrrrrs rr;_Screen.__init__|s == ). 0GMDJ JJ  W^^ , JJ  / ?? "ME(^F[)Il+J[)I[)I JJ " "5) H"jj335GO  ! !$ 8 JJui ; #rr{rrrc[URS5(dgURR5nURR5n[ U[ 5(aSUs=::aS::aO OXQ-nUcXQ- S- n[ U[ 5(aSUs=::aS::aO OXb-nUcXb- S- nURR XX45 UR5 g)aSet 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 rNrrr%)hasattrrrrrrrr-)rr{rrrrshs rr' _Screen.setups2tzz>22  ZZ ! ! # ZZ " " $ eU # #UaHE >jA%F fe $ $f)9)9YF >kQ&F v> rcz[Rb[RRU5 U[lg)a1Set title of turtle-window Argument: titlestring -- a string, to appear in the titlebar of the turtle graphics window. This is a method of Screen-class. Not available for TurtleScreen- objects. Example (for a Screen instance named screen): >>> screen.title("Welcome to the turtle-zoo!") N)rrr*r)r titlestrings rr* _Screen.titles' == $ MM   ,$rcURnU[RLa,S[lS[lS[lS[lS[ lUR5 g)NF) rrr rrr@r rr)rroots rr_Screen._destroysDzz 7== FK!FN GM"GO %  rc$UR5 g)zfShut the turtlegraphics window. Example (for a TurtleScreen instance named screen): >>> screen.bye() N)rrs rr _Screen.byes rc^U4SjnTRU5 [S(ag[5 g![a [ S5 gf=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&>TR5 g)z&Screen.bye() with two dummy-parametersN)r)rrrs rexitGracefully+_Screen.exitonclick..exitGracefullys HHJrrNr)rSrrAttributeErrorexit)rrs` rr_Screen.exitonclicksA&  ^$     J  G s 4A  A )r)rrrrrr@rrr;r'r*rrrrrrrrrvsR EG ']F<"w-X+&tK/@&P%"rrcB\rSrSrSrSrSr\S\S\S4SjrSr g) r izRawTurtle 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. Nrkrrc[Rc[5[l[R U[RUUUS9 g)N)rkrr)r rr r r;)rrkrrs rr;Turtle.__init__s; >> !#XFN4!&*8#*  ,rr) rrrrrrrrr;rrrrr r s1 DGG} $%5 6i ,rr ct0n[HnSU-n[U5RX'M! [HnSU-n[U5RX'M! [ SU-S5n[ SU55nUR S5 USSH6nUR S [U5-5 UR S X-5 M8 USnUR S [U5-5 UR S X-5 UR S 5 UR5 SSS5 g!,(df  g=f) aCreate and write docstring-dictionary to file. Optional argument: filename -- a string, used as filename default value is turtle_docstringdict Has to be called explicitly, (not used by the turtle-graphics classes) The docstring dictionary will be written to the Python script .py It is intended to serve as a template for translation of the docstrings into different languages. z_Screen.zTurtle.z%s.pyrc3b# UH%nURS5S[;dM!Uv M' g7f)rrN)r _alias_list)rrs rr&write_docstringdict.."s+=Aa ;as / /zdocsdict = { Nrz%s : z """%s """, z """%s """ z} ) _tg_screen_functionsrr_tg_turtle_functionsrr)r|reprclose)rdocsdict methodnamerrr s rrr sH* #S )) ++  "S )) + g  %=== "#9C GGHtCy( ) GG- = >2h 49$% (8=89    & % %s $B""..  2ejj\!23"#?LL.DIIi()+I x=) ##rcSSKnUcg[SnURSU-S5nURSU-5nUR SU5nU$)z>>>>>)objinitr paramslistargslist)getattrr$r __func_bodyformatrglobalsr) functionsrr7r8 docreviserrpl1pl2defstrs r_make_global_funcsrDsw )!&) "9 (C % ##Z/2$B VWY(1&..(A *% rzTurtle._screenzScreen()z Turtle._penzTurtle()__main__cL[5(a [5 g[5 gr)rOr^rVrrr switchpenrGs 88 D Drc[5 [S5 [5 [S5 [ 5 [ S5 [ S5HunUS:Xa [5 [ S5Hn[S5 [S5 M US:Xa[S5 [5 [5 [S 5 [ 5 Mw [ S 5 [S 5 [S 5 [5 [S5 [S5 [S5 [S5 [S 5 [ 5 [SS 5 [SS 5 [S5 [ S5H/n[S5 [S5 [S5 [S5 M1 [S5 [5 [ S5H/n[S5 [S5 [S5 [S5 M1 [5 g)zDemo of old turtle.py - moduleTdrr%rrZmaroonrRrrF startstartrredrN)rar+rzr1r>r{rFr2rDrQr:r?r`r|)rHrs rdemo1rOsJ t     aqAAv 1X RAvh D BK F a gu   b   b   c   lA gq e qA BK H BK "I  t  qA BK H BK "I   rc [S5 [5 [S5 [[ SS55 [ SS5S- n[ S5 [S5Hn[5 [US5 M [S5 [5(a[5 [5(aM[5 [S5 [S 5 Sn[!S 5 [S5 [S 5 [S S 5HnUS:a [#5 [%S SU-- SSU-5 [S5Hn['U5 [S5 M [)5 US- n[S5 [[5S-S-5 M [S5 [+5 ['S5 [ S5 [-5 [/SS5 [S5 [#5 [S5H0n[SS5 [ S5 ['S5 [ S5 M2 [)5 [S5 [+5 ['S5 [-5 [1S5 [35nUR5S5 [75nUR5S5 UR1S5 UR5 UR9S5 URS5 UR;5 UR=SS5 URS5 UR?5 URS5 UR/SS5 URS5 URS5 [[ U55 SnUR U5S:aUR'S5 URS 5 URUR U55 UR'S5 US!-S:Xa*URA5 URA5 [5 US- nUR U5S:aMURS"S#S$S%9 UR!S&5 UR!S5 S'n[BRD"S5 [5(a1UR5 UR5 [5(aM1UR'S5 URS(S)S*9 URGUS5 g+),zDemo of some new features.rrrrrJrzwait a moment...rgreenrLrrx FrRrNyellowr2rri(rblueoranger%g @g333333?rzCAUGHT! )rrboldr`)rrrc,[5 [5 gr)rr)r5r6s rbabademo2..babaAs M Erz Click me!)CourierrUr\)rN)$rprqrZrervr<rcrFrGr5r|ryrxrarRrrXr2rBrAr?r^rVr:rkrIrbr rQrzrJr>rrtimesleeprS)rrlaengerHtrirrr^s rdemo2res a  71a=!!Q# 2rA K 62   !!! F !!  2#  3r2A1u #bd(Ar!t,1X6 3 J bLF rF 5719b. ! 3  2 2  eH a qA 2rN rF rF rF    2  2  hk v&! X  B Q  C "   Q VH%q ! 76?#ll6"Q& IIcN IIcN NN3;;v. / FF1IrzQ   QJEll6"Q& *#8 H W U  1 !! HHJ KKM !! r  -(? A D!r)r)turtle_docstringdict)Ertkinterr9rrrarros.pathrrrcopyrr _tg_classesrr _tg_utilities__all__rrrrrrrrrr rr!r:rr>rr~objectrrrvrrr rBrrr r r rr rrr  _LANGUAGE ImportErrorr$r1r5r<rDrrrrGrOrerrrrrps0KZ  '' I ) !'/ - -0D D  (> *,  # 4 c  c  T  T     S    $    W  g  z  D  I ! "")' ,:<1t *$E*$j1 .*a#RXXa#FI6)BEE)0 B5vB5T  ) ) ,1F,1^"6f"6Li#iVCCLR6RjL6L>QjQf$ ~l~@,Y,(  D3"   MI ""$H    B'#Z1BD' *.?A z 2jaF G GMC[v1 /01Ds1 $i0M HBK LMMs*G6H 6HH H/H/.H/