public class ShapeInterpolator
extends java.lang.Object
Shape objects.
This class can be used to morph between the geometries
of two relatively arbitrary shapes with the only restrictions being
that the two different numbers of sub-paths or two shapes with
disparate winding rules may not blend together in a pleasing
manner.
The ShapeEvaluator will do the best job it can if the shapes do
not match in winding rule or number of sub-paths, but the geometry
of the shapes may need to be adjusted by other means to make the
shapes more like each other for best aesthetic effect.
Note that the process of comparing two geometries and finding similar
structures between them to blend for the morphing operation can be
expensive.
Instances of this class will properly perform the necessary
geometric analysis of their arguments on every method call and attempt
to cache the information so that they can operate more quickly if called
multiple times in a row on the same pair of Shape objects.
As a result attempting to mutate a Shape object that is stored
in one of their keyframes may not have any effect if the associated
interpolator has already cached the geometry.
Also, it is advisable to use different instances of ShapeEvaluator
for every pair of keyframes being morphed so that the cached information
can be reused as much as possible.
| Constructor and Description |
|---|
ShapeInterpolator() |
| Modifier and Type | Method and Description |
|---|---|
static java.awt.Shape |
apply(java.awt.Shape v0,
java.awt.Shape v1,
float fraction) |
static java.awt.Shape |
apply(java.awt.Shape v0,
java.awt.Shape v1,
float fraction,
boolean unionBounds) |
java.awt.Shape |
evaluate(java.awt.Shape v0,
java.awt.Shape v1,
float fraction)
Creates an interpolated shape from tight bounds.
|
java.awt.Shape |
evaluate(java.awt.Shape v0,
java.awt.Shape v1,
float fraction,
boolean unionBounds)
Creates an interpolated shape.
|
public static java.awt.Shape apply(java.awt.Shape v0,
java.awt.Shape v1,
float fraction)
public static java.awt.Shape apply(java.awt.Shape v0,
java.awt.Shape v1,
float fraction,
boolean unionBounds)
public java.awt.Shape evaluate(java.awt.Shape v0,
java.awt.Shape v1,
float fraction)
public java.awt.Shape evaluate(java.awt.Shape v0,
java.awt.Shape v1,
float fraction,
boolean unionBounds)
v0 - the first shapev1 - the second shapefraction - the fraction from zero (just first shape) to one (just second shape)unionBounds - if `true`, the shape reports bounds which are the union of
the bounds of both shapes, if `false` it reports "tight" bounds
using the actual interpolated path.