1- ========================================
2- :mod: `turtle ` --- Turtle graphics for Tk
3- ========================================
1+ =================================
2+ :mod: `turtle ` --- Turtle graphics
3+ =================================
44
55.. module :: turtle
6- :synopsis: Turtle graphics for Tk
6+ :synopsis: An educational framework for simple graphics applications
77..
sectionauthor ::
Gregor Lingl <[email protected] > 88
99.. testsetup :: default
@@ -58,7 +58,7 @@ The object-oriented interface uses essentially two+two classes:
5858 or TurtleScreen as argument, so the RawTurtle objects know where to draw.
5959
6060 Derived from RawTurtle is the subclass :class: `Turtle ` (alias: :class: `Pen `),
61- which draws on "the" :class: `Screen ` - instance which is automatically
61+ which draws on "the" :class: `Screen ` instance which is automatically
6262 created, if not already present.
6363
6464 All methods of RawTurtle/Turtle also exist as functions, i.e. part of the
@@ -71,15 +71,15 @@ function derived from a Screen method is called. An (unnamed) turtle object is
7171automatically created whenever any of the functions derived from a Turtle method
7272is called.
7373
74- To use multiple turtles an a screen one has to use the object-oriented interface.
74+ To use multiple turtles on a screen one has to use the object-oriented interface.
7575
7676.. note ::
7777 In the following documentation the argument list for functions is given.
7878 Methods, of course, have the additional first argument *self * which is
7979 omitted here.
8080
8181
82- Overview over available Turtle and Screen methods
82+ Overview of available Turtle and Screen methods
8383=================================================
8484
8585Turtle methods
@@ -645,8 +645,8 @@ Tell Turtle's state
645645 >>> turtle.forward(100 )
646646 >>> turtle.pos()
647647 (64.28,76.60)
648- >>> print (turtle.xcor())
649- 64.2787609687
648+ >>> print (round ( turtle.xcor(), 5 ))
649+ 64.27876
650650
651651
652652.. function :: ycor()
@@ -660,8 +660,8 @@ Tell Turtle's state
660660 >>> turtle.forward(100 )
661661 >>> print (turtle.pos())
662662 (50.00,86.60)
663- >>> print (turtle.ycor())
664- 86.6025403784
663+ >>> print (round ( turtle.ycor(), 5 ))
664+ 86.60254
665665
666666
667667.. function :: heading()
@@ -714,7 +714,10 @@ Settings for measurement
714714 >>> turtle.left(90 )
715715 >>> turtle.heading()
716716 90.0
717- >>> turtle.degrees(400.0 ) # angle measurement in gon
717+
718+ Change angle measurement unit to grad (also known as gon,
719+ grade, or gradian and equals 1/100-th of the right angle.)
720+ >>> turtle.degrees(400.0 )
718721 >>> turtle.heading()
719722 100.0
720723 >>> turtle.degrees(360 )
@@ -810,20 +813,16 @@ Drawing state
810813 >>> sorted (turtle.pen().items())
811814 [('fillcolor', 'black'), ('outline', 1), ('pencolor', 'red'),
812815 ('pendown', True), ('pensize', 10), ('resizemode', 'noresize'),
813- ('shown', True), ('speed', 9), ('stretchfactor', (1, 1)), ('tilt', 0)]
816+ ('shearfactor', 0.0), ('shown', True), ('speed', 9),
817+ ('stretchfactor', (1.0, 1.0)), ('tilt', 0.0)]
814818 >>> penstate= turtle.pen()
815819 >>> turtle.color(" yellow" , " " )
816820 >>> turtle.penup()
817- >>> sorted (turtle.pen().items())
818- [('fillcolor', ''), ('outline', 1), ('pencolor', 'yellow'),
819- ('pendown', False), ('pensize', 10), ('resizemode', 'noresize'),
820- ('shown', True), ('speed', 9), ('stretchfactor', (1, 1)), ('tilt', 0)]
821+ >>> sorted (turtle.pen().items())[:3 ]
822+ [('fillcolor', ''), ('outline', 1), ('pencolor', 'yellow')]
821823 >>> turtle.pen(penstate, fillcolor = " green" )
822- >>> sorted (turtle.pen().items())
823- [('fillcolor', 'green'), ('outline', 1), ('pencolor', 'red'),
824- ('pendown', True), ('pensize', 10), ('resizemode', 'noresize'),
825- ('shown', True), ('speed', 9), ('stretchfactor', (1, 1)), ('tilt', 0)]
826-
824+ >>> sorted (turtle.pen().items())[:3 ]
825+ [('fillcolor', 'green'), ('outline', 1), ('pencolor', 'red')]
827826
828827.. function :: isdown()
829828
@@ -884,10 +883,10 @@ Color control
884883 (0.2, 0.8, 0.5490196078431373)
885884 >>> colormode(255 )
886885 >>> turtle.pencolor()
887- (51, 204, 140)
886+ (51.0 , 204.0 , 140.0 )
888887 >>> turtle.pencolor(' #32c18f' )
889888 >>> turtle.pencolor()
890- (50, 193, 143)
889+ (50.0 , 193.0 , 143.0 )
891890
892891
893892.. function :: fillcolor(*args)
@@ -924,13 +923,13 @@ Color control
924923 'violet'
925924 >>> col = turtle.pencolor()
926925 >>> col
927- (50, 193, 143)
926+ (50.0 , 193.0 , 143.0 )
928927 >>> turtle.fillcolor(col)
929928 >>> turtle.fillcolor()
930- (50, 193, 143)
929+ (50.0 , 193.0 , 143.0 )
931930 >>> turtle.fillcolor(' #ffffff' )
932931 >>> turtle.fillcolor()
933- (255, 255, 255)
932+ (255.0 , 255.0 , 255.0 )
934933
935934
936935.. function :: color(*args)
@@ -963,7 +962,7 @@ Color control
963962 ('red', 'green')
964963 >>> color(" #285078" , " #a0c8f0" )
965964 >>> color()
966- ((40, 80, 120), (160, 200, 240))
965+ ((40.0 , 80.0 , 120.0 ), (160.0 , 200.0 , 240.0 ))
967966
968967
969968See also: Screen method :func: `colormode `.
@@ -1157,7 +1156,7 @@ Appearance
11571156 .. doctest ::
11581157
11591158 >>> turtle.shapesize()
1160- (1, 1, 1)
1159+ (1.0 , 1.0 , 1)
11611160 >>> turtle.resizemode(" user" )
11621161 >>> turtle.shapesize(5 , 5 , 12 )
11631162 >>> turtle.shapesize()
@@ -1184,7 +1183,7 @@ Appearance
11841183 >>> turtle.shapesize(5 ,2 )
11851184 >>> turtle.shearfactor(0.5 )
11861185 >>> turtle.shearfactor()
1187- >>> 0.5
1186+ 0.5
11881187
11891188
11901189.. function :: tilt(angle)
@@ -1268,11 +1267,12 @@ Appearance
12681267
12691268 .. doctest ::
12701269
1270+ >>> turtle = Turtle()
12711271 >>> turtle.shape(" square" )
12721272 >>> turtle.shapesize(4 ,2 )
12731273 >>> turtle.shearfactor(- 0.5 )
12741274 >>> turtle.shapetransform()
1275- >>> (4.0 , - 1.0 , - 0.0 , 2.0 )
1275+ (4.0, -1.0, -0.0, 2.0)
12761276
12771277
12781278.. function :: get_shapepoly()
@@ -1456,8 +1456,8 @@ Special Turtle methods
14561456
14571457.. _compoundshapes :
14581458
1459- Excursus about the use of compound shapes
1460- -----------------------------------------
1459+ Compound shapes
1460+ ---------------
14611461
14621462To use compound turtle shapes, which consist of several polygons of different
14631463color, you must use the helper class :class: `Shape ` explicitly as described
@@ -1511,6 +1511,7 @@ Window control
15111511 :param args: a color string or three numbers in the range 0..colormode or a
15121512 3-tuple of such numbers
15131513
1514+
15141515 Set or return background color of the TurtleScreen.
15151516
15161517 .. doctest ::
@@ -1520,7 +1521,7 @@ Window control
15201521 'orange'
15211522 >>> screen.bgcolor(" #800080" )
15221523 >>> screen.bgcolor()
1523- (128, 0, 128)
1524+ (128.0 , 0.0 , 128.0 )
15241525
15251526
15261527.. function :: bgpic(picname=None)
@@ -1548,7 +1549,7 @@ Window control
15481549
15491550 .. note ::
15501551 This TurtleScreen method is available as a global function only under the
1551- name ``clearscreen ``. The global function ``clear `` is another one
1552+ name ``clearscreen ``. The global function ``clear `` is a different one
15521553 derived from the Turtle method ``clear ``.
15531554
15541555
@@ -1643,10 +1644,12 @@ Animation control
16431644 :param n: nonnegative integer
16441645 :param delay: nonnegative integer
16451646
1646- Turn turtle animation on/off and set delay for update drawings. If *n * is
1647- given, only each n-th regular screen update is really performed. (Can be
1648- used to accelerate the drawing of complex graphics.) Second argument sets
1649- delay value (see :func: `delay `).
1647+ Turn turtle animation on/off and set delay for update drawings. If
1648+ *n * is given, only each n-th regular screen update is really
1649+ performed. (Can be used to accelerate the drawing of complex
1650+ graphics.) When called without arguments, returns the currently
1651+ stored value of n. Second argument sets delay value (see
1652+ :func: `delay `).
16501653
16511654 .. doctest ::
16521655
@@ -1790,8 +1793,8 @@ Input methods
17901793 :param title: string
17911794 :param prompt: string
17921795 :param default: number (optional)
1793- :param prompt : number (optional)
1794- :param prompt : number (optional)
1796+ :param minval : number (optional)
1797+ :param maxval : number (optional)
17951798
17961799 Pop up a dialog window for input of a number. title is the title of the
17971800 dialog window, prompt is a text mostly describing what numerical information
@@ -1991,8 +1994,8 @@ Methods specific to Screen, not inherited from TurtleScreen
19911994 >>> screen.title(" Welcome to the turtle zoo!" )
19921995
19931996
1994- The public classes of the module :mod: ` turtle `
1995- ==============================================
1997+ Public classes
1998+ ==============
19961999
19972000
19982001.. class :: RawTurtle(canvas)
@@ -2323,7 +2326,7 @@ The demoscripts are:
23232326+----------------+------------------------------+-----------------------+
23242327| round_dance | dancing turtles rotating | compound shapes, clone|
23252328| | pairwise in opposite | shapesize, tilt, |
2326- | | direction | get_polyshape , update |
2329+ | | direction | get_shapepoly , update |
23272330+----------------+------------------------------+-----------------------+
23282331| tree | a (graphical) breadth | :func: `clone ` |
23292332| | first tree (using generators)| |
0 commit comments