Colors in Java

For tthe first cits1001 project you can use the built in Java colours which are defined in java.awt.Color. Here are a few examples. Look up the rest in the Java library documentation.

  import java.awt.Color
  
  Pen pen = new Pen();
  pen.setColor( Color.RED );
  pen.setColor( Color.GREEN );
  pen.setColor( Color.BLUE);
  pen.setColor( Color.BLACK );
However, you may wish to create some more colours. You can do this using the RGB constructor, as shown below. Or if interested, you may also wish to research other colour models such as HSBColor.

Here is a selection of useful RGB colours.

Create a new colour by diving its red, green, blue components:

  import java.awt.Color;
  public static final Color VERY_LIGHT_RED = new Color(255,102,102);

Color

RGB Value

Swatch


Very light red

255-102-102

Light red

255- 51- 51

Red

255- 0 - 0

Dark red

204- 0 - 0

Very dark red

153- 0 - 0


Very light blue

51-204-255

Light blue

51-153-255

Blue

0 - 0 -255

Dark blue

0 - 0 -204

Very dark blue

0 - 0 -153


Very light green

102-255-102

Light green

0 -255- 51

Green

0 -204- 0

Dark green

0 -153- 0

Very dark green

0 -102- 0


Very light yellow

255-255-204

Light yellow

255-255-153

Yellow

255-255- 0

Dark yellow

255-204- 0


Light orange

255-153- 0

Orange

255-102- 0


Gold

255-204- 51


Light grey

204-204-204

Grey

153-153-153

Dark grey

102-102-102

Very dark grey

51- 51- 51


Light brown

153-102- 0

Brown

102- 51- 0

Dark brown

51- 0 - 0


Purple

102- 0 -153


Black

0 - 0 - 0


White

255-255-255