zfcO@s+dZdZddlZddlZddlZddlZddlZddlm Z m Z m Z ddl m Z ddlTddd d d d d ddg Zddddddddddddddddd d!d"d#d$d%d&d'd(d)gZd*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;d<d=d>d?d@dAdBdCdDdEdFdGdHdIdJdKdLdMdNdOdPdQdRdSdTdUdVdWdXdYdZd[d\d]d^d_d`dadbdcdddedfdgdhdidjdkdldmd%dndodpdqdrd(d)dsdtdugOZdvdwdxgZdydzd{d|d}d~dddddddddddddddddddgZeeeedgeZdd+d.d;dGdKdOdUdWd\d]d_d`didndqdrgZiddr6dd6dd6dd6ed6ed6dd6dd6dd6dd6dde6ddQ6dd=6dd[6ed6dd6dd6dd6dd$6ed6ZdZdZyeeWnek rfdGHnXdefdYZdZdZddZ fdZ!dej"fdYZ#e!e#ej$ddej%fdYZ&ej$Z$de'fdYZ(de)fdYZ*de)fdYZ+de'fdYZ,de'fdYZ-de(fdYZ.de'fdYZ/de'fdYZ0de'fdYZ1d e0e/fdYZ2e2Z3dZ4de.fdYZ5d e2fdYZ6e6Z7ddZ8dZ9edZ:ye:dkrNe9e:nWn3e;k rkdGe:GHnek rde:GHnXdZ<dZ=dZ>dZ?dZ@e@ee5dde>e@ee6dde=ejAZBZAeCdkr'dZDdZEdZFeEeFeGndS(s 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: http://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. s5turtle 1.0b1 - for Python 2.6 - 30. 5. 2008, 18:08iN(tisfiletsplittjoin(tdeepcopy(t*tScrolledCanvast TurtleScreentScreent RawTurtletTurtletRawPentPentShapetVec2Dtaddshapetbgcolortbgpictbyet clearscreent colormodetdelayt exitonclickt getcanvast getshapestlistentmodetonkeyt onscreenclicktontimertregister_shapet resetscreent screensizetsetuptsetworldcoordinatesttitlettracertturtlestupdatet window_heightt window_widthtbacktbackwardt begin_fillt begin_polytbktcircletcleart clearstampt clearstampstclonetcolortdegreestdistancetdottdowntend_filltend_polytfdtfillt fillcolortforwardtget_polytgetpent getscreent getturtletgototheadingt hideturtlethomethttisdownt isvisibletlefttlttonclicktondragt onreleasetpdtpentpencolortpendowntpensizetpenuptpostpositiontputradianstrighttresett resizemodetrttsetht setheadingtsetpost setpositiont settiltanglet setundobuffertsetxtsetytshapet shapesizet showturtletspeedtsttstampttiltt tiltanglettowardst turtlesizetundotundobufferentriestuptwidthtwritetxcortycortwrite_docstringdicttdonetmainlooptacostasintatantatan2tceiltcostcoshtetexptfabstfloortfmodtfrexpthypottldexptlogtlog10tmodftpitpowtsintsinhtsqrtttanttanht Terminatorg?g?theightit canvwidthi,t canvheightt leftrightt topbottomtstandardg?i itundobuffersizetclassictblacktnoresizetvisibletenglishtlanguagetturtlet exampleturtletscreent examplescreensPython Turtle Graphicst using_IDLEcCs#t|d}|j}|ji}x|D]}|j}| s2|jdr`q2ny|jd\}}Wn#tk rd||fGHq2nX|j}|j}|d krt|}n?y+d |krt|}n t |}Wntk rnX|||s s*def %(method)s(self, *args, **kw): return s*self.%(attribute)s.%(method)s(*args, **kw)c Bs&i}e||x>|jD]0}|d dksF|ddkr ||=q q Wx$|D]}||kr[||=q[q[Wx*e|D]}||kr||=qqWxw|jD]i\}}i|d6|d6}e|ejkrei|d6|d6} n| |U|||j|(tTKtFramet__init__twinfo_toplevelt _rootwindowRpRRRRtCanvastSUNKENt_canvast Scrollbartxviewt HORIZONTALthscrolltyviewtvscrollt configuretsett rowconfiguretcolumnconfiguretgridRXtbindtonResize(RtmasterRpRRR((s%/usr/lib64/python2.7/lib-tk/turtle.pyRgs,  $$$ c Cs|r||_n|r$||_n|r6||_n|jjd|d|j d|j d|jd|jdf|jjd|j|jd|j|jjd|j|jd|j|j dS(s<Adjust canvas and scrollbars according to given canvas size.Rt scrollregionig?iN( RRRRtconfigt xview_movetoRpt yview_movetoRt adjustScrolls(RRRR((s%/usr/lib64/python2.7/lib-tk/turtle.pyRXs     cCs|jj}|jj}|jjd|j||j|jjd|j||j||jks||jkr|jjddd|ddddddd dd dd d |j jddd|ddddddd dd dd d n|jj |j j d S(sA Adjust scrollbars according to window- and canvas-size. g?RiRR R R iR R RRN( Rt winfo_widtht winfo_heightR(RR)RRR"Rt grid_forget(Rtcwidthtcheight((s%/usr/lib64/python2.7/lib-tk/turtle.pyR*s""$$ cCs|jdS(sself-explanatoryN(R*(Rtevent((s%/usr/lib64/python2.7/lib-tk/turtle.pyR$scGs|jj|S(s@ 'forward' method, which canvas itself has inherited... (Rtbbox(Rtargs((s%/usr/lib64/python2.7/lib-tk/turtle.pyR1scOs|jj||S(s@ 'forward' method, which canvas itself has inherited... (Rtcget(RR2tkwargs((s%/usr/lib64/python2.7/lib-tk/turtle.pyR3scOs|jj||dS(s@ 'forward' method, which canvas itself has inherited... N(RR'(RR2R4((s%/usr/lib64/python2.7/lib-tk/turtle.pyR'scOs|jj||dS(s@ 'forward' method, which canvas itself has inherited... N(RR#(RR2R4((s%/usr/lib64/python2.7/lib-tk/turtle.pyR#scOs|jj||dS(s@ 'forward' method, which canvas itself has inherited... N(Rtunbind(RR2R4((s%/usr/lib64/python2.7/lib-tk/turtle.pyR5scCs|jjdS(s@ 'forward' method, which canvas itself has inherited... N(Rt focus_force(R((s%/usr/lib64/python2.7/lib-tk/turtle.pyR6sN(RRRRRRXR*R$R1R3R'R#R5R6(((s%/usr/lib64/python2.7/lib-tk/turtle.pyRas       Rt_RootcBsMeZdZdZdZdZdZdZdZdZ RS(s'Root class for Screen based on Tkinter.cCstjj|dS(N(RtTkR(R((s%/usr/lib64/python2.7/lib-tk/turtle.pyRscCs8t||||||_|jjdddddS(NtexpandiR:tboth(RRtpack(RRpRR.R/((s%/usr/lib64/python2.7/lib-tk/turtle.pyt setupcanvasscCs|jS(N(R(R((s%/usr/lib64/python2.7/lib-tk/turtle.pyt _getcanvasscCs!|jd||||fdS(Ns %dx%d%+d%+d(tgeometry(RRpRtstartxtstarty((s%/usr/lib64/python2.7/lib-tk/turtle.pyt set_geometryscCs|jd|dS(NtWM_DELETE_WINDOW(t wm_protocol(Rtdestroy((s%/usr/lib64/python2.7/lib-tk/turtle.pyt ondestroyscCs |jS(N(twinfo_screenwidth(R((s%/usr/lib64/python2.7/lib-tk/turtle.pyt win_widthscCs |jS(N(twinfo_screenheight(R((s%/usr/lib64/python2.7/lib-tk/turtle.pyt win_heights( RRRRR<R=RARERGRI(((s%/usr/lib64/python2.7/lib-tk/turtle.pyR7s      tTurtleScreenBasecBs[eZdZedZedZdZdZddde dZ dZ ddde dZ dZ d Zd Zd Zdd Zd ZdddZdddZdddZdddZdZdZdZdZdZdZdZdZdZdZ ddddZ!dZ"RS( sProvide 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. cCs&tjdddd}|j|S(s$return a blank image object RpiR(Rt PhotoImagetblank(timg((s%/usr/lib64/python2.7/lib-tk/turtle.pyt _blankimages cCstjd|S(s`return an image object containing the imagedata from a gif-file named filename. tfile(RRK(R((s%/usr/lib64/python2.7/lib-tk/turtle.pyt_imagescCs||_t|tr3|jj}|jj}nat|jjd}t|jjd}|jjd| d| d|d|df||_||_d|_|_ dS(NRpRR&ig?( tcvRRRRRR3R'txscaletyscale(RRQtwth((s%/usr/lib64/python2.7/lib-tk/turtle.pyRs  1  cCs|jjdddddS(s<Create an invisible polygon item on canvas self.cv) iR:Rtoutline(iiiiii(RQtcreate_polygon(R((s%/usr/lib64/python2.7/lib-tk/turtle.pyt _createpolysc Csg}x=|D]5\}} |j||j|j| |jq W|jj|||dk r~|jj|d|n|dk r|jj|d|n|dk r|jj|d|n|r|jj|ndS(s`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. R:RVRpN(tappendRRRSRQtcoordsRt itemconfiguret tag_raise( Rtpolyitemt coordlistR:RVRpttoptclRR((s%/usr/lib64/python2.7/lib-tk/turtle.pyt _drawpoly s    c Cs.|jjdddddddddtjS(s9Create an invisible line item on canvas self.cv) iR:RRpitcapstyle(RQt create_lineRtROUND(R((s%/usr/lib64/python2.7/lib-tk/turtle.pyt _createline$s$c Cs|dk rhg}x=|D]5\}}|j||j|j| |jqW|jj||n|dk r|jj|d|n|dk r|jj|d|n|r|jj|ndS(sQConfigure 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. R:RpN(RRYRRRSRQRZR[R\( RtlineitemR^R:RpR_R`RR((s%/usr/lib64/python2.7/lib-tk/turtle.pyt _drawline*s   cCs|jj|dS(s]Delete graphics item from canvas. If item is"all" delete all graphics items. N(RQtdelete(Rtitem((s%/usr/lib64/python2.7/lib-tk/turtle.pyt_deleteAscCs|jjdS(s(Redraw graphics items on canvas N(RQR%(R((s%/usr/lib64/python2.7/lib-tk/turtle.pyt_updateGscCs|jj|dS(s-Delay subsequent canvas actions for delay ms.N(RQtafter(RR((s%/usr/lib64/python2.7/lib-tk/turtle.pyt_delayLscCs=y|jj|}t}Wntjk r8t}nX|S(sCCheck if the string color is a legal Tkinter color string. (RQt winfo_rgbRRtTclErrorR(RR2trgbtok((s%/usr/lib64/python2.7/lib-tk/turtle.pyt_iscolorstringPs   cCs@|dk r,|jjd||jn|jjdSdS(sVSet canvas' backgroundcolor if color is not None, else return backgroundcolor.RN(RRQR'RkR3(RR2((s%/usr/lib64/python2.7/lib-tk/turtle.pyt_bgcolorZs  c Cs|\}}||j}||j}idd6dd6dd6}|jj|d| d|d ||d |d |} |jj| \} } } } |jj| | dfS( sWrite 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.tswRHRtcentertseRWittexttanchorR:tfont(RRRSRQt create_textR1R%(RRSttxttalignRyRORRRxRitx0ty0tx1ty1((s%/usr/lib64/python2.7/lib-tk/turtle.pyt_writecs   ' icsYdkr&jj|d|n/fd}jj|d|||dS(sBind 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 s csKjj|jjjj|j j}}||dS(N(RQtcanvasxRRRtcanvasyRRS(R0RR(tfunR(s%/usr/lib64/python2.7/lib-tk/turtle.pyteventfun~s!N(RRQt tag_unbindttag_bind(RRiRtnumtaddR((RRs%/usr/lib64/python2.7/lib-tk/turtle.pyt_onclickus csYdkr&jj|d|n/fd}jj|d|||dS(sgBind 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. scsKjj|jjjj|j j}}||dS(N(RQRRRRRRRS(R0RR(RR(s%/usr/lib64/python2.7/lib-tk/turtle.pyRs!N(RRQRR(RRiRRRR((RRs%/usr/lib64/python2.7/lib-tk/turtle.pyt _onreleases csYdkr&jj|d|n/fd}jj|d|||dS(sqBind 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. scscyKjj|jjjj|j j}}||Wntk r^nXdS(N(RQRRRRRRRSR(R0RR(RR(s%/usr/lib64/python2.7/lib-tk/turtle.pyRs ! N(RRQRR(RRiRRRR((RRs%/usr/lib64/python2.7/lib-tk/turtle.pyt_ondrags csSdkr#jjd|n,fd}jjd|||dS(sGBind 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. s csKjj|jjjj|j j}}||dS(N(RQRRRRRRRS(R0RR(RR(s%/usr/lib64/python2.7/lib-tk/turtle.pyRs!N(RRQR5R#(RRRRR((RRs%/usr/lib64/python2.7/lib-tk/turtle.pyt_onscreenclicks csPdkr&|jjd|dn&fd}|jjd||dS(s`Bind fun to key-release event of key. Canvas must have focus. See method listen scs dS(N((R0(R(s%/usr/lib64/python2.7/lib-tk/turtle.pyRsN(RRQR5R#(RRRR((Rs%/usr/lib64/python2.7/lib-tk/turtle.pyt_onkeys cCs|jjdS(s=Set focus on canvas (in order to collect key-events) N(RQR6(R((s%/usr/lib64/python2.7/lib-tk/turtle.pyt_listenscCs6|dkr|jj|n|jj||dS(s?Install a timer, which calls fun after t milliseconds. iN(RQt after_idleRl(RRtt((s%/usr/lib64/python2.7/lib-tk/turtle.pyt_ontimers cCs|jjddd|S(s0Create and return image item on canvas. itimage(RQt create_image(RR((s%/usr/lib64/python2.7/lib-tk/turtle.pyt _createimagescCsN|\}}|jj|||j| |jf|jj|d|dS(sZConfigure image item as to draw image object at position (x,y) on canvas) RN(RQRZRRRSt itemconfig(RRiRSRRR((s%/usr/lib64/python2.7/lib-tk/turtle.pyt _drawimages (cCs*|jj|d||jj|dS(sConfigure image item as to draw image object at center of canvas. Set item to the first item in the displaylist, so it will be drawn below any other item .RN(RQRt tag_lower(RRiR((s%/usr/lib64/python2.7/lib-tk/turtle.pyt _setbgpicscCs|jj|S(sQReturn 'line' or 'polygon' or 'image' depending on type of item. (RQR(RRi((s%/usr/lib64/python2.7/lib-tk/turtle.pyt_typescCsT|jj|}gtdt|dD]}||||d f^q+}|S(s returns list of coordinate-pairs of points of item Example (for insiders): >>> from turtle import * >>> getscreen()._pointlist(getturtle().turtle._item) [(0.0, 9.9999999999999982), (0.0, -9.9999999999999982), (9.9999999999999982, 0.0)] >>> iii(RQRZtrangetlen(RRiR`titpl((s%/usr/lib64/python2.7/lib-tk/turtle.pyt _pointlists>cCs#|jjd||||fdS(NR&(RQR'(Rtsrx1tsry1tsrx2tsry2((s%/usr/lib64/python2.7/lib-tk/turtle.pyt_setscrollregionsc Cs|jj}x|D]z}|jj|}g}xF|r||d \}}|j|||j|||d}q7W|jj||qWdS(Ni(RQtfind_allRZRY( Rt xscalefactort yscalefactorRRit coordinatest newcoordlistRR((s%/usr/lib64/python2.7/lib-tk/turtle.pyt_rescales  cCst|jts"|j|jfS||koD|koDdknr_|jj|jjfS|dk rw||_n|dk r||_n|jj|||dS(saResize the canvas the turtles are drawing on. Does not alter the drawing window. N(RRQRRRRRX(RRRR((s%/usr/lib64/python2.7/lib-tk/turtle.pyt_resize s'    cCs`|jj}|dkr+|jd}n|jj}|dkrV|jd}n||fS(s; Return the width and height of the turtle window. iRpR(RQR+R,(RRpR((s%/usr/lib64/python2.7/lib-tk/turtle.pyt _window_sizes  N(#RRRt staticmethodRNRPRRXRRRaReRgRjRkRmRrRsRRRRRRRRRRRRRRRRR(((s%/usr/lib64/python2.7/lib-tk/turtle.pyRJs@              cBseZdZRS(sWill 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. (RRR(((s%/usr/lib64/python2.7/lib-tk/turtle.pyR,stTurtleGraphicsErrorcBseZdZRS(sSome TurtleGraphics Error (RRR(((s%/usr/lib64/python2.7/lib-tk/turtle.pyR5scBs&eZdZddZddZRS(sData 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. cCs||_|dkr6t|trt|}qny|dkrt|tr|jjdrt|rtj |}qqn%|dkrg}nt d|||_ dS(NtpolygonRs.giftcompoundsThere is no shape type %s( RRRRt basestringtlowertendswithRRRPRt_data(Rttype_tdata((s%/usr/lib64/python2.7/lib-tk/turtle.pyRAs   !  cCsW|jdkr%td|jn|dkr:|}n|jj|||gdS(s-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() Rs Cannot add component to %s ShapeN(RRRRRY(RtpolyR:RV((s%/usr/lib64/python2.7/lib-tk/turtle.pyt addcomponentQs   N(RRRRRR(((s%/usr/lib64/python2.7/lib-tk/turtle.pyR :s tTbuffercBsJeZdZddZddZdZdZdZdZ RS( s5Ring buffer used as undobuffer for RawTurtle objects.i cCs2||_dgg||_d|_t|_dS(Ni(tbufsizeRtbuffertptrRtcumulate(RR((s%/usr/lib64/python2.7/lib-tk/turtle.pyRks  cCsb|dkr9xFt|jD]}dg|j|d?d@dAdBdCdDdEdFdGdHdIfd6tddJdKdLdMdNdOdPdQdRdSdTdUdVdWdXdYdZd[d\d]fd$6tdd^d_d`dafd%6tddbdcddfd(6tddedfdgdhfd)6td*|jd+6|_id,d-6|_tj||||_||_td.|_ g|_ |j dS(iNRiii tarrowiiiiiiii iiiiiiiiiiiRgQ#@gQ@gGz. @gQ@gQgQgGz. gQ#gg$R-tsquaregGzg'@ttriangleRRRLRtnopicR(ii(i i(ii (ii(ii(ii (ii(ii (ii(ii(ii(ii(ii(ii(ii(ii(ii(ii(ii(ii(ii(ii(i i(ii (ii(ii (ii(i i(gQ#@gQ@(gGz. @gQ@(gQ@gGz. @(gQ@gQ#@(ii (gQgQ#@(gQgGz. @(gGz. gQ@(gQ#gQ@(ii(gQ#gQ(gGz. gQ(gQgGz. (gQgQ#(gg$(gQ@gQ#(gQ@gGz. (gGz. @gQ(gQ#@gQ(i i(i i (ii (ii(i gGz(ig'@(igGz(ii(ii(ii(ii( R RNt_shapest_bgpicsRJRt_modet _delayvalueRt _colormodet_keysR.(RRQRRR((s%/usr/lib64/python2.7/lib-tk/turtle.pyRs4            cCstd|_td|_|jd|jd|_d|_d|_d|_g|_ |j dxd D]}|j d |qqWx"|j D]}|jd |qWd t_d S( sqDelete all drawings and all turtles from the TurtleScreen. Reset empty TurtleScreen to its initial state: white background, no backgroundimage, no eventbindings and tracing on. No argument. Example (for a TurtleScreen instance named screen): >>> screen.clear() Note: this method is not available as function. RRtallRRiiRiiN(iii(RRRRjRt_bgpict _bgpicnamet_tracingt_updatecountert_turtlesRRJRRRR t_pen(RtbtnR((s%/usr/lib64/python2.7/lib-tk/turtle.pyR.s         cCs|dkr|jS|j}|dkr>td|n||_|d kr|j|j d|j d|jd|jdd|_|_n|j dS( shSet 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' RtlogotworldsNo turtle-graphics-mode %sig?N(RRR(RR( RRRRRRRRRRSRX(RR((s%/usr/lib64/python2.7/lib-tk/turtle.pyRs     cCs|jdkr"|jdnt||}t||}|j\}}|j|d|d|j|j} } |j||_|j||_||j} | |j} |j| } |j| }|j| | | ||j |j| |j| |j dS(ssSet 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) RiN( RRRRRRRSRRRRR%(Rtllxtllyturxturytxspantyspantwxtwyt oldxscalet oldyscaleRRRR((s%/usr/lib64/python2.7/lib-tk/turtle.pyR!s    cCs|dkrO|jjdr<td|j|}qptddn!t|trptd|}n||j|>> screen.register_shape("triangle", ((5,-3),(0,5),(-5,-3))) s.gifRs"Bad arguments for register_shape. sUse help(register_shape)RN( RRRR RPRRRR(RtnameRc((s%/usr/lib64/python2.7/lib-tk/turtle.pyRs  cCsnt|dkr|d}nt|trf|j|sI|dkrM|Stdt|ny|\}}}Wn-ttfk rtdt|nX|jdkrg|||fD]}t d|^q\}}}nd|kodknoAd|ko#dknoAd|ko?dkns]td t|nd |||fS( sReturn 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. iiRsbad color string: %ssbad color arguments: %sg?go@isbad color sequence: %ss #%02x%02x%02x( RRRRrRRt TypeErrorRRtround(RR2RtgtbR((s%/usr/lib64/python2.7/lib-tk/turtle.pyt _colorstrBs  8TcCs|jds|St|dkrUgd D] }t|||d!d^q,}nSt|dkrg|dD]}dt||d^qr}ntd |tg|D]}||jd ^qS( NRiiiiiiisbad colorstring: %si(iii(RRRRRR(RtcstrRR`RUR((s%/usr/lib64/python2.7/lib-tk/turtle.pyt_color]s01cCsS|dkr|jS|dkr1t||_n|dkrOt||_ndS(sqReturn 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) g?iN(RRRR(Rtcmode((s%/usr/lib64/python2.7/lib-tk/turtle.pyRhs    cCs2x+|jD] }|j|j|jq WdS(sReset all Turtles on the Screen to their initial state. No argument. Example (for a TurtleScreen instance named screen): >>> screen.reset() N(Rt_setmodeRRX(RR((s%/usr/lib64/python2.7/lib-tk/turtle.pyRX}scCs|jS(sReturn the list of turtles on the screen. Example (for a TurtleScreen instance named screen): >>> screen.turtles() [] (R(R((s%/usr/lib64/python2.7/lib-tk/turtle.pyR$scGsO|r|j|}nd}|j|}|dk rK|j|}n|S(sSet 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(RRRsR(RR2R2((s%/usr/lib64/python2.7/lib-tk/turtle.pyRs cCsc|dkr|jSt||_d|_|dk rIt||_n|jr_|jndS(seTurns 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 iN(RRRRRR%(RtnR((s%/usr/lib64/python2.7/lib-tk/turtle.pyR#s    cCs&|dkr|jSt||_dS(s Return or set the drawing delay in milliseconds. Optional argument: delay -- positive integer Example (for a TurtleScreen instance named screen): >>> screen.delay(15) >>> screen.delay() 15 N(RRR(RR((s%/usr/lib64/python2.7/lib-tk/turtle.pyRs cCsRtjstt_tn|jdkrN|jd7_|j|j;_ndS(sIncrement update counter.iiN(Rt_RUNNINGRRRR(R((s%/usr/lib64/python2.7/lib-tk/turtle.pyt _incrementudcs    cCsT|j}t|_x(|jD]}|j|jqW||_|jdS(s'Perform a TurtleScreen update. N(RRR$t _update_datat _drawturtleRk(RttracingR((s%/usr/lib64/python2.7/lib-tk/turtle.pyR%s    cCs|jdS(s Return the width of the turtle window. Example (for a TurtleScreen instance named screen): >>> screen.window_width() 640 i(R(R((s%/usr/lib64/python2.7/lib-tk/turtle.pyR'scCs|jdS(s Return the height of the turtle window. Example (for a TurtleScreen instance named screen): >>> screen.window_height() 480 i(R(R((s%/usr/lib64/python2.7/lib-tk/turtle.pyR&scCs|jS(sReturn the Canvas of this TurtleScreen. No argument. Example (for a Screen instance named screen): >>> cv = screen.getcanvas() >>> cv (RQ(R((s%/usr/lib64/python2.7/lib-tk/turtle.pyRs cCst|jjS(sReturn 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'] (tsortedRR(R((s%/usr/lib64/python2.7/lib-tk/turtle.pyRs icCs|j|||dS(sBind 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 and a Turtle instance named turtle): >>> screen.onclick(goto) >>> # Subsequently clicking into the TurtleScreen will >>> # make the turtle move to the clicked point. >>> screen.onclick(None) N(R(RRRR((s%/usr/lib64/python2.7/lib-tk/turtle.pyRJscCsg|dkr1||jkrS|jj|qSn"||jkrS|jj|n|j||dS(smBind 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(RRtremoveRYR(RRR((s%/usr/lib64/python2.7/lib-tk/turtle.pyR#s  cCs|jdS(sSet 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(Rtxdummytydummy((s%/usr/lib64/python2.7/lib-tk/turtle.pyRAs icCs|j||dS(sInstall 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(R(RRR((s%/usr/lib64/python2.7/lib-tk/turtle.pyRMscCsb|dkr|jS||jkr;|j||j|>> screen.bgpic() 'nopic' >>> screen.bgpic("landscape.gif") >>> screen.bgpic() 'landscape.gif' N(RRRRPRR(Rtpicname((s%/usr/lib64/python2.7/lib-tk/turtle.pyRbs  cCs|j|||S(sResize 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(RRRR((s%/usr/lib64/python2.7/lib-tk/turtle.pyRzsN($RRRRRRRR.RRR!RRRRRXR$RR#RRR%R'R&RRRJRRRRRRRRR(((s%/usr/lib64/python2.7/lib-tk/turtle.pyRs@  " ' $        t TNavigatorcBseZdZieddd6eddd6eddd6ZdZdZdZedZd Z d%d Z d Z d d Z dZdZdZdZdZdZdZdZdZdZdZd%dZdZdZdZd%dZd%dZdZd Z d%d%d!Z!dd"Z"d%d%d#Z#d%d$Z$eZ%eZ&eZ'eZ(eZ)eZ*eZ+eZ,e Z-RS(&sRNavigation part of the RawTurtle. Implements methods for turtle movement. g?gRRRiicCs[|j|_|j|_||_d|_|jd|_|j|t j |dS(N( tDEFAULT_ANGLEOFFSETt _angleOffsettDEFAULT_ANGLEORIENTt _angleOrientRRt undobufferR3RRRX(RR((s%/usr/lib64/python2.7/lib-tk/turtle.pyRs       cCs)tdd|_tj|j|_dS(sXreset turtle to its initial values Will be overwritten by parent class gN(R t _positionRtSTART_ORIENTATIONRt_orient(R((s%/usr/lib64/python2.7/lib-tk/turtle.pyRXscCsj|dkr|jS|d kr#dS||_|d krMd|_d|_n|jd|_d|_dS( s:Set turtle-mode to 'standard', 'world' or 'logo'. RRRNiig@i(RRR(RR(RRRRt _fullcircle(RR((s%/usr/lib64/python2.7/lib-tk/turtle.pyRs      cCsB||_d||_|jdkr1d|_n |d|_dS(s+Helper function for degrees() and radians()ihRig@N(Rt _degreesPerAURR(Rt fullcircle((s%/usr/lib64/python2.7/lib-tk/turtle.pyt_setDegreesPerAUs    gv@cCs|j|dS(s> 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. Dafault 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(R(RR((s%/usr/lib64/python2.7/lib-tk/turtle.pyR3scCs|jdtjdS(s Set the angle measurement units to radians. No arguments. Example (for a Turtle instance named turtle): >>> turtle.heading() 90 >>> turtle.radians() >>> turtle.heading() 1.5707963267948966 iN(RRR(R((s%/usr/lib64/python2.7/lib-tk/turtle.pyRVs cCs%|j|j|}|j|dS(s)move turtle forward by specified distanceN(RRt_goto(RR4tende((s%/usr/lib64/python2.7/lib-tk/turtle.pyt_goscCs&||j9}|jj||_dS(s=Turn turtle counterclockwise by specified angle if angle > 0.N(RRR(RR((s%/usr/lib64/python2.7/lib-tk/turtle.pyt_rotates cCs ||_dS(smove turtle to position end.N(R(Rtend((s%/usr/lib64/python2.7/lib-tk/turtle.pyRscCs|j|dS(sMove 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(R(RR4((s%/usr/lib64/python2.7/lib-tk/turtle.pyR<scCs|j| dS(sMove 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) N(R(RR4((s%/usr/lib64/python2.7/lib-tk/turtle.pyR(scCs|j| dS(sTurn 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(R(RR((s%/usr/lib64/python2.7/lib-tk/turtle.pyRW'scCs|j|dS(sTurn 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 N(R(RR((s%/usr/lib64/python2.7/lib-tk/turtle.pyRH<scCs|jS(sReturn 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) (R(R((s%/usr/lib64/python2.7/lib-tk/turtle.pyRSQs cCs |jdS(s Return the turtle's x coordinate. No arguments. Example (for a Turtle instance named turtle): >>> reset() >>> turtle.left(60) >>> turtle.forward(100) >>> print turtle.xcor() 50.0 i(R(R((s%/usr/lib64/python2.7/lib-tk/turtle.pyRr^s cCs |jdS(s  Return the turtle's y coordinate --- No arguments. Example (for a Turtle instance named turtle): >>> reset() >>> turtle.left(60) >>> turtle.forward(100) >>> print turtle.ycor() 86.6025403784 i(R(R((s%/usr/lib64/python2.7/lib-tk/turtle.pyRsls cCs<|dkr"|jt|n|jt||dS(stMove 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(RRR (RRR((s%/usr/lib64/python2.7/lib-tk/turtle.pyRA{s cCs!|jdd|jddS(s$Move turtle to the origin - coordinates (0,0). No arguments. Move turtle to the origin - coordinates (0,0) and set its heading to its start-orientation (which depends on mode). Example (for a Turtle instance named turtle): >>> turtle.home() iN(RAR\(R((s%/usr/lib64/python2.7/lib-tk/turtle.pyRDs cCs!|jt||jddS(sSet 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) iN(RR R(RR((s%/usr/lib64/python2.7/lib-tk/turtle.pyRascCs!|jt|jd|dS(sSet 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) iN(RR R(RR((s%/usr/lib64/python2.7/lib-tk/turtle.pyRbscCs|dk rt||}nt|tr6|}n9t|trTt|}nt|tro|j}nt||jS(sReturn 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 N(RR RRRRtabs(RRRRS((s%/usr/lib64/python2.7/lib-tk/turtle.pyR4s   cCs|dk rt||}nt|tr6|}n9t|trTt|}nt|tro|j}n||j\}}ttj||dtj dd}||j :}|j |j ||j S(sCReturn 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 gf@i gv@N(RR RRRRRRRzRRRRR(RRRRStresult((s%/usr/lib64/python2.7/lib-tk/turtle.pyRks   * cCs_|j\}}ttj||dtjdd}||j:}|j|j||jS(s Return the turtle's current heading. No arguments. Example (for a Turtle instance named turtle): >>> turtle.left(67) >>> turtle.heading() 67.0 gf@i gv@( RRRRzRRRRR(RRRR ((s%/usr/lib64/python2.7/lib-tk/turtle.pyRBs * cCsK||j|j}|j}||d||d}|j|dS(sSet 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 g@N(RBRRR(Rtto_angleRtfull((s%/usr/lib64/python2.7/lib-tk/turtle.pyR\"s c Cs|jr+|jjdgt|j_n|j}|d krO|j}n|d krt||j}dtt dt|dd|}nd||}d|}d|t j |t j d |j }|d kr| | | }}}n|j} |j} |d kr:|jd d n |jd |j|xHt|D]:} |j||j||jd |j|qaW|j| |d kr|j| | n|j||jrt|j_nd S( s 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 tseqii g@gM@g?g?g@gf@iN(RRRRRfRRR RtminRRRRR#RmRRRR( RtradiustextenttstepsRftfracRTtw2tlttrtdlR((s%/usr/lib64/python2.7/lib-tk/turtle.pyR->s>     . )            cCsdS(s/dummy method - to be overwritten by child classN((RR((s%/usr/lib64/python2.7/lib-tk/turtle.pyRfRcCsdS(s/dummy method - to be overwritten by child classN((RtaR((s%/usr/lib64/python2.7/lib-tk/turtle.pyR#RcCsdS(s/dummy method - to be overwritten by child classN((RR((s%/usr/lib64/python2.7/lib-tk/turtle.pyRmRN(.RRRR Rt DEFAULT_MODERRRRXRRRR3RVRRRR<R(RWRHRSRrRsRARDRaRbR4RkRBR\R-RfR#RmR9R,R)RZRIRTR]R^R[(((s%/usr/lib64/python2.7/lib-tk/turtle.pyRsZ              #    #  A  tTPencBs eZdZeddZededdZddZddZdZ d Z d Z dd Z d Z d ZdZdZdZdZddZedZeedZdZdZeZe Ze Ze Ze ZeZeZ RS(sFDrawing part of the RawTurtle. Implements drawing properties. RYcCs#||_d|_tj|dS(N(t _resizemodeRRRt_reset(RRY((s%/usr/lib64/python2.7/lib-tk/turtle.pyRs  ROR;cCsUd|_t|_||_||_t|_d|_d|_d|_d|_ dS(Niii(ii( t_pensizeRt_shownt _pencolort _fillcolort_drawingt_speedt_stretchfactort_tiltt _outlinewidth(RROR;((s%/usr/lib64/python2.7/lib-tk/turtle.pyRs        cCsB|dkr|jS|j}|dkr>|jd|ndS(szSet 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' tautotuserRRYN(R%R&R(RRRRN(Rtrmode((s%/usr/lib64/python2.7/lib-tk/turtle.pyRYs    cCs'|dkr|jS|jd|dS(s!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 RQN(RRRN(RRp((s%/usr/lib64/python2.7/lib-tk/turtle.pyRQs cCs!|js dS|jdtdS(sPull the pen up -- no drawing when moving. Aliases: penup | pu | up No argument Example (for a Turtle instance named turtle): >>> turtle.penup() NRP(R RNR(R((s%/usr/lib64/python2.7/lib-tk/turtle.pyRRs cCs!|jr dS|jdtdS(sPull the pen down -- drawing when moving. Aliases: pendown | pd | down No argument. Example (for a Turtle instance named turtle): >>> turtle.pendown() NRP(R RNR(R((s%/usr/lib64/python2.7/lib-tk/turtle.pyRPs cCs|jS(sReturn 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%/usr/lib64/python2.7/lib-tk/turtle.pyRFs cCsidd6dd6dd6dd6d d 6}|dkr<|jS||krU||}n7d |kold knrtt|}nd}|jd |dS(s 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) itfastesti tfastitnormalitslowitslowestg?g%@RfN(RR!RRRN(RRftspeeds((s%/usr/lib64/python2.7/lib-tk/turtle.pyRfs)   cGs|rt|}|dkr/|d}}n4|dkrJ|\}}n|dkrc|}}n|j|}|j|}|jd|d|n"|j|j|j|jfSdS(sReturn 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 mor 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') iiiiROR;N(RRRNRRR(RR2Rtpcolortfcolor((s%/usr/lib64/python2.7/lib-tk/turtle.pyR2+s      cGsO|r;|j|}||jkr(dS|jd|n|j|jSdS(sZ 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' NRO(RRRNR(RR2R2((s%/usr/lib64/python2.7/lib-tk/turtle.pyROYs cGsO|r;|j|}||jkr(dS|jd|n|j|jSdS(s] 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) NR;(RRRNR(RR2R2((s%/usr/lib64/python2.7/lib-tk/turtle.pyR;~s cCs|jdtdS(sMakes the turtle visible. Aliases: showturtle | st No argument. Example (for a Turtle instance named turtle): >>> turtle.hideturtle() >>> turtle.showturtle() tshownN(RNR(R((s%/usr/lib64/python2.7/lib-tk/turtle.pyRes cCs|jdtdS(sYMakes 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() R0N(RNR(R((s%/usr/lib64/python2.7/lib-tk/turtle.pyRCscCs|jS(sReturn 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%/usr/lib64/python2.7/lib-tk/turtle.pyRGs c Ks9i |jd6|jd6|jd6|jd6|jd6|jd6|jd6|jd6|jd 6|j d 6}|ps|sz|St |t r|}ni}|j |i}x|D]}||||>> 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} >>> 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} >>> 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} R0RPROR;RQRfRYt stretchfactorRVRiRNN(RR RRRR!RR"R$R#RtdictR%RRRRRRt_newLineRRRRk( RRNtpendictt_pdtpt_p_bufRtnewLinetsf((s%/usr/lib64/python2.7/lib-tk/turtle.pyRNsz.                                  cCsdS(s/dummy method - to be overwritten by child classN((RtusePos((s%/usr/lib64/python2.7/lib-tk/turtle.pyR3@ RcCsdS(s/dummy method - to be overwritten by child classN((RRtforced((s%/usr/lib64/python2.7/lib-tk/turtle.pyRkB RcCsdS(s/dummy method - to be overwritten by child classN((RR2((s%/usr/lib64/python2.7/lib-tk/turtle.pyRD RcCsdS(s/dummy method - to be overwritten by child classN((RR2((s%/usr/lib64/python2.7/lib-tk/turtle.pyRF RN(!RRRRRRRRYRQRRRPRFRfR2ROR;ReRCRGRNRR3RRkRRRpRoRURMR6RgRE(((s%/usr/lib64/python2.7/lib-tk/turtle.pyRs8      & . % $  u   t _TurtleImagecBs eZdZdZdZRS(s6Helper class: Datatype to store Turtle attributes cCs#||_d|_|j|dS(N(RRRt _setshape(RRt shapeIndex((s%/usr/lib64/python2.7/lib-tk/turtle.pyRV s  cCse|j}||_|jdko6|j|jknr?dS|jdkoc|j|jknrldS|jdkr|j|jn3|jdkrx!|jD]}|j|qWn|j|j|_|jdkr|j|_nl|jdkr#|j|jdj|_n>|jdkrag|j|jD]}|j^qC|_ndS(NRRRRL(RR( RR>RRRjt_itemRXRR(RR>RRi((s%/usr/lib64/python2.7/lib-tk/turtle.pyR=[ s&  ))(RRRRR=(((s%/usr/lib64/python2.7/lib-tk/turtle.pyR<R s cBseZdZgZd8edededdZdZdZdZ dZ d Z d Z d Z d8d8d Zd ZdZdZdZd8dZd8d8d8dZdZdZdZdZdZdZdZdZd8dZdZdZdZ e!dZ"d8d Z#d!Z$d"Z%d8d#Z&d$Z'e(d%d9d)Z)d*Z*d+Z+d,Z,d-Z-d.Z.e.Z/d/Z0d0Z1d8d1Z2d2d8d3Z3d2d8d4Z4d2d8d5Z5d6Z6d7Z7eZ8RS(:svAnimation part of the RawTurtle. Puts RawTurtle upon a TurtleScreen and provides tools for its animation. RcRRcCst|tr||_nt|trX|tjkrLtjj|n||_nzt|ttfrxbtjD]"}|j |krw||_PqwqwWt||_tjj|jnt d||j}t j ||j tj ||jj||j|_t|||_d|_t|_d|_|_||_t|_|j|_|jg|_|jg|_g|_ ||_!t"||_#|j$dS(Nsbad canvas argument %s(%Rt_ScreenRRRtscreensRYRRRQRRRRRRRetdrawingLineItemR<RRt_polyRt _creatingPolyt _fillitemt _fillpathRt_hidden_from_screentcurrentLineItemRt currentLineRt stampItemst_undobuffersizeRRRk(RtcanvasRcRRR((s%/usr/lib64/python2.7/lib-tk/turtle.pyRx s@           cCs<tj|tj||j|j|jdS(sDelete 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(RRXRRt_clearRRk(R((s%/usr/lib64/python2.7/lib-tk/turtle.pyRX s     cCs7|dks|dkr$d|_nt||_dS(sSet 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) iN(RRR(Rtsize((s%/usr/lib64/python2.7/lib-tk/turtle.pyR` s cCs |jdkrdS|jjS(sReturn count of entries in the undobuffer. No argument. Example (for a Turtle instance named turtle): >>> while undobufferentries(): ... undo() iN(RRR(R((s%/usr/lib64/python2.7/lib-tk/turtle.pyRn s cCsd|_|_x!|jD]}|jj|qW|jj|_g|_|j rn|jj |j n|jg|_|j |j |jdS(sDelete all of pen's drawingsN(RRERFRRRjReRHRIR RYRR0R`RK(RRi((s%/usr/lib64/python2.7/lib-tk/turtle.pyRM s   cCs|j|jdS(sgDelete 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(RMRk(R((s%/usr/lib64/python2.7/lib-tk/turtle.pyR. s cCsd|jj|jjdkr#dSt|jdkr`|jj|j|j|j|jndS(Nii( RRRRRIRgRHRR(R((s%/usr/lib64/python2.7/lib-tk/turtle.pyR s  cCs|j}|jdkrdS|jdkr\|j|j|j|j|jnG|j|jdkrx|jD]}|jqW|jndS(s&Perform a Turtle-data update. iNi( RRRRRkRmRRR$(RRR((s%/usr/lib64/python2.7/lib-tk/turtle.pyRk s     cCs|jj||S(smTurns 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#(RtflagR((s%/usr/lib64/python2.7/lib-tk/turtle.pyR# scCs|jj|S(N(RR(RR2((s%/usr/lib64/python2.7/lib-tk/turtle.pyR% scCs|jj|S(N(RR(RR2((s%/usr/lib64/python2.7/lib-tk/turtle.pyR( scCst|tr|Sy|\}}}Wn-ttfk rUtdt|nX|jjdkrg|||fD]}td|^qx\}}}nd|kodknod|kodknod|kodkns tdt|nd|||fS(s,Convert colortriples to hexstrings. sbad color arguments: %sg?go@iisbad color sequence: %ss #%02x%02x%02x( RRRRRRRRR(RR2RRRR((s%/usr/lib64/python2.7/lib-tk/turtle.pyt_cc+ s8TcCsI|j}|j|j|j}d|_d|_t|}||_||_||_t||jj|_|jj ||j |jjj }|dkr|j |j_ nr|dkr|j|j dj|j_ nD|dkr,g|j |jjjD]}|j ^q |j_ n|j|_|j|S(sCreate 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() RRRLRN(RR3R RRRR<R>RRYRRRXR?RRReRHRk(RRRtqtttypeRi((s%/usr/lib64/python2.7/lib-tk/turtle.pyR1: s,          " 5 cCs\|dkr|jjS||jjkr>td|n|jj||jdS(sSet 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' sThere is no shape named %sN(RRR>RRRR=Rk(RR((s%/usr/lib64/python2.7/lib-tk/turtle.pyRcb s   cCs||ko"|ko"dknrF|j\}}|||jfS|dk r||dkrm||f}q||f}n+|dk r|jd|f}n |j}|dkr|j}n|jddd|d|dS(sOSet/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) iRYR&R1RVN(RR"R$RN(Rt stretch_widt stretch_lenRVR1((s%/usr/lib64/python2.7/lib-tk/turtle.pyRd} s'      cCsK| |j|j}|tjddtj}|jddd|dS(sZRotate the turtleshape to point in the specified direction 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). Examples (for a Turtle instance named turtle): >>> turtle.shape("circle") >>> turtle.shapesize(5,2) >>> turtle.settiltangle(45) >>> stamp() >>> turtle.fd(50) >>> turtle.settiltangle(-45) >>> stamp() >>> turtle.fd(50) gf@iRYR&RiN(RRRRRN(RRRi((s%/usr/lib64/python2.7/lib-tk/turtle.pyR_ scCs.|j dtj|j}||j|jS(sReturn the current tilt-angle. No argument. 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.tilt(45) >>> turtle.tiltangle() gf@(R#RRRRR(RRi((s%/usr/lib64/python2.7/lib-tk/turtle.pyRj scCs|j||jdS(sRotate 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(R_Rj(RR((s%/usr/lib64/python2.7/lib-tk/turtle.pyRi sc Cs|j}|j\}}|j\}}t|||j|j}dt||\}}g|D]G\}} ||||| |j|| ||| |jf^qeS(slComputes transformed polygon shapes from a shape according to current position and heading. g?(RRRR RSRRR ( RRRtp0tp1te0te1R~RR((s%/usr/lib64/python2.7/lib-tk/turtle.pyt _polytrafo s c Cs}|j}|j|jj}|j}|jj}|jr|jdkr|jdkrt |_ |j }|dkr|j dkrd}|}n|j dkrt d|jd}}|j}d} n3|j dkr|j\}}|j}|j} ng|D] \} } || || f^q }tj| tj| } } g|D]1\} } | | | | | | | | f^qU}|j|}|j|j}}|j||d|d |d |d tqy|d kr|j||j|qy|d kry|j\}}|j}xt||D]\}\}}}g|D] \} } || || f^qN}|j|}|j||d|j|d |j|d |d tq2Wqyn|j rdS|dkr|j|dddfddnn|d kr1|j||j|jdj n?|d krpx0|D]%}|j|dddfddqDWnt|_ dS(spManages the correct rendering of the turtle with respect to its shape, resizemode, stretch and tilt etc.iRRiR%g@R&R:RVRpR_RRNRRL(ii(ii(ii(ii(ii(ii(RRRR>RR?RRRRRGRRtmaxRR"R$R#RRR|RYRRRaRRRtzipRP(RRRcRRttitemttshapeRTtlxtlyRjRRtt0tt1tfctocRiR((s%/usr/lib64/python2.7/lib-tk/turtle.pyR s^   '        ->   %-&  "   &c Cs |j}|j|jj}|j}|j}|dkr|j}|jdkrdd}|}n|jdkrtd|j d}}|j }d} n3|jdkr|j \}}|j }|j } ng|D] \} } || || f^q}t j| t j| } } g|D]1\} } | | | | | | | | f^q%}|j|}|j|j}}|j||d|d |d |d tn6|d kr|jd }|j||j|n|dkrg}x'|D]}|j}|j|qWt|}|j \}}|j }xt||D]\}\}}}g|D] \} } || || f^qi}|j|}|j||d|j|d |j|d |d tqMWn|jj||jjd|f|S(sStamp 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) RRiR%g@iR&R:RVRpR_RRRRh(RRRR>RRRXRRZRR"R$R#RRR|RYRRRaRRRRRYRR[RPRJRR(RRRcRRR]tstitemRTR^R_RjRRR`RaRbRctelementRiR((s%/usr/lib64/python2.7/lib-tk/turtle.pyRh$ sV          ->      %-#cCs||jkret|trBx1|D]}|jj|q%Wn|jj||jj|nd|f}|j}||jkrdS|jj|}|jj|||j kr|j d|j |_ n|jj |j d|j dgdS(s9does the work for clearstamp() and clearstamps() RhNi( RJRRRRjRRRtindexRRtinsertR(RtstampidtsubitemRitbufRf((s%/usr/lib64/python2.7/lib-tk/turtle.pyt _clearstamp` s   cCs|j||jdS(sDDelete 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(RkRk(RRh((s%/usr/lib64/python2.7/lib-tk/turtle.pyR/v s cCsn|dkr|j}n)|dkr5|j| }n |j|}x|D]}|j|qIW|jdS(sDelete 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() iN(RRJRkRk(RRttoDeleteRi((s%/usr/lib64/python2.7/lib-tk/turtle.pyR0 s     c Csf|j|j|jt|jtf}|j}d|j|||j|j |j |j|j ff}|j r|j j |n|j}|jr|jdkr||}|d|jd|d|jd}dt|ddd|j|j}|d|} xtd|D]s} | dkr=t} nt} || | |_|jr|j|j||jf|j|j| n|jq"W|jr|j|jddfd d d |jqn|jr|j j|nt|jtr|jj|n||_|jr6|jj|nt|j d krX|jn|jd S(sMove the pen to the point end, thereby drawing a line if pen is down. All other methods for turtle movement depend on this one. tgoiiig?ig?g?R:RRpi*N(ii(ii(R RRRRFRRRRHRIRRRRR!RRRRSRRRRRgRBRkRYRDRCRR3( RRtgo_modesRt undo_entrytstarttdifftdiffsqtnhopstdeltaRR_((s%/usr/lib64/python2.7/lib-tk/turtle.pyR sR    (*          cCs|\}}}}|\}}}} |\} } } } |j}t|j|dkr`dGHn| |_| |_| ddgkrd}n|}|j| | d|d|g|jD]-}|| kr|j|dkr|^q}x+|D]#}|j||jj |qW|}|j rQ|j dkrQ||}|d|j d |d|j d }dt|dd d |j |j }|d |}x{td|D]j}|dkrt}nt}||||_|r|j|j||jf|||n|jqW|rQ|j|jddfddd|qQn||_|jrt|jdkr|jjn|jgkrt|_d|_qn| r|jgkrd|_d GHq|jdk r|jjqn|jdS(s)Reverse a _goto. Used for undo() g?s$undogoto: HALLO-DA-STIMMT-WAS-NICHT!iRR:RpRiiig?g?sUnwahrscheinlich in _undogoto!N(ii(ii(ii(ii(RR RRHRIRgRRRjRR!RRRRSRRRRRBRkRDRRCRRRF(RtentrytoldtnewRntcoodatatdrawingtpctpstfillingtcLItcLRRRtusepcRttodeleteRpRqRrRsRtRR_((s%/usr/lib64/python2.7/lib-tk/turtle.pyt _undogoto sd    !   (*        cCs|jr(|jjd||jfn||j9}|jj|}|jj}|dkr|jdkrd|j}dtt ||}d||}x6t |D]%}|jj||_|j qWn||_|j dS(s&Turns pen clockwise by angle. trotiig@g?N( RRRRRRRR!RR RRk(RRt neworientRtanglevelRRtR((s%/usr/lib64/python2.7/lib-tk/turtle.pyR s     cCst|jdkrb|jj|j|j|j|j|jj|_|jj |jn|jj|jdt g|_|r|j g|_ndS(sCloses current line item and starts a new one. Remark: if current line became too long, animation performance (via _drawline) slowed down considerably. iR_N( RRIRRgRHRRReRRYRR(RR:((s%/usr/lib64/python2.7/lib-tk/turtle.pyR3) s cCsmt|jt}|dkr"|S|j}d}}|rt|jdkr|jj|j|jd|jd|jf}qn|r|jj |_|j j |j|j g|_d|jf}|j nd|_|_|jr_|dkr$|d kr\|jj|q\q_|d krC|jj|q_|jjd||gn|jdS( sCall fill(True) before drawing a shape to fill, fill(False) when done. Optional argument: flag -- True/False (or 1/0 respectively) Call fill(True) before drawing the shape you want to fill, and fill(False) when done. When used without argument: return fillstate (True if filling, False else) Example (for a Turtle instance named turtle): >>> turtle.fill(True) >>> turtle.forward(100) >>> turtle.left(90) >>> turtle.forward(100) >>> turtle.left(90) >>> turtle.forward(100) >>> turtle.left(90) >>> turtle.forward(100) >>> turtle.fill(False) iR:tdofillt beginfillR N(((((RRFRRRRRaRERRXRRYRR3RRRk(RROR|Rtentry1tentry2((s%/usr/lib64/python2.7/lib-tk/turtle.pyR:9 s2         cCs|jtdS(sCalled just before drawing a shape to be filled. No argument. Example (for a Turtle instance named turtle): >>> turtle.begin_fill() >>> turtle.forward(100) >>> turtle.left(90) >>> turtle.forward(100) >>> turtle.left(90) >>> turtle.forward(100) >>> turtle.left(90) >>> turtle.forward(100) >>> turtle.end_fill() N(R:R(R((s%/usr/lib64/python2.7/lib-tk/turtle.pyR*l scCs|jtdS(sFill the shape drawn after the call begin_fill(). No argument. Example (for a Turtle instance named turtle): >>> turtle.begin_fill() >>> turtle.forward(100) >>> turtle.left(90) >>> turtle.forward(100) >>> turtle.left(90) >>> turtle.forward(100) >>> turtle.left(90) >>> turtle.forward(100) >>> turtle.end_fill() N(R:R(R((s%/usr/lib64/python2.7/lib-tk/turtle.pyR7~ scGs|stt|ttfrF|j|}|jt|jd}q|j}|s|jt|jd}qn7|dkr|jt|jd}n|j|}t|j dr |j j |j ||}|j j ||jr|jjd|fqn|j}|jrD|jjdgt|j_nzT|jdkrf|jn|j|j||j||jdWd|j|X|jrt|j_ndS(sDraw 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) it_dotR5R R%iN(RRRRRRZRRthasattrRRRRRYRRRNRRRYRERPRQROR<R(RRNR2RiRN((s%/usr/lib64/python2.7/lib-tk/turtle.pyR5 s:          cCs`|jj|j||||j\}}|jj||jr\|jjd|fn|S(s)Performs the writing for write() twri(RRRRRRYRR(RR{R|RyRiR((s%/usr/lib64/python2.7/lib-tk/turtle.pyR s  RHtArialiR*cCs|jr+|jjdgt|j_n|jt||j|}|rw|j\}}|j||n|jrt |j_ndS(sWrite 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 N( RRRRRRRRSR]R(RtargtmoveR|RyRRR((s%/usr/lib64/python2.7/lib-tk/turtle.pyRq s ! cCs|jg|_t|_dS(sStart 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() N(RRCRRD(R((s%/usr/lib64/python2.7/lib-tk/turtle.pyR+ s cCs t|_dS(s7Stop 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() N(RRD(R((s%/usr/lib64/python2.7/lib-tk/turtle.pyR8 s cCs |jdk rt|jSdS(sReturn the lastly recorded polygon. No argument. Example (for a Turtle instance named turtle): >>> p = turtle.get_poly() >>> turtle.register_shape("myFavouriteShape", p) N(RCRR(R((s%/usr/lib64/python2.7/lib-tk/turtle.pyR= s cCs|jS(sReturn 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") (R(R((s%/usr/lib64/python2.7/lib-tk/turtle.pyR? scCs|S(sUReturn the Turtleobject itself. No argument. Only reasonable use: as a function to return the 'anonymous turtle': Example: >>> pet = getturtle() >>> pet.fd(50) >>> pet >>> turtles() [] ((R((s%/usr/lib64/python2.7/lib-tk/turtle.pyR@" scCs|jjdS(s Returns the width of the turtle window. No argument. Example (for a TurtleScreen instance named screen): >>> screen.window_width() 640 i(RR(R((s%/usr/lib64/python2.7/lib-tk/turtle.pyR': s cCs|jjdS(s Return the height of the turtle window. No argument. Example (for a TurtleScreen instance named screen): >>> screen.window_height() 480 i(RR(R((s%/usr/lib64/python2.7/lib-tk/turtle.pyR&E s cCs|jj|S(sDSet delay value which determines speed of turtle animation. (RR(RR((s%/usr/lib64/python2.7/lib-tk/turtle.pyRmP sicCs-|jj|jj||||jdS(sBind fun to mouse-click event on this turtle on canvas. Arguments: fun -- a function with two arguments, to which will be assigned the coordinates of the clicked point on the canvas. btn -- number of the mouse-button defaults to 1 (left mouse button). add -- True or False. If True, new binding will be added, otherwise it will replace a former binding. Example for the anonymous turtle, i. e. the procedural way: >>> def turn(x, y): ... left(360) ... >>> onclick(turn) # Now clicking into the turtle will turn it. >>> onclick(None) # event-binding will be removed N(RRRR?Rk(RRRR((s%/usr/lib64/python2.7/lib-tk/turtle.pyRJW scCs-|jj|jj||||jdS(sBind fun to mouse-button-release event on this turtle on canvas. Arguments: fun -- a function with two arguments, to which will be assigned the coordinates of the clicked point on the canvas. btn -- number of the mouse-button defaults to 1 (left mouse button). Example (for a MyTurtle instance named joe): >>> class MyTurtle(Turtle): ... def glow(self,x,y): ... self.fillcolor("red") ... def unglow(self,x,y): ... self.fillcolor("") ... >>> joe = MyTurtle() >>> joe.onclick(joe.glow) >>> joe.onrelease(joe.unglow) Clicking on joe turns fillcolor red, unclicking turns it to transparent. N(RRRR?Rk(RRRR((s%/usr/lib64/python2.7/lib-tk/turtle.pyRLl scCs#|jj|jj|||dS(sBind fun to mouse-move event on this turtle on canvas. Arguments: fun -- a function with two arguments, to which will be assigned the coordinates of the clicked point on the canvas. btn -- number of the mouse-button defaults to 1 (left mouse button). Every sequence of mouse-move-events on a turtle is preceded by a mouse-click event on that turtle. Example (for a Turtle instance named turtle): >>> turtle.ondrag(turtle.goto) Subsequently clicking and dragging a Turtle will move it across the screen thereby producing handdrawings (if pen is down). N(RRRR?(RRRR((s%/usr/lib64/python2.7/lib-tk/turtle.pyRK scCs|jdkrdS|dkrV|\}}|j| ||j|jj}n5|dkr||d}|j|n|dkr|j|n|dkr|d}|jj||j j |n|dkr|d}|jj |dddfd d d d ny|d kr[|d}d|_ |_ |jj||j j |n0|d krtj||d|jjndS(s2Does the main part of the work for undo() NRRhiRmRR5RR:RRVRRN(RR5(ii(ii(ii(RRRRRR/RRRjRRRaRERFRRN(RtactionRRtdegPAUtdummyRdRi((s%/usr/lib64/python2.7/lib-tk/turtle.pyt_undo s6            cCs|jdkrdS|jj}|d}|d}|dkrvxA|rr|j}|j|d|dqEWn|j||dS(sundo (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() ... NiiR (RRRR(RRiRR((s%/usr/lib64/python2.7/lib-tk/turtle.pyRm s     N(RiR*(9RRRRARRRRXR`RnRMR.RRkR#RRRPR1RcRdR_RjRiRYRRhRkR/R0RRRRR3R:R*R7R5RRRqR+R8R=R?R@R>R'R&RmRJRLRKRRmRl(((s%/usr/lib64/python2.7/lib-tk/turtle.pyRq sl%          ( &    7 <    5 A   3   3       cCs%tjdkrtt_ntjS(sReturn the singleton screen object. If none exists at the moment, create a new one and return it, else return the existing one.N(R t_screenRR@(((s%/usr/lib64/python2.7/lib-tk/turtle.pyR sR@cBspeZd Zd ZedZdZededededdZdZ dZ d Z d Z RS( R"cCstjdkrKtt_|_|jjtj|jj|jntjdkrt d}t d}t d}t d}t d}t d}|jj |||||jj t_t j |tj|j||||ndS(NRpRRRRR(R@t_rootRR7R"t_titleREt_destroyRRR<R=RRR (RRpRRRRR((s%/usr/lib64/python2.7/lib-tk/turtle.pyR s      RpRRRcCst|jdsdS|jj}|jj}t|trld|koZdknrl||}n|dkr||d}nt|trd|kodknr||}n|dkr||d}n|jj|||||jdS(s  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 RANiii( RRRGRIRRRRAR%(RRpRR?R@Rttsh((s%/usr/lib64/python2.7/lib-tk/turtle.pyR s+  +  cCs/tjdk r"tjj|n|t_dS(sqSet 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@RRR"R(Rt titlestring((s%/usr/lib64/python2.7/lib-tk/turtle.pyR"(s cCsV|j}|tjkr?dt_dt_dt_dt_ntt_ |j dS(N( RR@RR RRRRRRRD(Rtroot((s%/usr/lib64/python2.7/lib-tk/turtle.pyR9s      cCs|jdS(s~Shut the turtlegraphics window. Example (for a TurtleScreen instance named screen): >>> screen.bye() N(R(R((s%/usr/lib64/python2.7/lib-tk/turtle.pyRCscsWfd}j|tdr*dSy tWntk rRtdnXdS(slGo 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() csjdS(s&Screen.bye() with two dummy-parametersN(R(RR(R(s%/usr/lib64/python2.7/lib-tk/turtle.pytexitGracefully^sRNi(RJRRvtAttributeErrortexit(RR((Rs%/usr/lib64/python2.7/lib-tk/turtle.pyRKs    N( RRRRRRRRR R"RRR(((s%/usr/lib64/python2.7/lib-tk/turtle.pyR@ s  '  cBs8eZdZdZdZedededdZRS(sRawTurtle 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. RcRRc CsGtjdkrtt_ntj|tjd|d|d|dS(NRcRR(R RRRRR(RRcRR((s%/usr/lib64/python2.7/lib-tk/turtle.pyRrs N(RRRRRRRR(((s%/usr/lib64/python2.7/lib-tk/turtle.pyR is tturtle_docstringdictcCsRi}x+tD]#}d|}t|j|||d D]2}|j d t ||j d ||qW|d}|j d t ||j d |||j d |j d S(sCreate 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. s_Screen.sTurtle.s%s.pyRTRisdocsdict = { is%s : s """%s """, s """%s """ s} N( t_tg_screen_functionsRRt_tg_turtle_functionsRRRRt _alias_listRqtreprR(Rtdocsdictt methodnameRRRR((s%/usr/lib64/python2.7/lib-tk/turtle.pyRts&     (   cCsxdi|jd6}t|}|j}xE|D]=}y||t|j_Wq3tk rod|GHq3Xq3WdS(sRead 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. s!turtle_docstringdict_%(language)sRsBad docstring-entry: %sN(Rt __import__RRtim_funcRR(tlangtmodnametmoduleRR((s%/usr/lib64/python2.7/lib-tk/turtle.pytread_docstringss    sCannot find docsdict fors;Unknown Error when trying to import %s-docstring-dictionaryc Csd}}t|tjkr1|j}d}n |}d}t|tjtjgkryg|jj}t|jj ||!}|jj ||!}|j pg}tt d|}dgt |t ||}t d||} |jj d@rF| jd|jj ||jd|jj ||d7}n|jj d@r| jd |jj ||jd |jj |nd j| }d |}d j|}d |}WqqXn||fS( s9Get strings describing the arguments for the given objectRiicSsdt|S(Ns=%s(R(R((s%/usr/lib64/python2.7/lib-tk/turtle.pytRcSs||S(N((Rtdflt((s%/usr/lib64/python2.7/lib-tk/turtle.pyRRiRis**s, s(%s)(RRt MethodTypeRRt LambdaTypet func_codet co_argcountRt co_varnamest func_defaultstmapRtco_flagsRYR( tobtargText1targText2tfobt argOffsettcountertitems2trealArgstdefaultstitems1((s%/usr/lib64/python2.7/lib-tk/turtle.pytgetmethparlists:    !  cCseddl}|dkrdStd}|jd|d}|jd|}|jd|}|S(s<To reduce docstrings from RawTurtle class for functions iNRs%s.Rs \(.+ %s\):t:(treRRtreplacetcompiletsub(tdocstrRt turtlenamet newdocstrtparexp((s%/usr/lib64/python2.7/lib-tk/turtle.pyt_turtle_docrevises   cCseddl}|dkrdStd}|jd|d}|jd|}|jd|}|S(s?To reduce docstrings from TurtleScreen class for functions iNRs%s.Rs \(.+ %s\):R(RRRRRR(RRt screennameRR((s%/usr/lib64/python2.7/lib-tk/turtle.pyt_screen_docrevises   srdef {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 Bsx|D]}e||}e|\}}|dkrMdG|G|GHqnejd|d|d|d|d|} | eU||je|_qWdS(NRs>>>>>>tobjtinitRt paramslisttargslist(tgetattrRt __func_bodytformattglobalsR( t functionsRRRt docreviseRRtpl1tpl2tdefstr((s%/usr/lib64/python2.7/lib-tk/turtle.pyt_make_global_funcss    sTurtle._screensScreen()s Turtle._pensTurtle()t__main__cCstrtntdS(N(RFRURM(((s%/usr/lib64/python2.7/lib-tk/turtle.pyt switchpen#s  cCstttttdttdxtdD]}|dkr_tdnx(tdD]}t dt dqlW|dkrt dtd ntt d tq@Wtdt d tt tt dt dt dt dt d ttd dtddt dx<tdD].}t dt dt dt dqXWtttdx<tdD].}t dt dt dt dqWtd dS(sDemo of old turtle.py - moduleidiiiiiiZtmarooniiRit startstartustarttrediN(RXR#RRoR)R6RpRR:R<RHR2RRWRq(RR((s%/usr/lib64/python2.7/lib-tk/turtle.pytdemo1)sX                              cCsOtdttdttddtddd}tdx(tdD]}tt |dqXWt dxt rt qWt tdtd d}td tdtd xtd d D]}|dkrttd d|dd|nx(tdD]}t|tdq+W|d7}tdttddqWttdttdtdttddtdtdx?tdD]1}t ddtdtdtdqWtdtdttdttdt}|jdt}|jd|jd|j |jd|jd|j|jdd|jd|j |jd|jdd|jd|jdtt|d}x|j|dkr|jd |jd!|j|j||jd|d"dkr|j!|j!tn|d7}q W|j d#d$d/d'd(|jd)|jd*d+}t"j#dx!t r|j |j qW|jd|j d,d$d0|j$|dd.S(1sDemo of some new features.iiig@iZii swait a moment...itgreeniiiiixi iFiRtyellowii2RR%uautoii(itblueuorangeig @g333333?isCAUGHT! RyRtboldR|urightRuredcSsttdS(N(RR(RR((s%/usr/lib64/python2.7/lib-tk/turtle.pytbabass Click me!tCourierN(RiR(Ri R(%RfRgRQR\RkR4RZRRR-RqRnRmRXRIRROR*R;R9R7RURMR2R:RcR@RYR RHRoRAR6RhttimetsleepRJ(RRtlaengeRttriRRR((s%/usr/lib64/python2.7/lib-tk/turtle.pytdemo2^s                                                       (HRt_vertTkinterRRRRtostos.pathRRRtcopyRt _tg_classesRRt _tg_utilitiest_math_functionst__all__RRRRRRRRRR RRRRRRRR8R7tobjectRJt ExceptionRRR RRRRR<RR RR@R R RtRt _LANGUAGEt ImportErrorRRRRRRvRuRRRRR(((s%/usr/lib64/python2.7/lib-tk/turtle.pytes          !   %  4  c K /&k  "        $         5 b