Welcome to the CSC Q&A, where you can get help (and share your knowledge) about computer science!

Something Helpful for Creating your OWN Color using DrawingPanel

+7 votes

We know how to call the DrawingPanel, hopefully, but you can actually create your own colors for use in the DrawingPanel! This might be useful for the new Owl Racing project, since Screecher has to be  brown, and there is no pre-set "Color.BROWN."

First, use this website to find the color you want to use. Once you find the color you want, note the values labelled "R," "G," and "B." These are the Red, Green, Blue values for your new color. In Eclipse, once you have your "RGB" values, you simply plug them in for the "R, G, and B" values below!

Color yourColorNameHere = new Color (R, G, B);

This will allow you to summon your new color by using "yourColorNameHere" in places that call for a color! What's neat is that you could also, conceivably, randomize your RGB values....  ;)

asked Jan 25, 2015 in (Winter 14) by Nicholas Misner (100 points)
As a follow-up: note that each R,G,B value should be between 0 and 255.  

Why? this is because most color components are stored in ONE BYTE (8 bits) of memory, and using 8 bits you can only store 256 distinct values -- namely, the integers between 0 and 255.

1 Answer

0 votes
Thanks for the tip!
answered Jan 28, 2015 by B Hook (100 points)