Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'develop' of git://github.com/jbuck/processing-js into d…

…evelop
  • Loading branch information...
commit 714697f905b0b779e6ee12fdbea47a905a732e2b 2 parents 00ec564 + 46fc3ec
@asalga authored
View
149 processing.js
@@ -3766,6 +3766,10 @@
this.matrix.skewX(parseFloat(m[0]));
} else if (pieces[i].indexOf("skewY") !== -1) {
this.matrix.skewY(m[0]);
+ } else if (pieces[i].indexOf("shearX") !== -1) {
+ this.matrix.shearX(m[0]);
+ } else if (pieces[i].indexOf("shearY") !== -1) {
+ this.matrix.shearY(m[0]);
}
}
return this.matrix;
@@ -5800,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
@@ -6399,6 +6423,28 @@
var t = Math.tan(angle);
this.apply(1, 0, 0, 0, t, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
},
+ /**
+ * @member PMatrix3D
+ * 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 shear specified in radians
+ */
+ shearX: function(angle) {
+ var t = Math.tan(angle);
+ this.apply(1, t, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
+ },
+ /**
+ * @member PMatrix3D
+ * 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 shear specified in radians
+ */
+ shearY: function(angle) {
+ var t = Math.tan(angle);
+ this.apply(1, 0, 0, 0, t, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
+ },
multX: function(x, y, z, w) {
if (!z) {
return this.elements[0] * x + this.elements[1] * y + this.elements[3];
@@ -8034,6 +8080,70 @@
};
/**
+ * Shears a shape around 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 radians() function. Objects are always sheared around their relative position
+ * to the origin and positive numbers shear objects in a clockwise direction. Transformations
+ * apply to everything that happens after and subsequent calls to the function accumulates the
+ * effect. For example, calling shearX(PI/2) and then shearX(PI/2) is the same as shearX(PI)
+ *
+ * @param {int|float} angleInRadians angle of rotation specified in radians
+ *
+ * @returns none
+ *
+ * @see rotateX
+ * @see rotateY
+ * @see rotateZ
+ * @see rotate
+ * @see translate
+ * @see scale
+ * @see popMatrix
+ * @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);
+ };
+
+ /**
+ * Shears a shape around 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 radians() function. Objects are always sheared around their
+ * relative position to the origin and positive numbers shear objects in a
+ * clockwise direction. Transformations apply to everything that happens after
+ * and subsequent calls to the function accumulates the effect. For example,
+ * calling shearY(PI/2) and then shearY(PI/2) is the same as shearY(PI).
+ *
+ * @param {int|float} angleInRadians angle of rotation specified in radians
+ *
+ * @returns none
+ *
+ * @see rotateX
+ * @see rotateY
+ * @see rotateZ
+ * @see rotate
+ * @see translate
+ * @see scale
+ * @see popMatrix
+ * @see pushMatrix
+ * @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);
+ };
+
+ /**
* The pushStyle() function saves the current style settings and popStyle() restores the prior settings.
* Note that these functions are always used together. They allow you to change the style settings and later
* return to what you had. When a new style is started with pushStyle(), it builds on the current style information.
@@ -13333,26 +13443,31 @@
* @see #curveTightness()
* @see #bezier()
*/
- Drawing2D.prototype.curve = function() {
- if (arguments.length === 8) { // curve(x1, y1, x2, y2, x3, y3, x4, y4)
- p.beginShape();
- p.curveVertex(arguments[0], arguments[1]);
- p.curveVertex(arguments[2], arguments[3]);
- p.curveVertex(arguments[4], arguments[5]);
- p.curveVertex(arguments[6], arguments[7]);
- p.endShape();
- }
+ Drawing2D.prototype.curve = function(x1, y1, x2, y2, x3, y3, x4, y4) {
+ p.beginShape();
+ p.curveVertex(x1, y1);
+ p.curveVertex(x2, y2);
+ p.curveVertex(x3, y3);
+ p.curveVertex(x4, y4);
+ p.endShape();
};
- Drawing3D.prototype.curve = function() {
- if (arguments.length === 12) { // curve( x1, y1, z1, x2, y2, z2, x3, y3, z3, x4, y4, z4);
+ Drawing3D.prototype.curve = function(x1, y1, z1, x2, y2, z2, x3, y3, z3, x4, y4, z4) {
+ if (z4 !== undef) {
p.beginShape();
- p.curveVertex(arguments[0], arguments[1], arguments[2]);
- p.curveVertex(arguments[3], arguments[4], arguments[5]);
- p.curveVertex(arguments[6], arguments[7], arguments[8]);
- p.curveVertex(arguments[9], arguments[10], arguments[11]);
+ p.curveVertex(x1, y1, z1);
+ p.curveVertex(x2, y2, z2);
+ p.curveVertex(x3, y3, z3);
+ p.curveVertex(x4, y4, z4);
p.endShape();
+ return;
}
+ p.beginShape();
+ p.curveVertex(x1, y1);
+ p.curveVertex(z1, x2);
+ p.curveVertex(y2, z2);
+ p.curveVertex(x3, y3);
+ p.endShape();
};
/**
@@ -17107,6 +17222,8 @@
DrawingPre.prototype.applyMatrix = createDrawingPreFunction("applyMatrix");
DrawingPre.prototype.rotate = createDrawingPreFunction("rotate");
DrawingPre.prototype.rotateZ = createDrawingPreFunction("rotateZ");
+ DrawingPre.prototype.shearX = createDrawingPreFunction("shearX");
+ DrawingPre.prototype.shearY = createDrawingPreFunction("shearY");
DrawingPre.prototype.redraw = createDrawingPreFunction("redraw");
DrawingPre.prototype.toImageData = createDrawingPreFunction("toImageData");
DrawingPre.prototype.ambientLight = createDrawingPreFunction("ambientLight");
@@ -17770,7 +17887,7 @@
"resetMatrix", "reverse", "rotate", "rotateX", "rotateY", "rotateZ",
"round", "saturation", "save", "saveFrame", "saveStrings", "scale",
"screenX", "screenY", "screenZ", "second", "set", "setup", "shape",
- "shapeMode", "shared", "shininess", "shorten", "sin", "size", "smooth",
+ "shapeMode", "shared", "shearX", "shearY", "shininess", "shorten", "sin", "size", "smooth",
"sort", "specular", "sphere", "sphereDetail", "splice", "split",
"splitTokens", "spotLight", "sq", "sqrt", "status", "str", "stroke",
"strokeCap", "strokeJoin", "strokeWeight", "subset", "tan", "text",
View
4 test/ref/curveDetail.pde
2 additions, 2 deletions not shown
View
10 test/ref/shearx-3D.pde
10 additions, 0 deletions not shown
View
11 test/ref/shearx.pde
11 additions, 0 deletions not shown
View
10 test/ref/sheary-3D.pde
10 additions, 0 deletions not shown
View
11 test/ref/sheary.pde
11 additions, 0 deletions not shown
View
6 test/ref/tests.js
@@ -14,6 +14,8 @@ var tests = [
{ path: "rotatepushpop.pde", tags: ["3D"] },
{ path: "rotatexy.pde", tags: ["3D"] },
{ path: "curRectMode.pde", tags: ["2D"] },
+ { path: "shearx-3D.pde", tags: ["3D"] },
+ { path: "sheary-3D.pde", tags: ["3D"] },
{ path: "hue.pde", tags: ["2D"] },
{ path: "saturation.pde", tags: ["2D"] },
{ path: "brightness.pde", tags: ["2D"] },
@@ -105,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 },
@@ -245,7 +249,7 @@ var tests = [
{ path: "curves.pde", tags: ["2D"], epsilonOverride: 0.07 },
{ path: "curve.pde", tags: ["2D"], epsilonOverride: 0.09 },
{ path: "curve-3D.pde", tags: ["3D"], epsilonOverride: 0.11 },
- { path: "curveDetail.pde", tags: ["3D"], knownFailureTicket: "1416" },
+ { path: "curveDetail.pde", tags: ["3D"] },
{ path: "curvePoint.pde", tags: ["2D"], epsilonOverride: 0.11 },
{ path: "curveTangent.pde", tags: ["2D"], epsilonOverride: 0.10 },
{ path: "curveTightness.pde", tags: ["2D"], epsilonOverride: 0.11 },
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
//////////////////
View
132 test/unit/pmatrix3d.pde
@@ -132,6 +132,138 @@ _checkEqual(
p.array(), 0.000001 );
///////////////////
+// SHEARX
+//////////////////
+
+p.reset();
+p.shearX(0.0);
+_checkEqual(
+[ 1.0000, 0.0000, 0.0000, 0.0000,
+ 0.0000, 1.0000, 0.0000, 0.0000,
+ 0.0000, 0.0000, 1.0000, 0.0000,
+ 0.0000, 0.0000, 0.0000, 1.0000
+], p.array() );
+
+p.reset();
+p.shearX( 3.14 );
+_checkEqual(
+ [1.0000, -0.0015926549364072232, 0.0000, 0.0000,
+ 0.0000, 1.0000, 0.0000, 0.0000,
+ 0.0000, 0.0000, 1.0000, 0.0000,
+ 0.0000, 0.0000, 0.0000, 1.0000],
+p.array(), 0.000001 );
+
+p.reset();
+p.shearX(-3.14);
+_checkEqual(
+[1.0000, 0.0015926549364072232, 0.0000, 0.0000,
+ 0.0000, 1.0000, 0.0000, 0.0000,
+ 0.0000, 0.0000, 1.0000, 0.0000,
+ 0.0000, 0.0000, 0.0000, 1.0000],
+p.array(), 0.000001);
+
+p.reset();
+p.set(1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4);
+p.shearX(0.0);
+_checkEqual(
+[1.0000, 2.0000, 3.0000, 4.0000,
+ 1.0000, 2.0000, 3.0000, 4.0000,
+ 1.0000, 2.0000, 3.0000, 4.0000,
+ 1.0000, 2.0000, 3.0000, 4.0000],
+p.array());
+
+p.reset();
+p.set(1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4);
+p.shearX(-1.0);
+_checkEqual(
+[1.0000, 0.44259227534509793, 3.0000, 4.0000,
+ 1.0000, 0.44259227534509793, 3.0000, 4.0000,
+ 1.0000, 0.44259227534509793, 3.0000, 4.0000,
+ 1.0000, 0.44259227534509793, 3.0000, 4.0000],
+p.array(), 0.000001);
+
+p.reset();
+p.set(1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4);
+p.shearX(-1.0);
+_checkEqual(
+[1.0000, 0.44259227534509793, 3.0000, 4.0000,
+ 1.0000, 0.44259227534509793, 3.0000, 4.0000,
+ 1.0000, 0.44259227534509793, 3.0000, 4.0000,
+ 1.0000, 0.44259227534509793, 3.0000, 4.0000],
+p.array(), 0.000001);
+
+///////////////////
+// SHEARY
+//////////////////
+
+p.reset();
+p.shearY(0.0);
+_checkEqual(
+[ 1.0000, 0.0000, 0.0000, 0.0000,
+ 0.0000, 1.0000, 0.0000, 0.0000,
+ 0.0000, 0.0000, 1.0000, 0.0000,
+ 0.0000, 0.0000, 0.0000, 1.0000
+], p.array() );
+
+p.reset();
+p.shearY( 3.14 );
+_checkEqual(
+ [1.0000, 0.0000, 0.0000, 0.0000,
+ -0.0015926549364072232, 1.0000, 0.0000, 0.0000,
+ 0.0000, 0.0000, 1.0000, 0.0000,
+ 0.0000, 0.0000, 0.0000, 1.0000],
+p.array(), 0.000001 );
+
+p.reset();
+p.shearY( -3.14 );
+_checkEqual(
+ [1.0000, 0.0000, 0.0000, 0.0000,
+ 0.0015926549364072232, 1.0000, 0.0000, 0.0000,
+ 0.0000, 0.0000, 1.0000, 0.0000,
+ 0.0000, 0.0000, 0.0000, 1.0000],
+p.array() , 0.000001);
+
+p.reset();
+p.set(1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4);
+p.shearY( 0.0 );
+_checkEqual(
+[1.0000, 2.0000, 3.0000, 4.0000,
+ 1.0000, 2.0000, 3.0000, 4.0000,
+ 1.0000, 2.0000, 3.0000, 4.0000,
+ 1.0000, 2.0000, 3.0000, 4.0000],
+p.array() );
+
+p.reset();
+p.set(1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4);
+p.shearY( -1.0 );
+_checkEqual(
+[-2.114815449309804, 2.0000, 3.0000, 4.0000,
+-2.114815449309804, 2.0000, 3.0000, 4.0000,
+-2.114815449309804, 2.0000, 3.0000, 4.0000,
+-2.114815449309804, 2.0000, 3.0000, 4.0000],
+p.array(), 0.000001 );
+
+p.reset();
+p.set(1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4);
+p.shearY( -3.14 );
+_checkEqual(
+[1.0031853098728145, 2.0000, 3.0000, 4.0000,
+ 1.0031853098728145, 2.0000, 3.0000, 4.0000,
+ 1.0031853098728145, 2.0000, 3.0000, 4.0000,
+ 1.0031853098728145, 2.0000, 3.0000, 4.0000],
+p.array(), 0.000001 );
+
+p.reset();
+p.set(1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4);
+p.shearY( 3.14 );
+_checkEqual(
+[0.9968146901271856, 2.0000, 3.0000, 4.0000,
+ 0.9968146901271856, 2.0000, 3.0000, 4.0000,
+ 0.9968146901271856, 2.0000, 3.0000, 4.0000,
+ 0.9968146901271856, 2.0000, 3.0000, 4.0000],
+p.array(), 0.000001 );
+
+///////////////////
// MULTX
//////////////////
Please sign in to comment.
Something went wrong with that request. Please try again.