Module 4 - Section 2 - Graphics
Module 4 - Section 2 - Graphics
- identify the commands inside the Pygame basic template
- experiment with various graphics commands
- draw shapes using Python commands
- draw text using Python commands
4.2.2 - Graphics colors
Colors are defined in a list of three colors: Red, Green, and Blue. Have you ever heard of an RGB monitor?
Each element of the RGB triad is a number ranging from 0 to 255. Zero means there is none of the color, and 255 tells the monitor to display as much of the color as possible. The colors combine in an additive way, so if all three colors are specified, the color on the monitor appears white.
Color in Python is defined by a tuple which is a kind of a list of three numbers. Individual numbers in the tuple are separated by commas. Write the following command in CLI area to create colors.
>>> BLACK = ( 0, 0, 0)
>>> WHITE = ( 255, 255, 255)
>>> RED = ( 255, 0, 0)
>>> GREEN = ( 0, 255, 0)
>>> BLUE = ( 0, 0, 255)
For these variable names we use CAPITAL letters. These variables that are not changing during the execution of the programm are called constants and we use upper-case letter to name them.
I f you want to create a color and you don't know the combination of the three colors you can go to color picker web page and experiment.