# GpMatrixOrder enumeration
{: .no_toc }

Selects the order of multiplication when a new transformation is combined with an existing one.

Each transformation method takes an *order* argument that defaults to **MatrixOrderPrepend**. The order matters because matrix multiplication does not commute: translating then scaling gives a different result than scaling then translating.

| Member | Value | Description |
|:-------|:------|:------------|
| **MatrixOrderPrepend**{: #MatrixOrderPrepend } | `0` | The new transformation is applied before the existing one. The new matrix is the left operand. |
| **MatrixOrderAppend**{: #MatrixOrderAppend } | `1` | The new transformation is applied after the existing one. The new matrix is the right operand. |

## Used by

- [**Graphics**](/twinBASIC-docs/tB/Packages/Contributed/GdiPlus/Graphics.md) class: [**MultiplyTransform**](/twinBASIC-docs/tB/Packages/Contributed/GdiPlus/Graphics.md#multiplytransform), [**RotateTransform**](/twinBASIC-docs/tB/Packages/Contributed/GdiPlus/Graphics.md#rotatetransform), [**RotateTransformAt**](/twinBASIC-docs/tB/Packages/Contributed/GdiPlus/Graphics.md#rotatetransformat), [**ScaleTransform**](/twinBASIC-docs/tB/Packages/Contributed/GdiPlus/Graphics.md#scaletransform), [**ShearTransform**](/twinBASIC-docs/tB/Packages/Contributed/GdiPlus/Graphics.md#sheartransform), [**TranslateTransform**](/twinBASIC-docs/tB/Packages/Contributed/GdiPlus/Graphics.md#translatetransform)
- [**ITransformable**](/twinBASIC-docs/tB/Packages/Contributed/GdiPlus/ITransformable.md) interface: [**MultiplyTransform**](/twinBASIC-docs/tB/Packages/Contributed/GdiPlus/ITransformable.md#multiplytransform), [**RotateTransform**](/twinBASIC-docs/tB/Packages/Contributed/GdiPlus/ITransformable.md#rotatetransform), [**RotateTransformAt**](/twinBASIC-docs/tB/Packages/Contributed/GdiPlus/ITransformable.md#rotatetransformat), [**ScaleTransform**](/twinBASIC-docs/tB/Packages/Contributed/GdiPlus/ITransformable.md#scaletransform), [**ShearTransform**](/twinBASIC-docs/tB/Packages/Contributed/GdiPlus/ITransformable.md#sheartransform), [**TranslateTransform**](/twinBASIC-docs/tB/Packages/Contributed/GdiPlus/ITransformable.md#translatetransform)
- [**LinearGradientBrush**](/twinBASIC-docs/tB/Packages/Contributed/GdiPlus/LinearGradientBrush.md) class: [**MultiplyTransform**](/twinBASIC-docs/tB/Packages/Contributed/GdiPlus/LinearGradientBrush.md#multiplytransform), [**RotateTransform**](/twinBASIC-docs/tB/Packages/Contributed/GdiPlus/LinearGradientBrush.md#rotatetransform), [**RotateTransformAt**](/twinBASIC-docs/tB/Packages/Contributed/GdiPlus/LinearGradientBrush.md#rotatetransformat), [**ScaleTransform**](/twinBASIC-docs/tB/Packages/Contributed/GdiPlus/LinearGradientBrush.md#scaletransform), [**ShearTransform**](/twinBASIC-docs/tB/Packages/Contributed/GdiPlus/LinearGradientBrush.md#sheartransform), [**TranslateTransform**](/twinBASIC-docs/tB/Packages/Contributed/GdiPlus/LinearGradientBrush.md#translatetransform)
- [**Matrix**](/twinBASIC-docs/tB/Packages/Contributed/GdiPlus/Matrix.md) class: [**Multiply**](/twinBASIC-docs/tB/Packages/Contributed/GdiPlus/Matrix.md#multiply), [**Rotate**](/twinBASIC-docs/tB/Packages/Contributed/GdiPlus/Matrix.md#rotate), [**RotateAt**](/twinBASIC-docs/tB/Packages/Contributed/GdiPlus/Matrix.md#rotateat), [**Scale**](/twinBASIC-docs/tB/Packages/Contributed/GdiPlus/Matrix.md#scale), [**Shear**](/twinBASIC-docs/tB/Packages/Contributed/GdiPlus/Matrix.md#shear), [**Translate**](/twinBASIC-docs/tB/Packages/Contributed/GdiPlus/Matrix.md#translate)
- [**PathGradientBrush**](/twinBASIC-docs/tB/Packages/Contributed/GdiPlus/PathGradientBrush.md) class: [**MultiplyTransform**](/twinBASIC-docs/tB/Packages/Contributed/GdiPlus/PathGradientBrush.md#multiplytransform), [**RotateTransform**](/twinBASIC-docs/tB/Packages/Contributed/GdiPlus/PathGradientBrush.md#rotatetransform), [**RotateTransformAt**](/twinBASIC-docs/tB/Packages/Contributed/GdiPlus/PathGradientBrush.md#rotatetransformat), [**ScaleTransform**](/twinBASIC-docs/tB/Packages/Contributed/GdiPlus/PathGradientBrush.md#scaletransform), [**ShearTransform**](/twinBASIC-docs/tB/Packages/Contributed/GdiPlus/PathGradientBrush.md#sheartransform), [**TranslateTransform**](/twinBASIC-docs/tB/Packages/Contributed/GdiPlus/PathGradientBrush.md#translatetransform)
- [**Pen**](/twinBASIC-docs/tB/Packages/Contributed/GdiPlus/Pen.md) class: [**MultiplyTransform**](/twinBASIC-docs/tB/Packages/Contributed/GdiPlus/Pen.md#multiplytransform), [**RotateTransform**](/twinBASIC-docs/tB/Packages/Contributed/GdiPlus/Pen.md#rotatetransform), [**ScaleTransform**](/twinBASIC-docs/tB/Packages/Contributed/GdiPlus/Pen.md#scaletransform), [**TranslateTransform**](/twinBASIC-docs/tB/Packages/Contributed/GdiPlus/Pen.md#translatetransform)
- [**TextureBrush**](/twinBASIC-docs/tB/Packages/Contributed/GdiPlus/TextureBrush.md) class: [**MultiplyTransform**](/twinBASIC-docs/tB/Packages/Contributed/GdiPlus/TextureBrush.md#multiplytransform), [**RotateTransform**](/twinBASIC-docs/tB/Packages/Contributed/GdiPlus/TextureBrush.md#rotatetransform), [**RotateTransformAt**](/twinBASIC-docs/tB/Packages/Contributed/GdiPlus/TextureBrush.md#rotatetransformat), [**ScaleTransform**](/twinBASIC-docs/tB/Packages/Contributed/GdiPlus/TextureBrush.md#scaletransform), [**ShearTransform**](/twinBASIC-docs/tB/Packages/Contributed/GdiPlus/TextureBrush.md#sheartransform), [**TranslateTransform**](/twinBASIC-docs/tB/Packages/Contributed/GdiPlus/TextureBrush.md#translatetransform)

## Example

```tb check_build check_run
Dim user As GdiPlusUser = GdiPlusUser()

' Translate by (10, 20), then scale by (2, 3).
Dim before As Matrix = Matrix()
before.Translate 10, 20
before.Scale 2, 3, MatrixOrderPrepend
Debug.Print before.OffsetX, before.OffsetY

Dim after As Matrix = Matrix()
after.Translate 10, 20
after.Scale 2, 3, MatrixOrderAppend
Debug.Print after.OffsetX, after.OffsetY
' Output:
' 10            20
' 20            60
```

With **MatrixOrderPrepend** the scaling is applied to a point before the translation, so the translation is unchanged. With **MatrixOrderAppend** the scaling is applied after the translation, so it scales the offset too.

## See Also

- [MatrixOrder](https://learn.microsoft.com/en-us/windows/win32/api/gdiplusenums/ne-gdiplusenums-matrixorder) -- Microsoft's documentation of the GDI+ enumeration
- [Enumerations](/twinBASIC-docs/tB/Packages/Contributed/GdiPlus/Enumerations/index.md) -- all the enumerations of the package
- [Graphics](/twinBASIC-docs/tB/Packages/Contributed/GdiPlus/Graphics.md) class
- [ITransformable](/twinBASIC-docs/tB/Packages/Contributed/GdiPlus/ITransformable.md) interface
- [LinearGradientBrush](/twinBASIC-docs/tB/Packages/Contributed/GdiPlus/LinearGradientBrush.md) class
- [Matrix](/twinBASIC-docs/tB/Packages/Contributed/GdiPlus/Matrix.md) class
