Foundation.TransformState2

A wrapper for TransformableObjects which keep an original and transformed state. It should be noted that the translate() and transform() methods in this implementation operate differently than they do in other implementations.


Example

var ts2 = new TransformState2<Rectangle>(new Rectangle(1, 2, 10, 20));

// Set the total amount of translation
ts2.translate(1, 1);

// The difference between original and transformed states
console.log("orgiginal   x: " + ts2.original.x);     // 1
console.log("orgiginal   y: " + ts2.original.y);     // 2
console.log("transformed x: " + ts2.transformed.x);  // 2 (1 + 1)
console.log("transformed y: " + ts2.transformed.y);  // 3 (2 + 1)

// Note that transformations are not compounded, but set from original:
ts2.translate(10, 10);
console.log("orgiginal   x: " + ts2.original.x);     // 1
console.log("orgiginal   y: " + ts2.original.y);     // 2
console.log("transformed x: " + ts2.transformed.x);  // 11 (1 + 10)
console.log("transformed y: " + ts2.transformed.y);  // 12 (2 + 10)


Implementation Details

Reference paths

  • '/foundation/_digest.ts'
  • '/foundation/core/utilities/_digest.ts'
  • '/foundation/core/utilities/TransformState2.ts'

Extends

This type does not extend a base type.

Implements

This type implements the following interfaces:

Methods may behave differently to normal implementations, see below. equals(), clone() and setTo() methods behave as normal.


Public Properties

original

  • The original form of the object, before transformations

transformed

  • The transformed form of the object, i.e. the original form with transformations applied.

Constructors

constructor(original: T, transformed: T = original.clone())<T extends TransformableObject>

  • The original form is owned by the instance.
  • If a transformed form is provided, it too is owned by the instance, otherwise the original form is cloned
  • Type is only generic on types which implement TransformableObject

Instance Methods

transform(a: Affine2): TransformState2<T>

  • Applies a to the object's original state and stores the result in the transformed state.
  • Important: While other implementations of transform compound transformations, this implementation resets the transformed state to the original state before applying a;

translate(x: number, y: number): TransformState2<T>

  • Applied the translation of x and y to the object's original state and stores the result in the transformed state.
  • Important: While other implementations of translate compound transformations, this implementation resets the transformed state to the original state before applying a;