# Transform

## Content

[**DsPdfJS API v9.1.3**](../README)

***

[DsPdfJS API](../globals) / Transform

# Class: Transform

Represents a 3x2 transformation matrix.

## Extends

- [`ObjectBase`](ObjectBase)

## Accessors

### id

#### Get Signature

> **get** **id**(): `number`

Gets the reference to the object.

##### Returns

`number`

#### Inherited from

[`ObjectBase`](ObjectBase).[`id`](ObjectBase#id)

***

### matrix

#### Get Signature

> **get** **matrix**(): `number`[]

Gets or sets the transformation matrix.
The matrix consists of six numbers (their meaning is simplified for clarity):
m11 - scales the drawing horizontally
m12 - skew the the drawing horizontally
m21 - skew the the drawing vertically
m22 - scales the drawing vertically
m31 - moves the the drawing horizontally
m32 - moves the the drawing vertically

##### Returns

`number`[]

#### Set Signature

> **set** **matrix**(`matrix`): `void`

Gets or sets the transformation matrix.
The matrix consists of six numbers (their meaning is simplified for clarity):
m11 - scales the drawing horizontally
m12 - skew the the drawing horizontally
m21 - skew the the drawing vertically
m22 - scales the drawing vertically
m31 - moves the the drawing horizontally
m32 - moves the the drawing vertically

##### Parameters

###### matrix

`number`[]

##### Returns

`void`

***

### om

#### Get Signature

> **get** **om**(): [`ObjectManager`](ObjectManager)

Gets the owner [ObjectManager](ObjectManager) instance.

##### Returns

[`ObjectManager`](ObjectManager)

#### Inherited from

[`ObjectBase`](ObjectBase).[`om`](ObjectBase#om)

## Methods

### createIdentity()

#### Call Signature

> `static` **createIdentity**(): `Transform`

Creates an identity transformation.

##### Returns

`Transform`

A new instance of Transform.

#### Call Signature

> `static` **createIdentity**(`om`): `Transform`

Creates an identity transformation.

##### Parameters

###### om

[`ObjectManager`](ObjectManager)

An object manager that controls the lifetime of the Transform object.

##### Returns

`Transform`

A new instance of Transform.

***

### createMatrix()

#### Call Signature

> `static` **createMatrix**(`m11`, `m12`, `m21`, `m22`, `m31`, `m32`): `Transform`

Creates a transformation based on the specified 3x2 matrix.

##### Parameters

###### m11

`number`

Scales the drawing horizontally

###### m12

`number`

Skew the the drawing horizontally

###### m21

`number`

Skew the the drawing vertically

###### m22

`number`

Scales the drawing vertically

###### m31

`number`

Moves the the drawing horizontally

###### m32

`number`

Moves the the drawing vertically

##### Returns

`Transform`

A new instance of Transform.

#### Call Signature

> `static` **createMatrix**(`om`, `m11`, `m12`, `m21`, `m22`, `m31`, `m32`): `Transform`

Creates a transformation based on the specified 3x2 matrix.

##### Parameters

###### om

[`ObjectManager`](ObjectManager)

An object manager that controls the lifetime of the Transform object.

###### m11

`number`

Scales the drawing horizontally

###### m12

`number`

Skew the the drawing horizontally

###### m21

`number`

Skew the the drawing vertically

###### m22

`number`

Scales the drawing vertically

###### m31

`number`

Moves the the drawing horizontally

###### m32

`number`

Moves the the drawing vertically

##### Returns

`Transform`

A new instance of Transform.

***

### createRotation()

#### Call Signature

> `static` **createRotation**(`angle`, `angleUnits?`, `cx?`, `cy?`): `Transform`

Creates a rotation transformation.

##### Parameters

###### angle

`number`

The rotation angle.

###### angleUnits?

[`AngleUnits`](../enumerations/AngleUnits)

The angle units. The default is Radians.

###### cx?

`number`

The optional center point X offset.

###### cy?

`number`

The optional center point Y offset.

##### Returns

`Transform`

A new instance of Transform.

#### Call Signature

> `static` **createRotation**(`om`, `angle`, `angleUnits?`, `cx?`, `cy?`): `Transform`

Creates a rotation transformation.

##### Parameters

###### om

[`ObjectManager`](ObjectManager)

An object manager that controls the lifetime of the Transform object.

###### angle

`number`

The rotation angle.

###### angleUnits?

[`AngleUnits`](../enumerations/AngleUnits)

The angle units. The default is Radians.

###### cx?

`number`

The optional center point X offset.

###### cy?

`number`

The optional center point Y offset.

##### Returns

`Transform`

A new instance of Transform.

***

### createScale()

#### Call Signature

> `static` **createScale**(`scaleFactor`, `cx?`, `cy?`): `Transform`

Creates a scaling transformation.

##### Parameters

###### scaleFactor

`number`

The value to scale by on the X and Y axes.

###### cx?

`number`

The optional center point X offset.

###### cy?

`number`

The optional center point Y offset.

##### Returns

`Transform`

A new instance of Transform.

#### Call Signature

> `static` **createScale**(`om`, `scaleFactor`, `cx?`, `cy?`): `Transform`

Creates a scaling transformation.

##### Parameters

###### om

[`ObjectManager`](ObjectManager)

An object manager that controls the lifetime of the Transform object.

###### scaleFactor

`number`

The value to scale by on the X and Y axes.

###### cx?

`number`

The optional center point X offset.

###### cy?

`number`

The optional center point Y offset.

##### Returns

`Transform`

A new instance of Transform.

***

### createScaleXY()

#### Call Signature

> `static` **createScaleXY**(`scaleX`, `scaleY`, `cx?`, `cy?`): `Transform`

Creates a scaling transformation.

##### Parameters

###### scaleX

`number`

The value to scale by on the X axis.

###### scaleY

`number`

The value to scale by on the Y axis.

###### cx?

`number`

The optional center point X offset.

###### cy?

`number`

The optional center point Y offset.

##### Returns

`Transform`

A new instance of Transform.

#### Call Signature

> `static` **createScaleXY**(`om`, `scaleX`, `scaleY`, `cx?`, `cy?`): `Transform`

Creates a scaling transformation.

##### Parameters

###### om

[`ObjectManager`](ObjectManager)

An object manager that controls the lifetime of the Transform object.

###### scaleX

`number`

The value to scale by on the X axis.

###### scaleY

`number`

The value to scale by on the Y axis.

###### cx?

`number`

The optional center point X offset.

###### cy?

`number`

The optional center point Y offset.

##### Returns

`Transform`

A new instance of Transform.

***

### createSkew()

#### Call Signature

> `static` **createSkew**(`angleX`, `angleY`, `angleUnits?`, `cx?`, `cy?`): `Transform`

Creates a skew transformation.

##### Parameters

###### angleX

`number`

The X angle.

###### angleY

`number`

The Y angle.

###### angleUnits?

[`AngleUnits`](../enumerations/AngleUnits)

The angle units. The default is Radians.

###### cx?

`number`

The optional center point X offset.

###### cy?

`number`

The optional center point Y offset.

##### Returns

`Transform`

A new instance of Transform.

#### Call Signature

> `static` **createSkew**(`om`, `angleX`, `angleY`, `angleUnits?`, `cx?`, `cy?`): `Transform`

Creates a skew transformation.

##### Parameters

###### om

[`ObjectManager`](ObjectManager)

An object manager that controls the lifetime of the Transform object.

###### angleX

`number`

The X angle.

###### angleY

`number`

The Y angle.

###### angleUnits?

[`AngleUnits`](../enumerations/AngleUnits)

The angle units. The default is Radians.

###### cx?

`number`

The optional center point X offset.

###### cy?

`number`

The optional center point Y offset.

##### Returns

`Transform`

A new instance of Transform.

***

### createTranslation()

#### Call Signature

> `static` **createTranslation**(`offsetX`, `offsetY`): `Transform`

Creates a translation transformation.

##### Parameters

###### offsetX

`number`

The horizontal offset.

###### offsetY

`number`

The vertical offset.

##### Returns

`Transform`

A new instance of Transform.

#### Call Signature

> `static` **createTranslation**(`om`, `offsetX`, `offsetY`): `Transform`

Creates a translation transformation.

##### Parameters

###### om

[`ObjectManager`](ObjectManager)

An object manager that controls the lifetime of the Transform object.

###### offsetX

`number`

The horizontal offset.

###### offsetY

`number`

The vertical offset.

##### Returns

`Transform`

A new instance of Transform.

***

### applyTransform()

> **applyTransform**(`transform`): `void`

Applies the transformation to the current instance.

#### Parameters

##### transform

`Transform`

The Transform object to be multiplied by the current transformation matrix.

#### Returns

`void`

***

### clone()

> **clone**(): `Transform`

Creates a copy of the current transformation.

#### Returns

`Transform`

A copy of the current Transform object.

***

### free()

> **free**(): `void`

Detaches the object from the [ObjectManager](ObjectManager) and deallocates its memory, if possible.

#### Returns

`void`

#### Inherited from

[`ObjectBase`](ObjectBase).[`free`](ObjectBase#free)

***

### pop()

> **pop**(): `void`

Restores the previously pushed transformation from the stack.

#### Returns

`void`

***

### push()

> **push**(): `void`

Saves the current transformation to the stack.

#### Returns

`void`

***

### rebind()

> **rebind**(`omTo`): `void`

Rebinds the object from the current [ObjectManager](ObjectManager) to the specified one.

#### Parameters

##### omTo

[`ObjectManager`](ObjectManager)

The new [ObjectManager](ObjectManager) for the object.

#### Returns

`void`

#### Inherited from

[`ObjectBase`](ObjectBase).[`rebind`](ObjectBase#rebind)

***

### reset()

> **reset**(): `void`

Resets the transformation to the identity matrix.

#### Returns

`void`

***

### rotate()

> **rotate**(`angle`, `angleUnits?`, `cx?`, `cy?`): `void`

Applies the rotation transformation.

#### Parameters

##### angle

`number`

The rotation angle.

##### angleUnits?

[`AngleUnits`](../enumerations/AngleUnits)

The angle units. The default is Radians.

##### cx?

`number`

The optional center point X offset.

##### cy?

`number`

The optional center point Y offset.

#### Returns

`void`

***

### scale()

> **scale**(`scaleFactor`, `cx?`, `cy?`): `void`

Applies the scaling transformation.

#### Parameters

##### scaleFactor

`number`

The value to scale by on the X and Y axes.

##### cx?

`number`

The optional center point X offset.

##### cy?

`number`

The optional center point Y offset.

#### Returns

`void`

***

### scaleXY()

> **scaleXY**(`scaleX`, `scaleY`, `cx?`, `cy?`): `void`

Applies the scaling transformation.

#### Parameters

##### scaleX

`number`

The value to scale by on the X axis.

##### scaleY

`number`

The value to scale by on the Y axis.

##### cx?

`number`

The optional center point X offset.

##### cy?

`number`

The optional center point Y offset.

#### Returns

`void`

***

### setTransform()

> **setTransform**(`transform`): `void`

Sets the transformation to the current instance.

#### Parameters

##### transform

`Transform`

The Transform object to replace the current transformation.

#### Returns

`void`

***

### skew()

> **skew**(`angleX`, `angleY`, `angleUnits?`, `cx?`, `cy?`): `void`

Applies the skew transformation.

#### Parameters

##### angleX

`number`

The X angle.

##### angleY

`number`

The Y angle.

##### angleUnits?

[`AngleUnits`](../enumerations/AngleUnits)

The angle units. The default is Radians.

##### cx?

`number`

The optional center point X offset.

##### cy?

`number`

The optional center point Y offset.

#### Returns

`void`

***

### skewX()

> **skewX**(`angle`, `angleUnits?`): `void`

Applies the skew transformation along the X axis.

#### Parameters

##### angle

`number`

The X angle.

##### angleUnits?

[`AngleUnits`](../enumerations/AngleUnits)

The angle units. The default is Radians.

#### Returns

`void`

***

### skewY()

> **skewY**(`angle`, `angleUnits?`): `void`

Applies the skew transformation along the Y axis.

#### Parameters

##### angle

`number`

The Y angle.

##### angleUnits?

[`AngleUnits`](../enumerations/AngleUnits)

The angle units. The default is Radians.

#### Returns

`void`

***

### transformPoint()

> **transformPoint**(`point`): [`Point`](../type-aliases/Point)

Transforms a [Point](../type-aliases/Point) by the transformation matrix.

#### Parameters

##### point

[`Point`](../type-aliases/Point)

The original [Point](../type-aliases/Point).

#### Returns

[`Point`](../type-aliases/Point)

The transformed [Point](../type-aliases/Point).

***

### transformPoints()

> **transformPoints**(`points`): [`Point`](../type-aliases/Point)[]

Transforms an array of [Point](../type-aliases/Point)s by the transformation matrix.

#### Parameters

##### points

[`Point`](../type-aliases/Point)[]

The original array of [Point](../type-aliases/Point)s.

#### Returns

[`Point`](../type-aliases/Point)[]

The array of transformed [Point](../type-aliases/Point)s.

***

### transformQuadrilateral()

> **transformQuadrilateral**(`quad`): [`Quadrilateral`](../type-aliases/Quadrilateral)

Transforms a [ds.Quadrilateral](../type-aliases/Quadrilateral) by the transformation matrix.

#### Parameters

##### quad

[`Quadrilateral`](../type-aliases/Quadrilateral)

The original [ds.Quadrilateral](../type-aliases/Quadrilateral).

#### Returns

[`Quadrilateral`](../type-aliases/Quadrilateral)

The transformed [ds.Quadrilateral](../type-aliases/Quadrilateral).

***

### translate()

> **translate**(`offsetX`, `offsetY`): `void`

Applies the translation transformation.

#### Parameters

##### offsetX

`number`

The horizontal offset.

##### offsetY

`number`

The vertical offset.

#### Returns

`void`

***

### tryInvert()

> **tryInvert**(): `boolean`

Inverts the transformation matrix, if possible.

#### Returns

`boolean`

true on success, false otherwise.
