Java Reference
In-Depth Information
Performance Consideration While transparency is not as costly as the effects described in the next section,
having a hundred or so transparent nodes in a scene can cause performance issues. Keep in mind when designing
an application that transparent nodes in general are more expensive than completely opaque nodes.
Example 4: Blend Mode
Transparency is an excellent means of producing a smooth visual effect. Another technique, setting the
blend mode of the emitter (the parent node to each particle) can create the types of effects seen in video
games and other high-end animations.
To understand blend modes, it is best to consider how nodes are drawn in general. When two nodes
overlap in the scene, usually one is drawn and then the other is drawn “over” the first. In other words,
the pixels that make up the second node replace the pixels that make up the first. If the second node is
partially opaque, the pixels from the first node and the pixels from the second are combined to produce
a third value.
This is basically how blend modes work. Instead of simply replacing the value of one pixel with
another, a function takes the two pixel values and produces a third value. Remember that a pixel's color
is composed of four values, red, green, blue and alpha, so the functions can produce some surprising
results.
There are several blend modes that come with JavaFX, but they do not all lend themselves to particle
systems. In the example code, the blend effect can be set to ADD , MULTIPLY , SCREEN, and, of course, no
blend effect.
For Example 4, the color of the Particle was changed to an orange-like color by adding a little green
and a little blue to the red. The blendMode of the Emitter was then set to BlendMode.ADD . This causes the
pixels with the greatest amount of overlap to be completely white, as in the center of the cluster of nodes
in Figure 2-6. Where there is no overlap the pixels are the normal orange color. Combining the red,
green, and blue values of each pixel produces the white color. If the nodes were completely red, this
blend mode would not do anything.
Search WWH ::




Custom Search