Feature
-
Cmn
abstract class Feature
While a polygon's shape can be drawn solely using a list of Cubic objects representing its raw curves and lines, features add an extra layer of context to groups of cubics. Features group cubics into (straight) edges, convex corners, or concave corners. For example, rounding a rectangle adds many cubics around its edges, but the rectangle's overall number of corners remains the same. Morph therefore uses this grouping for several reasons:
-
Noise Reduction: Grouping cubics reduces the amount of noise introduced by individual cubics (as seen in the rounded rectangle example).
-
Mapping Base: The grouping serves as the base set for
Morph's mapping process. -
Curve Type Mapping:
Morphmaps similar curve types (convex, concave) together. Note that edges or features created withbuildIgnorableFeatureare ignored in the default mapping.
By using features, you can manipulate polygon shapes with more context and control.
Summary
Nested types |
|---|
object Feature.Factory |
Public companion functions |
||
|---|---|---|
Feature |
buildConcaveCorner(cubics: List<Cubic>)Group a list of |
Cmn
|
Feature |
buildConvexCorner(cubics: List<Cubic>)Group a list of |
Cmn
|
Feature |
Group a |
Cmn
|
Feature |
buildIgnorableFeature(cubics: List<Cubic>)Group a list of |
Cmn
|
Public functions |
||
|---|---|---|
abstract Feature |
reversed()Returns a new |
Cmn
|
abstract Feature |
Transforms the points in this |
Cmn
|
Public properties |
||
|---|---|---|
List<Cubic> |
Cmn
|
|
abstract Boolean |
Whether this Feature is a concave corner (inward indentation in a shape). |
Cmn
|
abstract Boolean |
Whether this Feature is a convex corner (outward indentation in a shape). |
Cmn
|
abstract Boolean |
Whether this Feature is an Edge with no inward or outward indentation. |
Cmn
|
abstract Boolean |
Whether this Feature gets ignored in the Morph mapping. |
Cmn
|
Public companion functions
buildConcaveCorner
fun buildConcaveCorner(cubics: List<Cubic>): Feature
Group a list of Cubic objects to a concave corner (inward indentation in a shape).
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
for lists of empty cubics or non-continuous cubics |
buildConvexCorner
fun buildConvexCorner(cubics: List<Cubic>): Feature
Group a list of Cubic objects to a convex corner (outward indentation in a shape).
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
for lists of empty cubics or non-continuous cubics |
buildEdge
fun buildEdge(cubic: Cubic): Feature
Group a Cubic object to an edge (neither inward or outward identification in a shape).
| Parameters | |
|---|---|
cubic: Cubic |
The raw cubic describing the edge's shape |
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
for lists of empty cubics or non-continuous cubics |
buildIgnorableFeature
fun buildIgnorableFeature(cubics: List<Cubic>): Feature
Group a list of Cubic objects to a feature that should be ignored in the default Morph mapping. The feature can have any indentation.
Sometimes, it's helpful to ignore certain features when morphing shapes. This is because only the features you mark as important will be smoothly transitioned between the start and end shapes. Additionally, the default morph algorithm will try to match convex corners to convex corners and concave to concave. Marking features as ignorable will influence this matching. For example, given a 12-pointed star, marking all concave corners as ignorable will create a Morph that only considers the outer corners of the star. As a result, depending on the morphed to shape, the animation may have fewer intersections and rotations. Another example for the other way around is a Morph between a pointed up triangle to a square. Marking the square's top edge as a convex corner matches it to the triangle's upper corner. Instead of moving triangle's upper corner to one of rectangle's corners, the animation now splits the triangle to match squares' outer corners.
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
for lists of empty cubics or non-continuous cubics |
Public functions
reversed
abstract fun reversed(): Feature
Returns a new Feature with the points that define the shape of this Feature in reversed order.
transformed
abstract fun transformed(f: PointTransformer): Feature
Transforms the points in this Feature with the given PointTransformer and returns a new Feature
| Parameters | |
|---|---|
f: PointTransformer |
The |
Public properties
isConcaveCorner
abstract val isConcaveCorner: Boolean
Whether this Feature is a concave corner (inward indentation in a shape).
isConvexCorner
abstract val isConvexCorner: Boolean
Whether this Feature is a convex corner (outward indentation in a shape).
isEdge
abstract val isEdge: Boolean
Whether this Feature is an Edge with no inward or outward indentation.
isIgnorableFeature
abstract val isIgnorableFeature: Boolean
Whether this Feature gets ignored in the Morph mapping. See buildIgnorableFeature for more details.