Answers Best — Exploring Rgb Color Codes Codehs
If the exercise asks you to set a specific color using the setBackgroundColor or setColor function with RGB values, here is the syntax:
Example: Setting the background to Purple (Purple is made by mixing Red and Blue)
setBackgroundColor(128, 0, 128);
Example: Setting a shape to Bright Yellow (Yellow is made by mixing Red and Green)
var rect = new Rectangle(100, 50);
rect.setColor(255, 255, 0);
add(rect);
| Course Type | RGB Syntax | Example |
|-------------|------------|---------|
| CodeHS JavaScript Graphics | Color.rgb(r,g,b) | Color.rgb(255,165,0) (orange) |
| CodeHS Web Design (CSS) | rgb(r,g,b) | color: rgb(255,0,0); |
| Python Turtle (CodeHS) | color_rgb(r,g,b) | pencolor(color_rgb(0,255,0)) |
| Requirement | RGB Answer | |-------------|------------| | Pure red | (255, 0, 0) | | Pure green | (0, 255, 0) | | Pure blue | (0, 0, 255) | | Dark gray | (64, 64, 64) | | Light gray | (192, 192, 192) | | Orange | (255, 165, 0) | | Pink | (255, 192, 203) | exploring rgb color codes codehs answers best
To get the best results for “exploring rgb color codes codehs answers”:
RGB stands for Red, Green, Blue. It’s an additive color model used in digital displays (monitors, phones, TVs).
In RGB:
| Color | Red | Green | Blue | |-------|-----|-------|------| | Black | 0 | 0 | 0 | | White | 255 | 255 | 255 | | Red | 255 | 0 | 0 | | Lime | 0 | 255 | 0 | | Blue | 0 | 0 | 255 | | Yellow| 255 | 255 | 0 | | Purple| 128 | 0 | 128 | If the exercise asks you to set a
The best way to learn is to code. In the CodeHS Sandbox, you will often be asked to create a program that displays your favorite color or a gradient.
The Assignment: "Create a circle. Use RGB values to change its color from Blue to Purple."
The Best Solution (JavaScript/Graphics):
// This is the standard CodeHS solution var circle = new Circle(50); circle.setPosition(200, 200);// Starting Blue circle.setColor("rgb(0, 0, 255)"); add(circle); Example: Setting a shape to Bright Yellow (Yellow
// To make it purple, we add Red while keeping Blue high. // Ideal Purple: Red 128, Green 0, Blue 128 circle.setColor("rgb(128, 0, 128)");
Sometimes CodeHS asks you to create random RGB values.
function randomColor()
var r = Math.floor(Math.random() * 256);
var g = Math.floor(Math.random() * 256);
var b = Math.floor(Math.random() * 256);
return "rgb(" + r + ", " + g + ", " + b + ")";
CodeHS Pro Tip: If you see a color looking too dark, the values are too low. If a color is washed out (white-ish), all three values are too high.