Java Reference
In-Depth Information
Color
The class Color is a simple class that allows colors to be described as values of red, green, and blue, plus
opacity. This is a standard way to represent color in software and not much of a surprise. It is worth
noting that the range for each value is from 0.0 to 1.0.
Color also has a number of static Colors that can be easily referenced, such as Color.ANTIQUEWHITE
and standard colors including RED , BLUE , GREEN , and YELLOW .
The class Color also comes with several static utility functions that can be used to create Colors from
other methods of representing color. For example, the function Color.hsb can be used to specify a color
in terms of hue, saturation, and brightness. There is also the function Color.web , which can be used to
construct a Color from a String representation commonly used in cascading style sheets (CSS). For
example, calling Color.web(“#FF0000”) will return a Color object that represents red. Most of these utility
functions include a second form where you also specify the opacity of the color.
Linear Gradient
The class LinearGradient is used to describe the transition between two or more Colors across a section
of the scene. Imagine a rainbow created by a prism—there are parts that are clearly red and yellow, but
there are also colors in-between that are orangey. This is basically how a LinearGradient works: It
specifies a number of points along the gradient and says this one is red, and here is yellow, and this
states that the space between those points will be an interpolation of those two colors.
Figure 8-1 shows a rainbow-like pattern in grey scale on a number line going from 0.0 to 1.0, plus a
number of points that define where the gradient should be a specific color.
Figure 8-1. Rainbow-like pattern as a LinearGradient
Search WWH ::




Custom Search