Package com.xebisco.yield
Class Transform2D
java.lang.Object
com.xebisco.yield.Transform2D
A class representing the transformation of a 2D object.
This class encapsulates the position, scale, and rotation of a 2D object. It provides methods to translate, scale, and rotate the object.
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a newTransform2Dinstance.Constructs a newTransform2Dinstance from another Transform2D instance. -
Method Summary
Modifier and TypeMethodDescriptionanchor()Returns the anchor of the object.position()Returns the position of the object.voidrotate(double value) Rotates the object by a specified angle around the z-axis.scale()Returns the scale of the object.voidscale(double x, double y) Scales theTransform2Dobject by a given x and y value.voidScales theTransform2Dobject using aVector2D.setAnchor(ObjectAnchor anchor) Sets the object's anchor.setzRotation(double zRotation) Sets the z-rotation of the object.voidtranslate(double x, double y) Translates theTransform2Dposition by a given x and y value.voidTranslates the position of the object by adding aVector2Dvalue to it.doubleReturns the z-rotation of the object.
-
Constructor Details
-
Transform2D
public Transform2D()Constructs a newTransform2Dinstance. -
Transform2D
Constructs a newTransform2Dinstance from another Transform2D instance.- Parameters:
t- TheTransform2Dinstance to copy.
-
-
Method Details
-
translate
Translates the position of the object by adding aVector2Dvalue to it.- Parameters:
value- TheVector2Dobject to translate thisTransform2Dinstance position.
-
translate
public void translate(double x, double y) Translates theTransform2Dposition by a given x and y value.- Parameters:
x- The x-coordinate by which the object will be translated.y- The y-coordinate by which the object will be translated.
-
scale
public void scale(double x, double y) Scales theTransform2Dobject by a given x and y value.- Parameters:
x- The value to scale the object horizontally.y- The value to scale the object vertically.
-
scale
Scales theTransform2Dobject using aVector2D.- Parameters:
value- TheVector2Dobject to scale thisTransform2Dinstance.
-
rotate
public void rotate(double value) Rotates the object by a specified angle around the z-axis.- Parameters:
value- A double type variable that represents the degrees of rotation.
-
position
Returns the position of the object.- Returns:
- The position of the object.
-
scale
Returns the scale of the object.- Returns:
- The scale of the object.
-
zRotation
public double zRotation()Returns the z-rotation of the object.- Returns:
- The z-rotation of the object.
-
setzRotation
Sets the z-rotation of the object.- Parameters:
zRotation- The new z-rotation value.- Returns:
- This
Transform2Dinstance for method chaining.
-
anchor
Returns the anchor of the object.- Returns:
- The anchor of the object.
-
setAnchor
Sets the object's anchor.- Parameters:
anchor- The new object anchor.- Returns:
- This
Transform2Dinstance for method chaining.
-