Java Reference
In-Depth Information
The resulting image shows, even in grayscale, that the text appearing inside the
rectangle is white. This happens because the rectangle color, specified in (R, G, B),
is (255, 0, 255), whereas the text has a color of (0, 255, 0). If we add each of the
individual components up, we get a resulting color of (255, 255, 255).
For our next example, we'll make one small code change to Listing 6.4 to dem-
onstrate a different BlendMode effect. Replace the BlendMode.ADD occurrence
with BlendMode.MULTIPLY as follows:
blendMode: BlendMode.MULTIPLY
Figure 6.19 shows the result.
Figure 6.19
BlendMode.MULTIPLY Effect
This time, the text enclosed within the rectangle is black. Why? Because the
individual color components are multiplied with one another rather than added.
The resulting (R, G, B) color is now (0, 0, 0).
For our next example, we'll utilize the Blend effect to demonstrate two addi-
tional BlendMode s. Blend includes, among others, two instance variables called
topInput and bottomInput which, as their names imply, let you identify both
top and bottom inputs, respectively, for blending. We'll specify the topInput
variable to show how the SRC_OUT and SRC_IN BlendMode s can be used and how
they differ.
Our code for this segment furthermore introduces a new effect called Flood ,
which “floods” a rectangular region with an effect denoted by its paint instance
variable (in this case, a LinearGradient instance). This could be used as a poten-
tially more efficient alternative to rendering a Rectangle . Before showing the
listing and the resulting output, Table 6.4 describes the available SRC BlendMode s.
Just in case you're a little confused by the descriptions, let's show how an exam-
ple usage of SRC_OUT might be coded. Listing 6.5 has the specifics.
Search WWH ::




Custom Search