Class Transform2D

java.lang.Object
com.xebisco.yield.Transform2D

public class Transform2D extends Object
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 Details

    • Transform2D

      public Transform2D()
      Constructs a new Transform2D instance.
    • Transform2D

      public Transform2D(Transform2D t)
      Constructs a new Transform2D instance from another Transform2D instance.
      Parameters:
      t - The Transform2D instance to copy.
  • Method Details

    • translate

      public void translate(Vector2D value)
      Translates the position of the object by adding a Vector2D value to it.
      Parameters:
      value - The Vector2D object to translate this Transform2D instance position.
    • translate

      public void translate(double x, double y)
      Translates the Transform2D position 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 the Transform2D object 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

      public void scale(Vector2D value)
      Scales the Transform2D object using a Vector2D.
      Parameters:
      value - The Vector2D object to scale this Transform2D instance.
    • 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

      public Vector2D position()
      Returns the position of the object.
      Returns:
      The position of the object.
    • scale

      public Vector2D 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

      public Transform2D setzRotation(double zRotation)
      Sets the z-rotation of the object.
      Parameters:
      zRotation - The new z-rotation value.
      Returns:
      This Transform2D instance for method chaining.
    • anchor

      public ObjectAnchor anchor()
      Returns the anchor of the object.
      Returns:
      The anchor of the object.
    • setAnchor

      public Transform2D setAnchor(ObjectAnchor anchor)
      Sets the object's anchor.
      Parameters:
      anchor - The new object anchor.
      Returns:
      This Transform2D instance for method chaining.