Design in Java and LOGO II


COLOR: We've already had a basic lesson on RGB values and how to set color in JAVA. In this lesson we will look at a few more details.

There are three constructors for the Color class:

Color(int r, int g, int b); Color(int rgb); Color(float r, float g, float b); You've already seen how to use the first inside a call to setColor which you would use inside the paint method:

g.setColor(new Color(255, 0, 0)); The other real useful constructor is used like this:

g.setColor(new Color(0xff0000)); Both of these examples will set the current color to red. Using RGB values which are encoded as HEXADECIMAL values is often easier than using decimal values. To use a HEX value you need to start the number with "0x" in order for the compiler (the javac program) to recognize what your intentions are. The GIMP will provide HEX values for you and so this is all you need to know in order to use HEX values with this constructor.

ASSIGNMENT: Create and display the following design as an applet and as a LOGO image. Include the code for each in two separate text areas. NOTE: You must use the Color constructor with HEX values for at least six of your colors AND all sixteen of your colors must be unique (although they can be different SHADES of the same color).