set_matrix()

Set the current matrix to the one specified through the parameter source.

Examples

example picture for set_matrix()
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
import numpy as np


def setup():
    py5.size(100, 100, py5.P3D)
    py5.no_fill()
    matrix = np.array([[0.866025, 0, 0.5, 0],
                       [0, 1, 0, 0],
                       [-0.5, 0, 0.866025, -86.6025],
                       [0, 0, 0, 1]], dtype=np.float64)
    py5.set_matrix(matrix)
    py5.stroke(153)
    py5.box(50)

Description

Set the current matrix to the one specified through the parameter source. Inside the Processing code it will call reset_matrix() followed by apply_matrix(). This will be very slow because apply_matrix() will try to calculate the inverse of the transform, so avoid it whenever possible.

Underlying Processing method: setMatrix

Syntax

set_matrix(source: npt.NDArray[np.floating], /) -> None

Parameters

  • source: npt.NDArray[np.floating] - transformation matrix with a shape of 2x3 for 2D transforms or 4x4 for 3D transforms

Updated on February 26, 2022 13:22:44pm UTC