PencilCoder

Colors!

Goals:

  • Learn how to mix up your own colors on a computer, by blending together different amounts of light.

Coding Snippets:

  • coding snippets
  • Use the rgb function to define colors.
  • The loop block shown on the left repeats 10 times. In each iteration, the variable x takes on a value, starting with 0 on the first pass, 1 on the second, and so on, up to 9 on the final iteration.

Math and Computer Concepts:

  • The rgb function creates colors based on light. When you mix light, you get brighter and brighter colors. This is different than mixing paints, such as in art class. When you mix paint, you get darker and darker colors. (With light, red + green = yellow!)
  • Blank space
  • rgb takes three whole numbers between 0 and 255 as inputs. Each number specifies how much red, green, and blue light should be added together—the bigger the number, the more of that color you mix in. With 256 values for each input, you have (literally) millions of options: 256 × 256 × 256 = 16,777,216 !

Activities:

Use loops to accomplish the following tasks using as few lines of code as possible. Save all programs for today's class in a folder called Colors.