# Basics of colors

## Basics of Colors

While going through all kinds of pictures online, have you ever questioned how those pictures got their colors? Actually, computers have RGB mode to represent colors.

## RGB format

In Python, we follow a specific format when defining colors: (R, G, B), where “R”, “G”, and “B” are all integers. “R” represents some amount of red, “G” represents some amount of green, and “B” represents some amount of blue.

The color represented by (R, G, B) is what we get from “the mix of” different amounts of red, green and blue.

## Q&A

1. Which color does (0, 0, 0) represent?

Black. All colors are of 0%. (There is no color here. The whole world is so dark. It is black!)

1. Which color does (255, 255, 255) represent?

White. 255 represents that you are using 100% of each color, which is saturate. (When all colors are saturate, you will get white)

1. Which color does (100, 100, 100) represent?

Gray. 100 / 255 % = 39.2%. You will get gray by adding up 39.2% of red, 39.2% of blue, and 39.2% of green.

Note: Don’t panic if you feel confused here, we will explain more about these ideas in python code activities later in the workshop.

## Built-in colors

In Python, most commonly used colors are prepared for you. When you need to refer to a color, just do:

color = 'color name'

For example: Red:

color = 'red'
# The following code is used to show you the color you get.
# You can skip these lines for now and we will explain them in the next page!
img = Image.new('RGB', (60, 30), color)
img.save('red.png')
img.show('red.png')

The following is your output: Amazing! You get red!