canvas.set_color(Color(255, 0, 0)) canvas.fill_rect(0, 0, 200, 400)
| Mistake | Explanation | Fix | |---------|-------------|-----| | Using values > 255 | Invalid — color wraps or fails | Clamp between 0–255 | | Forgetting Color.rgb() | setColor(255,0,0) is wrong | Use Color.rgb(255,0,0) | | Mixing CSS and JS syntax | rgb(255,0,0) in JavaScript | Use proper library method | | Assuming grayscale = equal RGB | Correct — e.g., (100,100,100) is gray | That’s actually correct ✅ | exploring rgb color codes codehs answers best
Before we dive into specific answers, you need to understand the rules of the game. In CodeHS (specifically in JavaScript Graphics or Web Design tracks), colors are often created using the rgb(r, g, b) function. canvas
"A student wrote rgb(300, 0, 0) but the code crashed. Why?" Keep experimenting with different values, pay attention to
: Use readInt to get red, green, and blue values (0-255) from the user.
A primary challenge in this module (Exercise 7.1.3) requires students to build a program that goes beyond static color selection: User Input
Mastering RGB color codes is more than just a requirement for passing a CodeHS quiz; it is a creative superpower. Once you understand how to manipulate light through code, you gain total control over the visual impact of your digital creations. Keep experimenting with different values, pay attention to contrast, and don't be afraid to use color pickers to find that perfect shade.