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

Method scale

src/math/Matrices/Matrix.js:933–960  ·  view source on GitHub ↗

* Scales a p5.Matrix by scalars or a vector. * * This method applies a scaling transformation to the current matrix. * Scaling is a transformation that enlarges or shrinks objects by a scale factor * along the x, y, and z axes. The scale factors can be provided as individual * numbers

(x, y, z)

Source from the content-addressed store, hash-verified

931 * }
932 */
933 scale(x, y, z) {
934 if (x instanceof Vector) {
935 // x is a vector, extract the components from it.
936 y = x.y;
937 z = x.z;
938 x = x.x; // must be last
939 } else if (x instanceof Array) {
940 // x is an array, extract the components from it.
941 y = x[1];
942 z = x[2];
943 x = x[0]; // must be last
944 }
945
946 this.matrix[0] *= x;
947 this.matrix[1] *= x;
948 this.matrix[2] *= x;
949 this.matrix[3] *= x;
950 this.matrix[4] *= y;
951 this.matrix[5] *= y;
952 this.matrix[6] *= y;
953 this.matrix[7] *= y;
954 this.matrix[8] *= z;
955 this.matrix[9] *= z;
956 this.matrix[10] *= z;
957 this.matrix[11] *= z;
958
959 return this;
960 }
961
962 /**
963 * Rotate the Matrix around a specified axis by a given angle.

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected