Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added shearX() and shearX() to 2D mode [#1640]

Conflicts:
	processing.js
  • Loading branch information...
commit 46fc3ecb1f7037a49a61d081a695c930d96b1b18 2 parents 429315c + 1c9c64c
@jbuck authored
View
30 processing.js
@@ -5804,6 +5804,26 @@
},
/**
* @member PMatrix2D
+ * The shearX() function shears the matrix along the x-axis the amount specified by the angle parameter.
+ * Angles should be specified in radians (values from 0 to PI*2) or converted to radians with the <b>radians()</b> function.
+ *
+ * @param {float} angle angle of skew specified in radians
+ */
+ shearX: function(angle) {
+ this.apply(1, 0, 1, Math.tan(angle) , 0, 0);
+ },
+ /**
+ * @member PMatrix2D
+ * The shearY() function shears the matrix along the y-axis the amount specified by the angle parameter.
+ * Angles should be specified in radians (values from 0 to PI*2) or converted to radians with the <b>radians()</b> function.
+ *
+ * @param {float} angle angle of skew specified in radians
+ */
+ shearY: function(angle) {
+ this.apply(1, 0, 1, 0, Math.tan(angle), 0);
+ },
+ /**
+ * @member PMatrix2D
* The determinant() function calvculates the determinant of this matrix.
*
* @return {float} the determinant of the matrix
@@ -8081,6 +8101,11 @@
* @see pushMatrix
*/
+ Drawing2D.prototype.shearX = function(angleInRadians) {
+ modelView.shearX(angleInRadians);
+ curContext.transform(1,0,angleInRadians,1,0,0);
+ };
+
Drawing3D.prototype.shearX = function(angleInRadians) {
modelView.shearX(angleInRadians);
};
@@ -8109,6 +8134,11 @@
* @see shearX
*/
+ Drawing2D.prototype.shearY = function(angleInRadians) {
+ modelView.shearY(angleInRadians);
+ curContext.transform(1,angleInRadians,0,1,0,0);
+ };
+
Drawing3D.prototype.shearY = function(angleInRadians) {
modelView.shearY(angleInRadians);
};
View
11 test/ref/shearx.pde
11 additions, 0 deletions not shown
View
11 test/ref/sheary.pde
11 additions, 0 deletions not shown
View
2  test/ref/tests.js
@@ -107,6 +107,8 @@ var tests = [
{ path: "wolfram.pde", tags: ["2D", "Test Suite"] },
{ path: "pshape_ellipseMode.pde", tags: ["2D","SVG"] },
{ path: "pshape_svg.pde", tags: ["2D","SVG"] },
+ { path: "shearx.pde", tags: ["2D"] },
+ { path: "sheary.pde", tags: ["2D"] },
{ path: "loadShape.pde", tags: ["2D","SVG"], epsilonOverride: 0.06 },
{ path: "loadShape2.pde", tags: ["2D","SVG"], epsilonOverride: 0.08 },
{ path: "loadShape3.pde", tags: ["2D","SVG"], epsilonOverride: 0.07 },
View
25 test/unit/pmatrix2d.pde
@@ -57,6 +57,31 @@ _checkEqual(
], m1.array() );
//////////////////
+// SHEARX/SHEARY
+//////////////////
+
+m1.reset();
+m1.shearY(0.5);
+_checkEqual(
+[ 1.0000, 0.0000, 1.0000,
+ 0.0000, 0.5463, 0.0000
+], m1.array(), 0.00001 );
+
+m1.reset();
+
+m1.shearX(0.5);
+_checkEqual(
+[ 1.0000, 0.0000, 1.0000,
+ 0.5463, 0.0000, 0.0000
+], m1.array(), 0.00001 );
+
+m1.shearY(0.5);
+_checkEqual(
+[ 1.0000, 0.0000, 2.0000,
+ 0.5463, 0.0000, 0.5463
+], m1.array(), 0.00001 );
+
+//////////////////
// APPLY
//////////////////
Please sign in to comment.
Something went wrong with that request. Please try again.