The tricky part of RGB is guessing what happens when you mix two lights together. Here is the cheat sheet:
| Mix These... | You Get This... | RGB Code |
| :--- | :--- | :--- |
| Red + Green | Yellow | (255, 255, 0) |
| Red + Blue | Magenta (Purple) | (255, 0, 255) |
| Green + Blue | Cyan (Light Blue) | (0, 255, 255) |
In many CodeHS lessons (e.g., JavaScript Graphics), you might have to:
Example JavaScript (CodeHS Graphics):
var rect = new Rectangle(100, 100);
rect.setPosition(50, 50);
rect.setColor(rgb(255, 0, 0)); // red
add(rect);
Or, for Tracy the Turtle (Python-like), you might use:
color(rgb(255, 0, 0)) # red
If the assignment asks you to write code to set the background or draw a shape with a specific color, here is the syntax you need.
Scenario A: Setting the Background Color To set the background to Cyan (Green + Blue):
setBackground(Color(0, 255, 255));
Scenario B: Drawing a Circle To draw a circle that is Yellow:
// Create the circle
var circle = new Circle(50);
circle.setPosition(100, 100);
// Set the color using RGB values
circle.setColor(Color(255, 255, 0));
// Add to screen
add(circle);
Scenario C: Making Colors "Hot" (Darker/Lighter) Sometimes CodeHS asks how to make a color darker or lighter.
The tricky part of RGB is guessing what happens when you mix two lights together. Here is the cheat sheet:
| Mix These... | You Get This... | RGB Code |
| :--- | :--- | :--- |
| Red + Green | Yellow | (255, 255, 0) |
| Red + Blue | Magenta (Purple) | (255, 0, 255) |
| Green + Blue | Cyan (Light Blue) | (0, 255, 255) |
In many CodeHS lessons (e.g., JavaScript Graphics), you might have to: exploring rgb color codes codehs answers google hot
Example JavaScript (CodeHS Graphics):
var rect = new Rectangle(100, 100);
rect.setPosition(50, 50);
rect.setColor(rgb(255, 0, 0)); // red
add(rect);
Or, for Tracy the Turtle (Python-like), you might use: The tricky part of RGB is guessing what
color(rgb(255, 0, 0)) # red
If the assignment asks you to write code to set the background or draw a shape with a specific color, here is the syntax you need.
Scenario A: Setting the Background Color To set the background to Cyan (Green + Blue): Example JavaScript (CodeHS Graphics): var rect = new
setBackground(Color(0, 255, 255));
Scenario B: Drawing a Circle To draw a circle that is Yellow:
// Create the circle
var circle = new Circle(50);
circle.setPosition(100, 100);
// Set the color using RGB values
circle.setColor(Color(255, 255, 0));
// Add to screen
add(circle);
Scenario C: Making Colors "Hot" (Darker/Lighter) Sometimes CodeHS asks how to make a color darker or lighter.