@@ -1213,16 +1213,32 @@ def turtles(self):
12131213 def bgcolor (self , * args ):
12141214 """Set or return backgroundcolor of the TurtleScreen.
12151215
1216- Arguments (if given): a color string or three numbers
1217- in the range 0..colormode or a 3-tuple of such numbers.
1216+ Four input formats are allowed:
1217+ - bgcolor()
1218+ Return the current background color as color specification
1219+ string or as a tuple (see example). May be used as input
1220+ to another color/pencolor/fillcolor/bgcolor call.
1221+ - bgcolor(colorstring)
1222+ Set the background color to colorstring, which is a Tk color
1223+ specification string, such as "red", "yellow", or "#33cc8c".
1224+ - bgcolor((r, g, b))
1225+ Set the background color to the RGB color represented by
1226+ the tuple of r, g, and b. Each of r, g, and b must be in
1227+ the range 0..colormode, where colormode is either 1.0 or 255
1228+ (see colormode()).
1229+ - bgcolor(r, g, b)
1230+ Set the background color to the RGB color represented by
1231+ r, g, and b. Each of r, g, and b must be in the range
1232+ 0..colormode.
12181233
12191234 Example (for a TurtleScreen instance named screen):
12201235 >>> screen.bgcolor("orange")
12211236 >>> screen.bgcolor()
12221237 'orange'
1223- >>> screen.bgcolor(0.5,0,0.5)
1238+ >>> colormode(255)
1239+ >>> screen.bgcolor('#800080')
12241240 >>> screen.bgcolor()
1225- '#800080'
1241+ (128.0, 0.0, 128.0)
12261242 """
12271243 if args :
12281244 color = self ._colorstr (args )
@@ -1624,7 +1640,7 @@ def forward(self, distance):
16241640
16251641 Example (for a Turtle instance named turtle):
16261642 >>> turtle.position()
1627- (0.00, 0.00)
1643+ (0.00,0.00)
16281644 >>> turtle.forward(25)
16291645 >>> turtle.position()
16301646 (25.00,0.00)
@@ -1647,10 +1663,10 @@ def back(self, distance):
16471663
16481664 Example (for a Turtle instance named turtle):
16491665 >>> turtle.position()
1650- (0.00, 0.00)
1666+ (0.00,0.00)
16511667 >>> turtle.backward(30)
16521668 >>> turtle.position()
1653- (-30.00, 0.00)
1669+ (-30.00,0.00)
16541670 """
16551671 self ._go (- distance )
16561672
@@ -1757,7 +1773,7 @@ def goto(self, x, y=None):
17571773 Example (for a Turtle instance named turtle):
17581774 >>> tp = turtle.pos()
17591775 >>> tp
1760- (0.00, 0.00)
1776+ (0.00,0.00)
17611777 >>> turtle.setpos(60,30)
17621778 >>> turtle.pos()
17631779 (60.00,30.00)
@@ -1837,7 +1853,7 @@ def distance(self, x, y=None):
18371853
18381854 Example (for a Turtle instance named turtle):
18391855 >>> turtle.pos()
1840- (0.00, 0.00)
1856+ (0.00,0.00)
18411857 >>> turtle.distance(30,40)
18421858 50.0
18431859 >>> pen = Turtle()
@@ -2176,19 +2192,17 @@ def color(self, *args):
21762192
21772193 Arguments:
21782194 Several input formats are allowed.
2179- They use 0, 1, 2, or 3 arguments as follows:
2180-
2181- color()
2182- Return the current pencolor and the current fillcolor
2183- as a pair of color specification strings as are returned
2184- by pencolor and fillcolor.
2185- color(colorstring), color((r,g,b)), color(r,g,b)
2186- inputs as in pencolor, set both, fillcolor and pencolor,
2195+ They use 0 to 3 arguments as follows:
2196+ - color()
2197+ Return the current pencolor and the current fillcolor as
2198+ a pair of color specification strings or tuples as returned
2199+ by pencolor() and fillcolor().
2200+ - color(colorstring), color((r,g,b)), color(r,g,b)
2201+ Inputs as in pencolor(), set both, fillcolor and pencolor,
21872202 to the given value.
2188- color(colorstring1, colorstring2),
2189- color((r1,g1,b1), (r2,g2,b2))
2190- equivalent to pencolor(colorstring1) and fillcolor(colorstring2)
2191- and analogously, if the other input format is used.
2203+ - color(colorstring1, colorstring2), color((r1,g1,b1), (r2,g2,b2))
2204+ Equivalent to pencolor(colorstring1) and fillcolor(colorstring2)
2205+ and analogously if the other input format is used.
21922206
21932207 If turtleshape is a polygon, outline and interior of that polygon
21942208 is drawn with the newly set colors.
@@ -2199,9 +2213,9 @@ def color(self, *args):
21992213 >>> turtle.color()
22002214 ('red', 'green')
22012215 >>> colormode(255)
2202- >>> color((40, 80, 120), (160, 200, 240 ))
2216+ >>> color(('#285078', '#a0c8f0' ))
22032217 >>> color()
2204- ('#285078', '#a0c8f0' )
2218+ ((40.0, 80.0, 120.0), (160.0, 200.0, 240.0) )
22052219 """
22062220 if args :
22072221 l = len (args )
@@ -2223,28 +2237,32 @@ def pencolor(self, *args):
22232237 Arguments:
22242238 Four input formats are allowed:
22252239 - pencolor()
2226- Return the current pencolor as color specification string,
2227- possibly in hex-number format (see example).
2228- May be used as input to another color/pencolor/fillcolor call.
2240+ Return the current pencolor as color specification string or
2241+ as a tuple (see example). May be used as input to another
2242+ color/pencolor/fillcolor/bgcolor call.
22292243 - pencolor(colorstring)
2230- s is a Tk color specification string, such as "red" or "yellow"
2244+ Set pencolor to colorstring, which is a Tk color
2245+ specification string, such as "red", "yellow", or "#33cc8c".
22312246 - pencolor((r, g, b))
2232- *a tuple* of r, g, and b, which represent, an RGB color,
2233- and each of r, g, and b are in the range 0..colormode,
2234- where colormode is either 1.0 or 255
2247+ Set pencolor to the RGB color represented by the tuple of
2248+ r, g, and b. Each of r, g, and b must be in the range
2249+ 0..colormode, where colormode is either 1.0 or 255 (see
2250+ colormode()).
22352251 - pencolor(r, g, b)
2236- r, g, and b represent an RGB color, and each of r, g, and b
2237- are in the range 0..colormode
2252+ Set pencolor to the RGB color represented by r, g, and b.
2253+ Each of r, g, and b must be in the range 0..colormode.
22382254
22392255 If turtleshape is a polygon, the outline of that polygon is drawn
22402256 with the newly set pencolor.
22412257
22422258 Example (for a Turtle instance named turtle):
22432259 >>> turtle.pencolor('brown')
2244- >>> tup = (0.2, 0.8, 0.55)
2245- >>> turtle.pencolor(tup)
22462260 >>> turtle.pencolor()
2247- '#33cc8c'
2261+ 'brown'
2262+ >>> colormode(255)
2263+ >>> turtle.pencolor('#32c18f')
2264+ >>> turtle.pencolor()
2265+ (50.0, 193.0, 143.0)
22482266 """
22492267 if args :
22502268 color = self ._colorstr (args )
@@ -2261,26 +2279,31 @@ def fillcolor(self, *args):
22612279 Four input formats are allowed:
22622280 - fillcolor()
22632281 Return the current fillcolor as color specification string,
2264- possibly in hex-number format (see example).
2265- May be used as input to another color/pencolor/fillcolor call.
2282+ possibly in tuple format (see example). May be used as
2283+ input to another color/pencolor/fillcolor/bgcolor call.
22662284 - fillcolor(colorstring)
2267- s is a Tk color specification string, such as "red" or "yellow"
2285+ Set fillcolor to colorstring, which is a Tk color
2286+ specification string, such as "red", "yellow", or "#33cc8c".
22682287 - fillcolor((r, g, b))
2269- *a tuple* of r, g, and b, which represent, an RGB color,
2270- and each of r, g, and b are in the range 0..colormode,
2271- where colormode is either 1.0 or 255
2288+ Set fillcolor to the RGB color represented by the tuple of
2289+ r, g, and b. Each of r, g, and b must be in the range
2290+ 0..colormode, where colormode is either 1.0 or 255 (see
2291+ colormode()).
22722292 - fillcolor(r, g, b)
2273- r, g, and b represent an RGB color, and each of r, g, and b
2274- are in the range 0..colormode
2293+ Set fillcolor to the RGB color represented by r, g, and b.
2294+ Each of r, g, and b must be in the range 0..colormode.
22752295
22762296 If turtleshape is a polygon, the interior of that polygon is drawn
22772297 with the newly set fillcolor.
22782298
22792299 Example (for a Turtle instance named turtle):
22802300 >>> turtle.fillcolor('violet')
2281- >>> col = turtle.pencolor()
2282- >>> turtle.fillcolor(col)
2283- >>> turtle.fillcolor(0, .5, 0)
2301+ >>> turtle.fillcolor()
2302+ 'violet'
2303+ >>> colormode(255)
2304+ >>> turtle.fillcolor('#ffffff')
2305+ >>> turtle.fillcolor()
2306+ (255.0, 255.0, 255.0)
22842307 """
22852308 if args :
22862309 color = self ._colorstr (args )
0 commit comments