Skip to content

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.

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.

ReturnsSignatureSummary
Transformationcreate() factoryCreates a transformation without operations.

ReturnsSignatureSummary
thistranslate(Vector vector) fluentAdds a move by vector, in design pixels.
thisrotate(double angle, Rotation rotation) fluentAdds a rotation of angle degrees around the axis rotation, about the pivot given to transform ((0, 0) with apply).
thisrotate(Supplier angle, Rotation rotation) fluentAdds a rotation of the angle read from angle each time, in degrees.
thisrotate(double angle, Rotation rotation, Vector pivot) fluentAdds a rotation of angle degrees around the axis rotation, about pivot; a null pivot uses the pivot given to transform.
thisrotate(Supplier angle, Rotation rotation, Vector pivot) fluentAdds a rotation of the angle read from angle each time, about pivot.
thisscale(Scale scale) fluentAdds a scale by scale, about the pivot given to transform.
thisscale(Scale scale, Vector pivot) fluentAdds a scale by scale, about pivot; a null pivot uses the pivot given to transform.
voidapply()Pushes the model-view matrix and applies the operations; call reset() after your drawing to pop it.
voidapply(Runnable drawing)Applies the operations around drawing, then restores the model-view matrix, even when drawing throws.
voidreset()Pops the model-view matrix pushed by apply().
voidtransform(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.
voidclear()Removes every operation.

Transformation create() factory

Creates a transformation without operations.

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<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().

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

Report a problem with this page