Show:
Extends Array
Module: p5.play
Parent Module: p5.play

A 2D affine transformation (translation, rotation, scale) stored as a 3x3 matrix that uses homogeneous coordinates. Used to quickly transform points or vectors between reference frames.

Constructor

p5.Transform2D
(
  • source
)

Defined in lib/p5.play.js:6108

Parameters:

Methods

clear () p5.Transform2D

Defined in lib/p5.play.js:6135

Reset this transform to an identity transform, in-place.

Returns:

p5.Transform2D:

this transform

copy () p5.Transform2D

Defined in lib/p5.play.js:6150

Make a copy of this transform.

Returns:

equals
(
  • other
)
Boolean

Defined in lib/p5.play.js:6159

Check whether two transforms are the same.

Parameters:

Returns:

Boolean
getRotation () Number

Defined in lib/p5.play.js:6354

Retrieve the angle of this transform in radians.

Returns:

Number
getScale () p5.Vector

Defined in lib/p5.play.js:6310

Retrieve the scale vector of this transform.

Returns:

getTranslation () p5.Vector

Defined in lib/p5.play.js:6266

Retrieve the resolved translation of this transform.

Returns:

mult
(
  • other
)
p5.Transform2D

Defined in lib/p5.play.js:6221

Multiply this transform by another, combining them. Modifies this transform and returns it.

Parameters:

Returns:

rotate
(
  • radians
)
p5.Transform2D

Defined in lib/p5.play.js:6335

Modify this transform, rotating it by a certain amount.

Parameters:

  • radians Number

Returns:

scale () p5.Transform2D

Defined in lib/p5.play.js:6275

Modify this transform, scaling it by a certain amount. Returns this transform.

Returns:

Example:

// Three different ways to call this method.
var t = new p5.Transform();
// 1. One scalar value
t.scale(uniformScale);
// 1. Two scalar values
t.scale(scaleX, scaleY);
// 2. One vector
t.translate(new p5.Vector(scaleX, scaleY));
translate () p5.Transform2D

Defined in lib/p5.play.js:6232

Modify this transform, translating it by a certain amount. Returns this transform.

Returns:

Example:

// Two different ways to call this method.
var t = new p5.Transform();
// 1. Two numbers
t.translate(x, y);
// 2. One vector
t.translate(new p5.Vector(x, y));

Static Methods

p5.Transform2D.mult
(
  • t1
  • t2
  • dest
)
p5.Transform2D

Defined in lib/p5.play.js:6178

Multiply two transforms together, combining them. Does not modify original transforms. Assigns result into dest argument if provided and returns it. Otherwise returns a new transform.

Parameters:

Returns: