Skip to content

Commit

Permalink
Merge pull request #5072 from msub2/main
Browse files Browse the repository at this point in the history
Allows applyMatrix() to take in an array as its first argument
  • Loading branch information
stalgiag authored Mar 9, 2021
2 parents a8afd77 + e913f92 commit c212eab
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions src/core/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import p5 from './main';
* alt="The transformation matrix used when applyMatrix is called"/>
*
* @method applyMatrix
* @param {Number} a numbers which define the 2x3 matrix to be multiplied
* @param {Number|Array} a numbers which define the 2x3 matrix to be multiplied, or an array of numbers
* @param {Number} b numbers which define the 2x3 matrix to be multiplied
* @param {Number} c numbers which define the 2x3 matrix to be multiplied
* @param {Number} d numbers which define the 2x3 matrix to be multiplied
Expand Down Expand Up @@ -137,14 +137,30 @@ import p5 from './main';
* </code>
* </div>
*
* <div>
* <code>
* function draw() {
* background(200);
* let testMatrix = [1, 0, 0, 1, 0, 0];
* applyMatrix(testMatrix);
* rect(0, 0, 50, 50);
* }
* </code>
* </div>
*
* @alt
* A rectangle translating to the right
* A rectangle shrinking to the center
* A rectangle rotating clockwise about the center
* A rectangle shearing
* A rectangle in the upper left corner
*/
p5.prototype.applyMatrix = function(a, b, c, d, e, f) {
this._renderer.applyMatrix(...arguments);
p5.prototype.applyMatrix = function() {
if (Array.isArray(arguments[0])) {
this._renderer.applyMatrix(...arguments[0]);
} else {
this._renderer.applyMatrix(...arguments);
}
return this;
};

Expand Down

0 comments on commit c212eab

Please sign in to comment.