MCPcopy Index your code
hub / github.com/processing/p5.js / constructor

Method constructor

src/math/Matrices/Matrix.js:27–40  ·  view source on GitHub ↗
(...args)

Source from the content-addressed store, hash-verified

25 #sqDimention;
26
27 constructor(...args) {
28 super(...args);
29 // This is default behavior when object
30 // instantiated using createMatrix()
31 if (isMatrixArray(args[0]) && isPerfectSquare(args[0])) {
32 const sqDimention = Math.sqrt(args[0].length);
33 this.#sqDimention = sqDimention;
34 this.matrix = GLMAT_ARRAY_TYPE.from(args[0]);
35 } else if (typeof args[0] === 'number') {
36 this.#sqDimention = Number(args[0]);
37 this.matrix = this.#createIdentityMatrix(args[0]);
38 }
39 return this;
40 }
41
42 /**
43 * Returns the 3x3 matrix if the dimensions are 3x3, otherwise returns `undefined`.

Callers

nothing calls this directly

Calls 3

#createIdentityMatrixMethod · 0.95
isPerfectSquareFunction · 0.85
isMatrixArrayFunction · 0.70

Tested by

no test coverage detected