Java Reference
In-Depth Information
In the file Main.fx, the Emitter is initialized and in this case the blendMode is bound to the variable
blendMode . The variable blendMode is of type BlendMode and is set by the UI components.
The class BlendMode provides constants, so it is as simple as:
blendMode = BlendMode.ADD;
As mentioned above, the color of the nodes was changed. Here is the code that does this:
fill = Color{
red: 1.0
green: 0.4
blue: 0.2
Again, a completely red node was not used because blend effects look a lot better when there are
multiple colors to work with. In fact, blend modes look the best when the nodes are much more
complicated than a simple circle. The following section looks at using simple raster images to produce
even more interesting effects.
Performance Considerations By playing with the example application, it becomes clear that using blend
effects is not a computationally cheap operation. The number of nodes that can be involved is considerably lower
than when no blend mode is used. When designing an application that uses this technique, be sure to use this
feature wisely. It can produce stunning effects—but it can also bring the application to a halt. One strategy for
controlling performance degradation might be keeping track of the total number of blended particles in the
application, and simply adding no more when a preset limit is reached. Particles are almost always decoration in a
scene, so will the user notice if there are only four sparks instead of ten?
Example 5: Nonuniform Nodes
The previous examples all used circular particles, and it is easy to imagine those same examples using
rectangles, stars, or some other shape. To explore such options, simply have Particle extend the desired
shape. This example will explore the benefits of using raster images with nonuniform transparency as
the basis of a particle.
The best bitmaps to use are small, have no hard edges, have some transparency, and are not a single
color. These features are important because they make it easier to blur the particles together into a
seamless visual effect. Modeling a firework explosion does not require that that the particles blend
together, but modeling things like fire, smoke, or water works better when each particle is not visually
The image used in this example has all of the features listed above.
Search WWH ::

Custom Search