Class Transform2D

. The Transform2D contains information about 2D object's position, rotation and scale. The class follows the 'copy-on-write' pattern, which means that every operation returns a copy of the transform with updated values. It also implies that the values of the transform cannot be directly modified.

The concept of immutability improves sharing of objects as all types in TypeScript are assigned by identity, instead of by-value (e.g. a copy) as in other programming languages like C.

Constructors

Properties

_rotation: number
_scale: Vector2
_translation: Vector2

Accessors

  • get rotation(): number
  • Represents the rotation component of the transform.

    Returns number

  • set rotation(value): void
  • Parameters

    • value: number

    Returns void

  • get scale(): Vector2
  • Represents the scaling component of the transform.

    Returns Vector2

  • set scale(value): void
  • Parameters

    Returns void

  • get translation(): Vector2
  • Represents the translation component of the transform.

    Returns Vector2

  • set translation(value): void
  • Parameters

    Returns void

Methods

  • Copies all properties defined by the prototype of Transform2D from other to this instance.

    Parameters

    Returns Transform2D

  • Clones this instance and returns a new Transform2D with identical values.

    Returns Transform2D

  • Determines if both transforms are equal.

    Parameters

    Returns boolean

  • Returns a string representation of an object.

    Returns string

  • Transforms a Rect2 with the 2D transform.

    Parameters

    Returns Rect2