Custom Search

PYTHON: Colours

In Python, the colour names and their hexadecimal codes are retrieved from a dictionary in the color.py module.

 

You can either use the hex code to set the cursor colour:

cursor.color("#cc3366")

Or you can use the names that have been given to the colours (see the graphic below):

cursor.color("limegreen")

To make it quick and easy to use when employing matplotlib - the primary and secondary colours they can be called up by a single letter shortcut - rather than the full name of the colour:

r - red

b - blue

g - green

y - yellow

c - cyan

m - magenta

That is also true for white - w, but black gets the final letter of its name - k (as blue already nabbed 'b')

turtlename.fillcolor("blue")

This will define the colour that you wish enclosed figures to be filled with.

You need to start the fill region with: turtlename.begin_fill()

And finish it with fuzzle.end_fill()

 

Try it out for yourself...