set_matrix()

set_matrix()#

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

Examples#

example picture for set_matrix()

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

Signatures#

set_matrix(
    source: npt.NDArray[np.floating],  # transformation matrix with a shape of 2x3 for 2D transforms or 4x4 for 3D transforms
    /,
) -> None

Updated on March 06, 2023 02:49:26am UTC