@@ -1214,16 +1214,32 @@ def turtles(self):
12141214 def bgcolor (self , * args ):
12151215 """Set or return backgroundcolor of the TurtleScreen.
12161216
1217- Arguments (if given): a color string or three numbers
1218- in the range 0..colormode or a 3-tuple of such numbers.
1217+ Four input formats are allowed:
1218+ - bgcolor()
1219+ Return the current background color as color specification
1220+ string or as a tuple (see example). May be used as input
1221+ to another color/pencolor/fillcolor/bgcolor call.
1222+ - bgcolor(colorstring)
1223+ Set the background color to colorstring, which is a Tk color
1224+ specification string, such as "red", "yellow", or "#33cc8c".
1225+ - bgcolor((r, g, b))
1226+ Set the background color to the RGB color represented by
1227+ the tuple of r, g, and b. Each of r, g, and b must be in
1228+ the range 0..colormode, where colormode is either 1.0 or 255
1229+ (see colormode()).
1230+ - bgcolor(r, g, b)
1231+ Set the background color to the RGB color represented by
1232+ r, g, and b. Each of r, g, and b must be in the range
1233+ 0..colormode.
12191234
12201235 Example (for a TurtleScreen instance named screen):
12211236 >>> screen.bgcolor("orange")
12221237 >>> screen.bgcolor()
12231238 'orange'
1224- >>> screen.bgcolor(0.5,0,0.5)
1239+ >>> colormode(255)
1240+ >>> screen.bgcolor('#800080')
12251241 >>> screen.bgcolor()
1226- '#800080'
1242+ (128.0, 0.0, 128.0)
12271243 """
12281244 if args :
12291245 color = self ._colorstr (args )
@@ -1678,7 +1694,7 @@ def forward(self, distance):
16781694
16791695 Example (for a Turtle instance named turtle):
16801696 >>> turtle.position()
1681- (0.00, 0.00)
1697+ (0.00,0.00)
16821698 >>> turtle.forward(25)
16831699 >>> turtle.position()
16841700 (25.00,0.00)
@@ -1701,10 +1717,10 @@ def back(self, distance):
17011717
17021718 Example (for a Turtle instance named turtle):
17031719 >>> turtle.position()
1704- (0.00, 0.00)
1720+ (0.00,0.00)
17051721 >>> turtle.backward(30)
17061722 >>> turtle.position()
1707- (-30.00, 0.00)
1723+ (-30.00,0.00)
17081724 """
17091725 self ._go (- distance )
17101726
@@ -1811,7 +1827,7 @@ def goto(self, x, y=None):
18111827 Example (for a Turtle instance named turtle):
18121828 >>> tp = turtle.pos()
18131829 >>> tp
1814- (0.00, 0.00)
1830+ (0.00,0.00)
18151831 >>> turtle.setpos(60,30)
18161832 >>> turtle.pos()
18171833 (60.00,30.00)
@@ -1891,7 +1907,7 @@ def distance(self, x, y=None):
18911907
18921908 Example (for a Turtle instance named turtle):
18931909 >>> turtle.pos()
1894- (0.00, 0.00)
1910+ (0.00,0.00)
18951911 >>> turtle.distance(30,40)
18961912 50.0
18971913 >>> pen = Turtle()
@@ -2230,19 +2246,17 @@ def color(self, *args):
22302246
22312247 Arguments:
22322248 Several input formats are allowed.
2233- They use 0, 1, 2, or 3 arguments as follows:
2234-
2235- color()
2236- Return the current pencolor and the current fillcolor
2237- as a pair of color specification strings as are returned
2238- by pencolor and fillcolor.
2239- color(colorstring), color((r,g,b)), color(r,g,b)
2240- inputs as in pencolor, set both, fillcolor and pencolor,
2249+ They use 0 to 3 arguments as follows:
2250+ - color()
2251+ Return the current pencolor and the current fillcolor as
2252+ a pair of color specification strings or tuples as returned
2253+ by pencolor() and fillcolor().
2254+ - color(colorstring), color((r,g,b)), color(r,g,b)
2255+ Inputs as in pencolor(), set both, fillcolor and pencolor,
22412256 to the given value.
2242- color(colorstring1, colorstring2),
2243- color((r1,g1,b1), (r2,g2,b2))
2244- equivalent to pencolor(colorstring1) and fillcolor(colorstring2)
2245- and analogously, if the other input format is used.
2257+ - color(colorstring1, colorstring2), color((r1,g1,b1), (r2,g2,b2))
2258+ Equivalent to pencolor(colorstring1) and fillcolor(colorstring2)
2259+ and analogously if the other input format is used.
22462260
22472261 If turtleshape is a polygon, outline and interior of that polygon
22482262 is drawn with the newly set colors.
@@ -2253,9 +2267,9 @@ def color(self, *args):
22532267 >>> turtle.color()
22542268 ('red', 'green')
22552269 >>> colormode(255)
2256- >>> color((40, 80, 120), (160, 200, 240 ))
2270+ >>> color(('#285078', '#a0c8f0' ))
22572271 >>> color()
2258- ('#285078', '#a0c8f0' )
2272+ ((40.0, 80.0, 120.0), (160.0, 200.0, 240.0) )
22592273 """
22602274 if args :
22612275 l = len (args )
@@ -2277,28 +2291,32 @@ def pencolor(self, *args):
22772291 Arguments:
22782292 Four input formats are allowed:
22792293 - pencolor()
2280- Return the current pencolor as color specification string,
2281- possibly in hex-number format (see example).
2282- May be used as input to another color/pencolor/fillcolor call.
2294+ Return the current pencolor as color specification string or
2295+ as a tuple (see example). May be used as input to another
2296+ color/pencolor/fillcolor/bgcolor call.
22832297 - pencolor(colorstring)
2284- s is a Tk color specification string, such as "red" or "yellow"
2298+ Set pencolor to colorstring, which is a Tk color
2299+ specification string, such as "red", "yellow", or "#33cc8c".
22852300 - pencolor((r, g, b))
2286- *a tuple* of r, g, and b, which represent, an RGB color,
2287- and each of r, g, and b are in the range 0..colormode,
2288- where colormode is either 1.0 or 255
2301+ Set pencolor to the RGB color represented by the tuple of
2302+ r, g, and b. Each of r, g, and b must be in the range
2303+ 0..colormode, where colormode is either 1.0 or 255 (see
2304+ colormode()).
22892305 - pencolor(r, g, b)
2290- r, g, and b represent an RGB color, and each of r, g, and b
2291- are in the range 0..colormode
2306+ Set pencolor to the RGB color represented by r, g, and b.
2307+ Each of r, g, and b must be in the range 0..colormode.
22922308
22932309 If turtleshape is a polygon, the outline of that polygon is drawn
22942310 with the newly set pencolor.
22952311
22962312 Example (for a Turtle instance named turtle):
22972313 >>> turtle.pencolor('brown')
2298- >>> tup = (0.2, 0.8, 0.55)
2299- >>> turtle.pencolor(tup)
23002314 >>> turtle.pencolor()
2301- '#33cc8c'
2315+ 'brown'
2316+ >>> colormode(255)
2317+ >>> turtle.pencolor('#32c18f')
2318+ >>> turtle.pencolor()
2319+ (50.0, 193.0, 143.0)
23022320 """
23032321 if args :
23042322 color = self ._colorstr (args )
@@ -2315,26 +2333,31 @@ def fillcolor(self, *args):
23152333 Four input formats are allowed:
23162334 - fillcolor()
23172335 Return the current fillcolor as color specification string,
2318- possibly in hex-number format (see example).
2319- May be used as input to another color/pencolor/fillcolor call.
2336+ possibly in tuple format (see example). May be used as
2337+ input to another color/pencolor/fillcolor/bgcolor call.
23202338 - fillcolor(colorstring)
2321- s is a Tk color specification string, such as "red" or "yellow"
2339+ Set fillcolor to colorstring, which is a Tk color
2340+ specification string, such as "red", "yellow", or "#33cc8c".
23222341 - fillcolor((r, g, b))
2323- *a tuple* of r, g, and b, which represent, an RGB color,
2324- and each of r, g, and b are in the range 0..colormode,
2325- where colormode is either 1.0 or 255
2342+ Set fillcolor to the RGB color represented by the tuple of
2343+ r, g, and b. Each of r, g, and b must be in the range
2344+ 0..colormode, where colormode is either 1.0 or 255 (see
2345+ colormode()).
23262346 - fillcolor(r, g, b)
2327- r, g, and b represent an RGB color, and each of r, g, and b
2328- are in the range 0..colormode
2347+ Set fillcolor to the RGB color represented by r, g, and b.
2348+ Each of r, g, and b must be in the range 0..colormode.
23292349
23302350 If turtleshape is a polygon, the interior of that polygon is drawn
23312351 with the newly set fillcolor.
23322352
23332353 Example (for a Turtle instance named turtle):
23342354 >>> turtle.fillcolor('violet')
2335- >>> col = turtle.pencolor()
2336- >>> turtle.fillcolor(col)
2337- >>> turtle.fillcolor(0, .5, 0)
2355+ >>> turtle.fillcolor()
2356+ 'violet'
2357+ >>> colormode(255)
2358+ >>> turtle.fillcolor('#ffffff')
2359+ >>> turtle.fillcolor()
2360+ (255.0, 255.0, 255.0)
23382361 """
23392362 if args :
23402363 color = self ._colorstr (args )
0 commit comments