Color()
A colour. Colours never change: withHue(\u2026) and the other with methods return a
new colour, so a colour can be shared, kept in a constant (HtmlColor) or handed to
several sprites without one of them changing it for the others.
A colour can be given in two ways:
- red, green and blue from 0 to 255, plus an optional alpha (opacity) from 0 to 255: `new Color(255, 128, 0)`;
- Scratch's colour, saturation and brightness, each from 0 to 100: `Color.fromHSB(50, 100, 100)`. The colour (hue) goes around: 0 is red, about 17 yellow, 33 green, 50 cyan, 67 blue, 83 magenta, 100 red again.
Color orange = new Color(255, 128, 0);
Color lighter = orange.withBrightness(100).withSaturation(50);
Color next = orange.withHue(orange.getHue() + 10);
Syntax
Java
new Color(red, green, blue)
new Color(red, green, blue, alpha)
new Color(hex)