Skip to content

Latest commit

 

History

History
18 lines (11 loc) · 876 Bytes

File metadata and controls

18 lines (11 loc) · 876 Bytes

Lab 7.01: Create a Color Class

In this lab we will create a class that will represent colors and build a function to combine two colors.

Background

RGB is a way of storing color data. R stands for red, G stands for green, and B stands for blue. Each color is given a value from 0 to 255.

You can use this tool to see the RGB values for different colors: https://www.rapidtables.com/web/color/RGB_Color.html

https://media.24ways.org/2009/01/f1.gif

Lab

  1. Create a class, Color.
  2. Instantiate at least 3 colors.
  3. Add attributes of r, g, and b to those instances.
  4. Create a function, add_color, which takes in two colors and returns a color that is the sum of the two reds, greens, and blues. Don't forget: the maximum value for R, G, or B is 255.