org.jsfml.graphics

Class Transform

• Field Detail

• IDENTITY

public static final Transform IDENTITY
The identity transformation, maps any vector to itself and therefore "does nothing".
• Constructor Detail

• Transform

public Transform()
Constructs an identity transformation.
• Transform

public Transform(float a00,
float a01,
float a02,
float a10,
float a11,
float a12,
float a20,
float a21,
float a22)
Constructs a new transformation from a 3x3 matrix of the following format:
a00, a01, a02,
a10, a11, a12,
a20, a21, a22
Parameters:
a00 - Matrix component.
a01 - Matrix component.
a02 - Matrix component.
a10 - Matrix component.
a11 - Matrix component.
a12 - Matrix component.
a20 - Matrix component.
a21 - Matrix component.
a22 - Matrix component.
• Transform

public Transform(Transform t)
Constructs a new transformation by copying another transformation.
Parameters:
t - the transformation to copy.
• Method Detail

• combine

public static Transform combine(Transform t1,
Transform t2)
Combines two transformation matrices by multiplying them.
Parameters:
t1 - the first transformation matrix.
t2 - the second transformation matrix.
Returns:
the product of the two given matrices.
• translate

public static Transform translate(Transform t,
float x,
float y)
Adds a translation by a 2D vector to a transformation.
Parameters:
t - the transformation to apply the translation on.
x - the X coordinate of the translation vector.
y - the Y coordinate of the translation vector.
Returns:
a new transformation matrix with the translation applied.
• translate

public static Transform translate(Transform t,
Vector2f v)
Adds a translation by a 2D vector to a transformation.
Parameters:
t - the transformation to apply the translation to.
v - the translation vector.
Returns:
a new transformation matrix with the translation applied.
• rotate

public static Transform rotate(Transform t,
float angle)
Adds a rotation around the origin to a transformation.
Parameters:
t - the transformation to apply the rotation on.
angle - the rotation angle in degrees.
Returns:
a new transformation with the rotation applied
• rotate

public static Transform rotate(Transform t,
float angle,
float centerX,
float centerY)
Adds a rotation around an arbitrary center to this transformation.
Parameters:
t - the transformation to apply the rotation on.
angle - the rotation angle in degrees.
centerX - the X coordinate of the rotation center.
centerY - the Y coordinate of the rotation center.
Returns:
a new transformation with the rotation applied.
• rotate

public static Transform rotate(Transform t,
float angle,
Vector2f center)
Adds a rotation around an arbitrary center to this transformation.
Parameters:
t - the transformation to apply the rotation on.
angle - the rotation angle in degrees.
center - the rotation center.
Returns:
a new transformation with the rotation applied.
• scale

public static Transform scale(Transform t,
float scaleX,
float scaleY)
Adds a scaling operation from the origin to a transformation.
Parameters:
t - the transform to apply the scaling on.
scaleX - the X factor of the scaling operation.
scaleY - the Y factor of the scaling operation.
Returns:
a new transformation with the scaling applied.
• scale

public static Transform scale(Transform t,
Vector2f factors)
Adds a scaling operation from the origin to a transformation.
Parameters:
t - the transform to apply the scaling on.
factors - the factors of the scaling operation.
Returns:
a new transformation with the scaling applied.
• scale

public static Transform scale(Transform t,
float scaleX,
float scaleY,
float centerX,
float centerY)
Adds a scaling operation from an arbitrary center to a transformation.
Parameters:
t - the transform to apply the scaling on.
scaleX - the X factor of the scaling operation.
scaleY - the Y factor of the scaling operation.
centerX - the X coordinate of the scaling center.
centerY - the Y coordinate of the scaling center.
Returns:
a new transformation with the scaling applied.
• scale

public static Transform scale(Transform t,
Vector2f factors,
Vector2f center)
Adds a scaling operation from an arbitrary center to a transformation.
Parameters:
t - the transform to apply the scaling on.
factors - the factors of the scaling operation.
center - the scaling center.
Returns:
a new transformation with the scaling applied.
• getMatrix

public float[] getMatrix()
Gets a copy of the underlying 4x4 3D transformation matrix.
Returns:
a copy of the underlying 4x4 3D transformation matrix.
• getInverse

public Transform getInverse()
Returns the inverse transformation.
Returns:
the inverse transformation, or the identity transformation if the matrix cannot be inverted.
• transformPoint

public Vector2f transformPoint(float x,
float y)
Transforms a 2D point using the transformation matrix.
Parameters:
x - the X coordinate of the point.
y - the Y coordinate of the point.
Returns:
a new 2D vector, representing the transformed point.
• transformPoint

public final Vector2f transformPoint(Vector2f v)
Transforms a 2D point using the transformation matrix.
Parameters:
v - the point to transform.
Returns:
a new 2D vector, representing the transformed point.
• transformRect

public FloatRect transformRect(FloatRect rectangle)
Transforms a rectangle and returns the axis-aligned bounding rectangle.
Parameters:
rectangle - the rectangle to transform.
Returns:
the axis-aligned bounding rectangle of the rotated rectangle.
• hashCode

public int hashCode()
Overrides:
hashCode in class Object