<commit_before>/**
 * @module Transform
 * @submodule Transform
 * @for p5
 * @requires core
 * @requires constants
 */

import p5 from './main';

/**
 * Multiplies the current matrix by the one specified through the parameters.
 * This is a powerful operation that can perform the equivalent of translate,
 * scale, shear and rotate all at once. You can learn more about transformation
 * matrices on <a href="https://en.wikipedia.org/wiki/Transformation_matrix">
 * Wikipedia</a>.
 *
 * The naming of the arguments here follows the naming of the <a href=
 * "https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-transform">
 * WHATWG specification</a> and corresponds to a
 * transformation matrix of the
 * form:
 *
 * > <img style="max-width: 150px" src="assets/transformation-matrix.png"
 * alt="The transformation matrix used when applyMatrix is called"/>
 *
 * @method applyMatrix
 * @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
 * @param  {Number} e numbers which define the 2x3 matrix to be multiplied
 * @param  {Number} f numbers which define the 2x3 matrix to be multiplied
 * @chainable
 * @example
 * <div>
 * <code>
 * function setup() {
 *   frameRate(10);
 *   rectMode(CENTER);
 * }
 *
 * function draw() {
 *   let step = frameCount % 20;
 *   background(200);
 *   // Equivalent to translate(x, y);
 *   applyMatrix(1, 0, 0, 1, 40 + step, 50);
 *   rect(0, 0, 50, 50);
 * }
 * </code>
 * </div>
 *
 * <div>
 * <code>
 * function setup() {
 *   frameRate(10);
 *   rectMode(CENTER);
 * }
 *
 * function draw() {
 *   let step = frameCount % 20;
 *   background(200);
 *   translate(50, 50);
 *   // Equivalent to scale(x, y);
 *   applyMatrix(1 / step, 0, 0, 1 / step, 0, 0);
 *   rect(0, 0, 50, 50);
 * }
 * </code>
 * </div>
 *
 * <div>
 * <code>
 * function setup() {
 *   frameRate(10);
 *   rectMode(CENTER);
 * }
 *
 * function draw() {
 *   let step = frameCount % 20;
 *   let angle = map(step, 0, 20, 0, TWO_PI);
 *   let cos_a = cos(angle);
 *   let sin_a = sin(angle);
 *   background(200);
 *   translate(50, 50);
 *   // Equivalent to rotate(angle);
 *   applyMatrix(cos_a, sin_a, -sin_a, cos_a, 0, 0);
 *   rect(0, 0, 50, 50);
 * }
 * </code>
 * </div>
 *
 * <div>
 * <code>
 * function setup() {
 *   frameRate(10);
 *   rectMode(CENTER);
 * }
 *
 * function draw() {
 *   let step = frameCount % 20;
 *   let angle = map(step, 0, 20, -PI / 4, PI / 4);
 *   background(200);
 *   translate(50, 50);
 *   // equivalent to shearX(angle);
 *   let shear_factor = 1 / tan(PI / 2 - angle);
 *   applyMatrix(1, 0, shear_factor, 1, 0, 0);
 *   rect(0, 0, 50, 50);
 * }
 * </code>
 * </div>
 *
 * <div modernizr='webgl'>
 * <code>
 * function setup() {
 *   createCanvas(100, 100, WEBGL);
 *   noFill();
 * }
 *
 * function draw() {
 *   background(200);
 *   rotateY(PI / 6);
 *   stroke(153);
 *   box(35);
 *   let rad = millis() / 1000;
 *   // Set rotation angles
 *   let ct = cos(rad);
 *   let st = sin(rad);
 *   // Matrix for rotation around the Y axis
 *   // prettier-ignore
 *   applyMatrix(  ct, 0.0,  st,  0.0,
 *                0.0, 1.0, 0.0,  0.0,
 *                -st, 0.0,  ct,  0.0,
 *                0.0, 0.0, 0.0,  1.0);
 *   stroke(255);
 *   box(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
 */
p5.prototype.applyMatrix = function(a, b, c, d, e, f) {
  if (Array.isArray(arguments[0])) {
    this._renderer.applyMatrix(...arguments[0]);
  } else {
    this._renderer.applyMatrix(...arguments);
  }
  return this;
};

/**
 * Replaces the current matrix with the identity matrix.
 *
 * @method resetMatrix
 * @chainable
 * @example<commit_msg>Remove unused parameters, updated inline examples<commit_after>/**
 * @module Transform
 * @submodule Transform
 * @for p5
 * @requires core
 * @requires constants
 */

import p5 from './main';

/**
 * Multiplies the current matrix by the one specified through the parameters.
 * This is a powerful operation that can perform the equivalent of translate,
 * scale, shear and rotate all at once. You can learn more about transformation
 * matrices on <a href="https://en.wikipedia.org/wiki/Transformation_matrix">
 * Wikipedia</a>.
 *
 * The naming of the arguments here follows the naming of the <a href=
 * "https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-transform">
 * WHATWG specification</a> and corresponds to a
 * transformation matrix of the
 * form:
 *
 * > <img style="max-width: 150px" src="assets/transformation-matrix.png"
 * alt="The transformation matrix used when applyMatrix is called"/>
 *
 * @method applyMatrix
 * @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
 * @param  {Number} e numbers which define the 2x3 matrix to be multiplied
 * @param  {Number} f numbers which define the 2x3 matrix to be multiplied
 * @chainable
 * @example
 * <div>
 * <code>
 * function setup() {
 *   frameRate(10);
 *   rectMode(CENTER);
 * }
 *
 * function draw() {
 *   let step = frameCount % 20;
 *   background(200);
 *   // Equivalent to translate(x, y);
 *   applyMatrix(1, 0, 0, 1, 40 + step, 50);
 *   rect(0, 0, 50, 50);
 * }
 * </code>
 * </div>
 *
 * <div>
 * <code>
 * function setup() {
 *   frameRate(10);
 *   rectMode(CENTER);
 * }
 *
 * function draw() {
 *   let step = frameCount % 20;
 *   background(200);
 *   translate(50, 50);
 *   // Equivalent to scale(x, y);
 *   applyMatrix(1 / step, 0, 0, 1 / step, 0, 0);
 *   rect(0, 0, 50, 50);
 * }
 * </code>
 * </div>
 *
 * <div>
 * <code>
 * function setup() {
 *   frameRate(10);
 *   rectMode(CENTER);
 * }
 *
 * function draw() {
 *   let step = frameCount % 20;
 *   let angle = map(step, 0, 20, 0, TWO_PI);
 *   let cos_a = cos(angle);
 *   let sin_a = sin(angle);
 *   background(200);
 *   translate(50, 50);
 *   // Equivalent to rotate(angle);
 *   applyMatrix(cos_a, sin_a, -sin_a, cos_a, 0, 0);
 *   rect(0, 0, 50, 50);
 * }
 * </code>
 * </div>
 *
 * <div>
 * <code>
 * function setup() {
 *   frameRate(10);
 *   rectMode(CENTER);
 * }
 *
 * function draw() {
 *   let step = frameCount % 20;
 *   let angle = map(step, 0, 20, -PI / 4, PI / 4);
 *   background(200);
 *   translate(50, 50);
 *   // equivalent to shearX(angle);
 *   let shear_factor = 1 / tan(PI / 2 - angle);
 *   applyMatrix(1, 0, shear_factor, 1, 0, 0);
 *   rect(0, 0, 50, 50);
 * }
 * </code>
 * </div>
 *
 * <div modernizr='webgl'>
 * <code>
 * function setup() {
 *   createCanvas(100, 100, WEBGL);
 *   noFill();
 * }
 *
 * function draw() {
 *   background(200);
 *   rotateY(PI / 6);
 *   stroke(153);
 *   box(35);
 *   let rad = millis() / 1000;
 *   // Set rotation angles
 *   let ct = cos(rad);
 *   let st = sin(rad);
 *   // Matrix for rotation around the Y axis
 *   // prettier-ignore
 *   applyMatrix(  ct, 0.0,  st,  0.0,
 *                0.0, 1.0, 0.0,  0.0,
 *                -st, 0.0,  ct,  0.0,
 *                0.0, 0.0, 0.0,  1.0);
 *   stroke(255);
 *   box(50);
 * }
 * </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() {
  if (Array.isArray(arguments[0])) {
    this._renderer.applyMatrix(...arguments[0]);
  } else {
    this._renderer.applyMatrix(...arguments);
  }
  return this;
};

/**
 * Replaces the current matrix with the identity matrix.
 *
 * @method resetMatrix
 * @chainable
 * @example
{'fraction_non_alphanumeric': 0.1606198942815954, 'fraction_numerical': 0.041446419990389234, 'mean_word_length': 2.8100686498855834, 'pattern_counts': {'":': 0, '<': 57, '<?xml version=': 0, '>': 59, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5663893', 'n_tokens_mistral': 3164, 'n_tokens_neox': 2877, 'n_words': 890}