mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
[3.13] gh-138772: Fix and improve documentation for turtle color functions (GH-139325) (GH-140048)
Use multiple signatures for clarity.
Explain different forms of bgcolor() in details.
Fix outdated docstrings.
(cherry picked from commit 525dcfe523)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
This commit is contained in:
parent
278384150a
commit
0e7893207b
2 changed files with 110 additions and 57 deletions
|
|
@ -743,13 +743,17 @@ Turtle motion
|
|||
180.0
|
||||
|
||||
|
||||
.. function:: dot(size=None, *color)
|
||||
.. function:: dot()
|
||||
dot(size)
|
||||
dot(color, /)
|
||||
dot(size, color, /)
|
||||
dot(size, r, g, b, /)
|
||||
|
||||
:param size: an integer >= 1 (if given)
|
||||
:param 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.
|
||||
not given, the maximum of ``pensize+4`` and ``2*pensize`` is used.
|
||||
|
||||
|
||||
.. doctest::
|
||||
|
|
@ -1118,7 +1122,9 @@ Drawing state
|
|||
Color control
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
.. function:: pencolor(*args)
|
||||
.. function:: pencolor()
|
||||
pencolor(color, /)
|
||||
pencolor(r, g, b, /)
|
||||
|
||||
Return or set the pencolor.
|
||||
|
||||
|
|
@ -1127,7 +1133,7 @@ Color control
|
|||
``pencolor()``
|
||||
Return the current pencolor as color specification string or
|
||||
as a tuple (see example). May be used as input to another
|
||||
color/pencolor/fillcolor call.
|
||||
color/pencolor/fillcolor/bgcolor call.
|
||||
|
||||
``pencolor(colorstring)``
|
||||
Set pencolor to *colorstring*, which is a Tk color specification string,
|
||||
|
|
@ -1167,7 +1173,9 @@ Color control
|
|||
(50.0, 193.0, 143.0)
|
||||
|
||||
|
||||
.. function:: fillcolor(*args)
|
||||
.. function:: fillcolor()
|
||||
fillcolor(color, /)
|
||||
fillcolor(r, g, b, /)
|
||||
|
||||
Return or set the fillcolor.
|
||||
|
||||
|
|
@ -1176,7 +1184,7 @@ Color control
|
|||
``fillcolor()``
|
||||
Return the current fillcolor as color specification string, possibly
|
||||
in tuple format (see example). May be used as input to another
|
||||
color/pencolor/fillcolor call.
|
||||
color/pencolor/fillcolor/bgcolor call.
|
||||
|
||||
``fillcolor(colorstring)``
|
||||
Set fillcolor to *colorstring*, which is a Tk color specification string,
|
||||
|
|
@ -1210,7 +1218,10 @@ Color control
|
|||
(255.0, 255.0, 255.0)
|
||||
|
||||
|
||||
.. function:: color(*args)
|
||||
.. function:: color()
|
||||
color(color, /)
|
||||
color(r, g, b, /)
|
||||
color(pencolor, fillcolor, /)
|
||||
|
||||
Return or set pencolor and fillcolor.
|
||||
|
||||
|
|
@ -1796,13 +1807,32 @@ Most of the examples in this section refer to a TurtleScreen instance called
|
|||
Window control
|
||||
--------------
|
||||
|
||||
.. function:: bgcolor(*args)
|
||||
.. function:: bgcolor()
|
||||
bgcolor(color, /)
|
||||
bgcolor(r, g, b, /)
|
||||
|
||||
:param args: a color string or three numbers in the range 0..colormode or a
|
||||
3-tuple of such numbers
|
||||
Return or set the background color of the TurtleScreen.
|
||||
|
||||
Four input formats are allowed:
|
||||
|
||||
Set or return background color of the TurtleScreen.
|
||||
``bgcolor()``
|
||||
Return the current background color as color specification string or
|
||||
as a tuple (see example). May be used as input to another
|
||||
color/pencolor/fillcolor/bgcolor call.
|
||||
|
||||
``bgcolor(colorstring)``
|
||||
Set the background color to *colorstring*, which is a Tk color
|
||||
specification string, such as ``"red"``, ``"yellow"``, or ``"#33cc8c"``.
|
||||
|
||||
``bgcolor((r, g, b))``
|
||||
Set the background color to the RGB color represented by the tuple of
|
||||
*r*, *g*, and *b*.
|
||||
Each of *r*, *g*, and *b* must be in the range 0..colormode, where
|
||||
colormode is either 1.0 or 255 (see :func:`colormode`).
|
||||
|
||||
``bgcolor(r, g, b)``
|
||||
Set the background color to the RGB color represented by *r*, *g*, and *b*. Each of
|
||||
*r*, *g*, and *b* must be in the range 0..colormode.
|
||||
|
||||
.. doctest::
|
||||
:skipif: _tkinter is None
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue