MCPcopy
hub / github.com/processing/p5.js / set

Method set

src/math/Matrices/Matrix.js:241–257  ·  view source on GitHub ↗

* Replace the entire contents of a NxN matrix. * * This method allows you to replace the values of the current matrix with * those from another matrix, an array, or individual arguments. The input * can be a `Matrix` instance, an array of numbers, or individual numbers * that match th

(inMatrix)

Source from the content-addressed store, hash-verified

239 * }
240 */
241 set(inMatrix) {
242 let refArray = GLMAT_ARRAY_TYPE.from([...arguments]);
243 if (inMatrix instanceof Matrix) {
244 refArray = GLMAT_ARRAY_TYPE.from(inMatrix.matrix);
245 } else if (isMatrixArray(inMatrix)) {
246 refArray = GLMAT_ARRAY_TYPE.from(inMatrix);
247 }
248 if (refArray.length !== this.matrix.length) {
249 p5._friendlyError(
250 `Expected same dimensions values but received different ${refArray.length}.`,
251 'p5.Matrix.set'
252 );
253 return this;
254 }
255 this.matrix = refArray;
256 return this;
257 }
258
259 /**
260 * Gets a copy of the matrix, returns a p5.Matrix object.

Callers

nothing calls this directly

Calls 2

isMatrixArrayFunction · 0.70
_friendlyErrorMethod · 0.45

Tested by

no test coverage detected