Transformation
final class Transformation
Package: dev.joid.lib.render.transform · Module: core · Source: Transformation.java
A list of translations, rotations and scales applied to the model-view matrix around what you draw.
Description
Section titled “Description”Build it once, then apply it around your drawing (Rotate and scale a drawing).
The operations run in the order you add them, and the suppliers are read each time the transformation is applied, so a transformation can follow a value that changes. A translation also tells the pixel grid how far the drawing moved, so that a moving node stays sharp. A node effect transforms a node; reach for this class in your own drawing.
Learn more
Section titled “Learn more”Creation
Section titled “Creation”| Returns | Signature | Summary |
|---|---|---|
Transformation | create() factory | Creates a transformation without operations. |
Methods
Section titled “Methods”| Returns | Signature | Summary |
|---|---|---|
this | translate(Vector vector) fluent | Adds a move by vector, in design pixels. |
this | rotate(double angle, Rotation rotation) fluent | Adds a rotation of angle degrees around the axis rotation, about the pivot given to transform ((0, 0) with apply). |
this | rotate(Supplier | Adds a rotation of the angle read from angle each time, in degrees. |
this | rotate(double angle, Rotation rotation, Vector pivot) fluent | Adds a rotation of angle degrees around the axis rotation, about pivot; a null pivot uses the pivot given to transform. |
this | rotate(Supplier | Adds a rotation of the angle read from angle each time, about pivot. |
this | scale(Scale scale) fluent | Adds a scale by scale, about the pivot given to transform. |
this | scale(Scale scale, Vector pivot) fluent | Adds a scale by scale, about pivot; a null pivot uses the pivot given to transform. |
void | apply() | Pushes the model-view matrix and applies the operations; call reset() after your drawing to pop it. |
void | apply(Runnable drawing) | Applies the operations around drawing, then restores the model-view matrix, even when drawing throws. |
void | reset() | Pops the model-view matrix pushed by apply(). |
void | transform(double pivotX, double pivotY) | Applies the operations to the current model-view matrix without pushing it, with pivotX, pivotY as the pivot of the operations that have none. |
void | clear() | Removes every operation. |
Creation details
Section titled “Creation details”create
Section titled “create”Transformation create() factory
Creates a transformation without operations.
Method details
Section titled “Method details”translate
Section titled “translate”this translate(Vector vector) fluent
Adds a move by vector, in design pixels.
rotate
Section titled “rotate”this rotate(double angle, Rotation rotation) fluent
Adds a rotation of angle degrees around the axis rotation, about the pivot given to transform ((0, 0) with apply).
this rotate(Supplier<Double> angle, Rotation rotation) fluent
Adds a rotation of the angle read from angle each time, in degrees.
this rotate(double angle, Rotation rotation, Vector pivot) fluent
Adds a rotation of angle degrees around the axis rotation, about pivot; a null pivot uses the pivot given to transform.
this rotate(Supplier<Double> angle, Rotation rotation, Vector pivot) fluent
Adds a rotation of the angle read from angle each time, about pivot.
this scale(Scale scale) fluent
Adds a scale by scale, about the pivot given to transform.
this scale(Scale scale, Vector pivot) fluent
Adds a scale by scale, about pivot; a null pivot uses the pivot given to transform.
void apply()
Pushes the model-view matrix and applies the operations; call reset() after your drawing to pop it.
void apply(Runnable drawing)
Applies the operations around drawing, then restores the model-view matrix, even when drawing throws.
void reset()
Pops the model-view matrix pushed by apply().
transform
Section titled “transform”void transform(double pivotX, double pivotY)
Applies the operations to the current model-view matrix without pushing it, with pivotX, pivotY as the pivot of the operations that have none.
void clear()
Removes every operation.
fluent returns the instance, typed for chaining · factory creates an instance · signal also accepts a value that follows signals, as a signal, an expression or a lambda (When does JOID compute this value again?) · hook called by JOID, override it · abstract you implement it · default interface method with a body · static called on the class · protected visible to subclasses
