* 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)
| 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. |
nothing calls this directly
no test coverage detected