All Color values are wrapped in pyDraw as to make constructors and methods more clear. Colors are immutable, and can be created from names, RGB values, or a hex string.


You can create a Color by passing in one of three options:

  • Name (string from Tkinter dataset)

  • RGB (either a tuple or just three arguments, [0-255])

  • Hex (supports 3-char: '#fff' and 6-char: '#ffffff')

color = Color('red')  # Get the red color
color = Color(255, 0, 0)  # Create red from RGB
color = Color('#ff0000')  # Create red from hex

Retrieving Values

The RGB values are available no matter how the Color was initialized:  # Retrieve the red value (0-255)  # Retrieve the green value (0-255)  # Retrieve the blue value (0-255)

color.rgb()  # Retrieve a tuple of all three color values  # If initialized with a name, it is available
color.hex()  # If initialized with a hex, it is available

Random Color and All Colors

You can retrieve a random Color via:


Or you can generate it yourself by retrieving the full list of (named) Colors:


Note that these are static methods and are called on the Color class, rather than an instance.

To view all named colors, please see the second tab.


You can easily clone a color (like most objects in pyDraw) as:



🚀 Experienced Only: You can retrieve a "turtle-friendly" version of the Color with:


Last updated