set_matrix()#

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

Examples#

example picture for set_matrix()
 1import numpy as np
 2
 3
 4def setup():
 5    py5.size(100, 100, py5.P3D)
 6    py5.no_fill()
 7    matrix = np.array([[0.866025, 0, 0.5, 0],
 8                       [0, 1, 0, 0],
 9                       [-0.5, 0, 0.866025, -86.6025],
10                       [0, 0, 0, 1]], dtype=np.float64)
11    py5.set_matrix(matrix)
12    py5.stroke(153)
13    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