### Navigation

- index
- next |
- previous |
- CS116 1.0 documentation »

# Color

Color objects contain three values: red, blue, and green.

Each of these values is an integer between 0 and 255 (inclusive).

## Example Usage

    # A color with red=25, green=50, and blue=200.
    myColor = Color(25, 50, 200)
    # Another color with red=200, green=205, blue=0.
    myOtherColor = Color(200, 205, 0)

    # This will change myColor to have RGB values of (100, 50, 200)
    myColor.setRed(100)

    # This will change myOtherColor to have RGB values of (200, 205, 25)
    myOtherColor.setBlue(25)

    # This will compute the distance between the two colors.
    distance = myColor.colorDistance(myOtherColor)

    # This will print the distance, which happens to be 254.2636427018224.
    print(distance)

## Initialization

`Color.``Color`(self, red, green, blue)

  Parameters: | red (int) – between 0 and 255 (inclusive). green (int) – between 0 and 255 (inclusive). blue (int) – between 0 and 255 (inclusive).

To construct a color object called c:

    c = Color(red, green, blue)

## Methods

This function computes the Euclidean distance between two colors to measure how different they are.

`Color.``colorDistance`(self, other)

    color_dist = color.colorDistance(otherColor)

## Getters

These functions allow you to get color values from color objects.

`Color.``getRGB`(self)

    red, green, blue = color.getRGB()

`Color.``getRed`(self)

    red = color.getRed()

`Color.``getGreen`(self)

    green = color.getGreen()

`Color.``getBlue`(self)

    blue = color.getBlue()

## Setters

These functions allow you to change color values in color objects.

`Color.``setRed`(self, red)

  Parameters: | red (int) – between 0 and 255 (inclusive).

    color.setRed(red)

`Color.``setGreen`(self, green)

  Parameters: | green (int) – between 0 and 255 (inclusive).

    color.setGreen(green)

`Color.``setBlue`(self, blue)

  Parameters: | blue (int) – between 0 and 255 (inclusive).

    color.setBlue(blue)

## Built-in Colors

You can create your own colors, but there are many already built-in!

    # Whites/Pastels
    snow = Color(255, 250, 250)
    snow_2 = Color(238, 233, 233)
    snow_3 = Color(205, 201, 201)
    snow_4 = Color(139, 137, 137)
    ghost_white = Color(248, 248, 255)
    white_smoke = Color(245, 245, 245)
    gainsboro = Color(220, 220, 220)
    floral_white = Color(255, 250, 240)
    old_lace = Color(253, 245, 230)
    linen = Color(240, 240, 230)
    antique_white = Color(250, 235, 215)
    antique_white_2 = Color(238, 223, 204)
    antique_white_3 = Color(205, 192, 176)
    antique_white_4 = Color(139, 131, 120)
    papaya_whip = Color(255, 239, 213)
    blanched_almond = Color(255, 235, 205)
    bisque = Color(255, 228, 196)
    bisque_2 = Color(238, 213, 183)
    bisque_3 = Color(205, 183, 158)
    bisque_4 = Color(139, 125, 107)
    peach_puff = Color(255, 218, 185)
    peach_puff_2 = Color(238, 203, 173)
    peach_puff_3 = Color(205, 175, 149)
    peach_puff_4 = Color(139, 119, 101)
    navajo_white = Color(255, 222, 173)
    moccasin = Color(255, 228, 181)
    cornsilk = Color(255, 248, 220)
    cornsilk_2 = Color(238, 232, 205)
    cornsilk_3 = Color(205, 200, 177)
    cornsilk_4 = Color(139, 136, 120)
    ivory = Color(255, 255, 240)
    ivory_2 = Color(238, 238, 224)
    ivory_3 = Color(205, 205, 193)
    ivory_4 = Color(139, 139, 131)
    lemon_chiffon = Color(255, 250, 205)
    seashell = Color(255, 245, 238)
    seashell_2 = Color(238, 229, 222)
    seashell_3 = Color(205, 197, 191)
    seashell_4 = Color(139, 134, 130)
    honeydew = Color(240, 255, 240)
    honeydew_2 = Color(244, 238, 224)
    honeydew_3 = Color(193, 205, 193)
    honeydew_4 = Color(131, 139, 131)
    mint_cream = Color(245, 255, 250)
    azure = Color(240, 255, 255)
    alice_blue = Color(240, 248, 255)
    lavender = Color(230, 230, 250)
    lavender_blush = Color(255, 240, 245)
    misty_rose = Color(255, 228, 225)
    white = Color(255, 255, 255)

    # Grays
    black = Color(0, 0, 0)
    dark_slate_gray = Color(49, 79, 79)
    dim_gray = Color(105, 105, 105)
    slate_gray = Color(112, 138, 144)
    light_slate_gray = Color(119, 136, 153)
    gray = Color(190, 190, 190)
    light_gray = Color(211, 211, 211)

    # Blues
    midnight_blue = Color(25, 25, 112)
    navy = Color(0, 0, 128)
    cornflower_blue = Color(100, 149, 237)
    dark_slate_blue = Color(72, 61, 139)
    slate_blue = Color(106, 90, 205)
    medium_slate_blue = Color(123, 104, 238)
    light_slate_blue = Color(132, 112, 255)
    medium_blue = Color(0, 0, 205)
    royal_blue = Color(65, 105, 225)
    blue = Color(0, 0, 255)
    dodger_blue = Color(30, 144, 255)
    deep_sky_blue = Color(0, 191, 255)
    sky_blue = Color(135, 206, 250)
    light_sky_blue = Color(135, 206, 250)
    steel_blue = Color(70, 130, 180)
    light_steel_blue = Color(176, 196, 222)
    light_blue = Color(173, 216, 230)
    powder_blue = Color(176, 224, 230)
    pale_turquoise = Color(175, 238, 238)
    dark_turquoise = Color(0, 206, 209)
    medium_turquoise = Color(72, 209, 204)
    turquoise = Color(64, 224, 208)
    cyan = Color(0, 255, 255)
    light_cyan = Color(224, 255, 255)
    cadet_blue = Color(95, 158, 160)

    # Greens
    green = Color(0, 255, 0)
    medium_aquamarine = Color(102, 205, 170)
    aquamarine = Color(127, 255, 212)
    dark_green = Color(0, 100, 0)
    dark_olive_green = Color(85, 107, 47)
    dark_sea_green = Color(143, 188, 143)
    sea_green = Color(46, 139, 87)
    medium_sea_green = Color(60, 179, 113)
    light_sea_green = Color(32, 178, 170)
    pale_green = Color(152, 251, 152)
    spring_green = Color(0, 255, 127)
    lawn_green = Color(124, 252, 0)
    chartreuse = Color(127, 255, 0)
    medium_spring_green = Color(0, 250, 154)
    green_yellow = Color(173, 255, 47)
    lime_green = Color(50, 205, 50)
    yellow_green = Color(154, 205, 50)
    forest_green = Color(34, 139, 34)
    olive_drab = Color(107, 142, 35)
    dark_khaki = Color(189, 183, 107)
    khaki = Color(240, 230, 140)

    # Yellows
    pale_goldenrod = Color(238, 232, 170)
    light_goldenrod_yellow = Color(250, 250, 210)
    light_yellow = Color(255, 255, 224)
    yellow = Color(255, 255, 0)
    gold = Color(255, 215, 0)
    light_goldenrod = Color(238, 221, 130)
    goldenrod = Color(218, 165, 32)
    dark_goldenrod = Color(184, 134, 11)

    # Browns
    rosy_brown = Color(188, 143, 143)
    indian_red = Color(205, 92, 92)
    saddle_brown = Color(139, 69, 19)
    sienna = Color(160, 82, 45)
    peru = Color(205, 133, 63)
    burlywood = Color(222, 184, 135)
    beige = Color(245, 245, 220)
    wheat = Color(245, 222, 179)
    sandy_brown = Color(244, 164, 96)
    tan = Color(210, 180, 140)
    chocolate = Color(210, 105, 30)
    firebrick = Color(178, 34, 34)
    brown = Color(165, 42, 42)

    # Oranges
    dark_salmon = Color(233, 150, 122)
    salmon = Color(250, 128, 114)
    light_salmon = Color(255, 160, 122)
    orange = Color(255, 165, 0)
    dark_orange = Color(255, 140, 0)
    coral = Color(255, 127, 80)
    light_coral = Color(240, 128, 128)
    tomato = Color(255, 99, 71)
    orange_red = Color(255, 69, 0)
    red = Color(255, 0, 0)

    # Pinks/Violets
    hot_pink = Color(255, 105, 180)
    deep_pink = Color(255, 20, 147)
    pink = Color(255, 192, 203)
    light_pink = Color(255, 182, 193)
    pale_violet_red = Color(219, 112, 147)
    maroon = Color(176, 48, 96)
    medium_violet_red = Color(199, 21, 133)
    violet_red = Color(208, 32, 144)
    violet = Color(238, 130, 238)
    plum = Color(221, 160, 221)
    orchid = Color(218, 112, 214)
    medium_orchid = Color(186, 85, 211)
    dark_orchid = Color(153, 50, 204)
    dark_violet = Color(148, 0, 211)
    blue_violet = Color(138, 43, 226)
    purple = Color(160, 32, 240)
    medium_purple = Color(147, 112, 219)
    magenta = Color(255, 0, 255)
    thistle = Color(216, 191, 216)

### Navigation

- index
- next |
- previous |
- CS116 1.0 documentation »