Skip to content

Commit

Permalink
Merge branch 'develop' of git://github.com/jbuck/processing-js into d…
Browse files Browse the repository at this point in the history
…evelop
  • Loading branch information
asalga committed May 28, 2012
2 parents 00ec564 + 46fc3ec commit 714697f
Show file tree
Hide file tree
Showing 9 changed files with 339 additions and 19 deletions.
149 changes: 133 additions & 16 deletions processing.js
Expand Up @@ -3766,6 +3766,10 @@
this.matrix.skewX(parseFloat(m[0])); this.matrix.skewX(parseFloat(m[0]));
} else if (pieces[i].indexOf("skewY") !== -1) { } else if (pieces[i].indexOf("skewY") !== -1) {
this.matrix.skewY(m[0]); 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; return this.matrix;
Expand Down Expand Up @@ -5798,6 +5802,26 @@
skewY: function(angle) { skewY: function(angle) {
this.apply(1, 0, 1, 0, angle, 0); this.apply(1, 0, 1, 0, angle, 0);
}, },
/**
* @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 * @member PMatrix2D
* The determinant() function calvculates the determinant of this matrix. * The determinant() function calvculates the determinant of this matrix.
Expand Down Expand Up @@ -6399,6 +6423,28 @@
var t = Math.tan(angle); var t = Math.tan(angle);
this.apply(1, 0, 0, 0, t, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); 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) { multX: function(x, y, z, w) {
if (!z) { if (!z) {
return this.elements[0] * x + this.elements[1] * y + this.elements[3]; return this.elements[0] * x + this.elements[1] * y + this.elements[3];
Expand Down Expand Up @@ -8033,6 +8079,70 @@
p.rotateZ(angleInRadians); p.rotateZ(angleInRadians);
}; };


/**
* 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. * 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 * Note that these functions are always used together. They allow you to change the style settings and later
Expand Down Expand Up @@ -13333,26 +13443,31 @@
* @see #curveTightness() * @see #curveTightness()
* @see #bezier() * @see #bezier()
*/ */
Drawing2D.prototype.curve = function() { Drawing2D.prototype.curve = function(x1, y1, x2, y2, x3, y3, x4, y4) {
if (arguments.length === 8) { // curve(x1, y1, x2, y2, x3, y3, x4, y4) p.beginShape();
p.beginShape(); p.curveVertex(x1, y1);
p.curveVertex(arguments[0], arguments[1]); p.curveVertex(x2, y2);
p.curveVertex(arguments[2], arguments[3]); p.curveVertex(x3, y3);
p.curveVertex(arguments[4], arguments[5]); p.curveVertex(x4, y4);
p.curveVertex(arguments[6], arguments[7]); p.endShape();
p.endShape();
}
}; };


Drawing3D.prototype.curve = function() { Drawing3D.prototype.curve = function(x1, y1, z1, x2, y2, z2, x3, y3, z3, x4, y4, z4) {
if (arguments.length === 12) { // curve( x1, y1, z1, x2, y2, z2, x3, y3, z3, x4, y4, z4); if (z4 !== undef) {
p.beginShape(); p.beginShape();
p.curveVertex(arguments[0], arguments[1], arguments[2]); p.curveVertex(x1, y1, z1);
p.curveVertex(arguments[3], arguments[4], arguments[5]); p.curveVertex(x2, y2, z2);
p.curveVertex(arguments[6], arguments[7], arguments[8]); p.curveVertex(x3, y3, z3);
p.curveVertex(arguments[9], arguments[10], arguments[11]); p.curveVertex(x4, y4, z4);
p.endShape(); p.endShape();
return;
} }
p.beginShape();
p.curveVertex(x1, y1);
p.curveVertex(z1, x2);
p.curveVertex(y2, z2);
p.curveVertex(x3, y3);
p.endShape();
}; };


/** /**
Expand Down Expand Up @@ -17107,6 +17222,8 @@
DrawingPre.prototype.applyMatrix = createDrawingPreFunction("applyMatrix"); DrawingPre.prototype.applyMatrix = createDrawingPreFunction("applyMatrix");
DrawingPre.prototype.rotate = createDrawingPreFunction("rotate"); DrawingPre.prototype.rotate = createDrawingPreFunction("rotate");
DrawingPre.prototype.rotateZ = createDrawingPreFunction("rotateZ"); DrawingPre.prototype.rotateZ = createDrawingPreFunction("rotateZ");
DrawingPre.prototype.shearX = createDrawingPreFunction("shearX");
DrawingPre.prototype.shearY = createDrawingPreFunction("shearY");
DrawingPre.prototype.redraw = createDrawingPreFunction("redraw"); DrawingPre.prototype.redraw = createDrawingPreFunction("redraw");
DrawingPre.prototype.toImageData = createDrawingPreFunction("toImageData"); DrawingPre.prototype.toImageData = createDrawingPreFunction("toImageData");
DrawingPre.prototype.ambientLight = createDrawingPreFunction("ambientLight"); DrawingPre.prototype.ambientLight = createDrawingPreFunction("ambientLight");
Expand Down Expand Up @@ -17770,7 +17887,7 @@
"resetMatrix", "reverse", "rotate", "rotateX", "rotateY", "rotateZ", "resetMatrix", "reverse", "rotate", "rotateX", "rotateY", "rotateZ",
"round", "saturation", "save", "saveFrame", "saveStrings", "scale", "round", "saturation", "save", "saveFrame", "saveStrings", "scale",
"screenX", "screenY", "screenZ", "second", "set", "setup", "shape", "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", "sort", "specular", "sphere", "sphereDetail", "splice", "split",
"splitTokens", "spotLight", "sq", "sqrt", "status", "str", "stroke", "splitTokens", "spotLight", "sq", "sqrt", "status", "str", "stroke",
"strokeCap", "strokeJoin", "strokeWeight", "subset", "tan", "text", "strokeCap", "strokeJoin", "strokeWeight", "subset", "tan", "text",
Expand Down
4 changes: 2 additions & 2 deletions test/ref/curveDetail.pde

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions test/ref/shearx-3D.pde

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions test/ref/shearx.pde

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions test/ref/sheary-3D.pde

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions test/ref/sheary.pde

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion test/ref/tests.js
Expand Up @@ -14,6 +14,8 @@ var tests = [
{ path: "rotatepushpop.pde", tags: ["3D"] }, { path: "rotatepushpop.pde", tags: ["3D"] },
{ path: "rotatexy.pde", tags: ["3D"] }, { path: "rotatexy.pde", tags: ["3D"] },
{ path: "curRectMode.pde", tags: ["2D"] }, { path: "curRectMode.pde", tags: ["2D"] },
{ path: "shearx-3D.pde", tags: ["3D"] },
{ path: "sheary-3D.pde", tags: ["3D"] },
{ path: "hue.pde", tags: ["2D"] }, { path: "hue.pde", tags: ["2D"] },
{ path: "saturation.pde", tags: ["2D"] }, { path: "saturation.pde", tags: ["2D"] },
{ path: "brightness.pde", tags: ["2D"] }, { path: "brightness.pde", tags: ["2D"] },
Expand Down Expand Up @@ -105,6 +107,8 @@ var tests = [
{ path: "wolfram.pde", tags: ["2D", "Test Suite"] }, { path: "wolfram.pde", tags: ["2D", "Test Suite"] },
{ path: "pshape_ellipseMode.pde", tags: ["2D","SVG"] }, { path: "pshape_ellipseMode.pde", tags: ["2D","SVG"] },
{ path: "pshape_svg.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: "loadShape.pde", tags: ["2D","SVG"], epsilonOverride: 0.06 },
{ path: "loadShape2.pde", tags: ["2D","SVG"], epsilonOverride: 0.08 }, { path: "loadShape2.pde", tags: ["2D","SVG"], epsilonOverride: 0.08 },
{ path: "loadShape3.pde", tags: ["2D","SVG"], epsilonOverride: 0.07 }, { path: "loadShape3.pde", tags: ["2D","SVG"], epsilonOverride: 0.07 },
Expand Down Expand Up @@ -245,7 +249,7 @@ var tests = [
{ path: "curves.pde", tags: ["2D"], epsilonOverride: 0.07 }, { path: "curves.pde", tags: ["2D"], epsilonOverride: 0.07 },
{ path: "curve.pde", tags: ["2D"], epsilonOverride: 0.09 }, { path: "curve.pde", tags: ["2D"], epsilonOverride: 0.09 },
{ path: "curve-3D.pde", tags: ["3D"], epsilonOverride: 0.11 }, { 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: "curvePoint.pde", tags: ["2D"], epsilonOverride: 0.11 },
{ path: "curveTangent.pde", tags: ["2D"], epsilonOverride: 0.10 }, { path: "curveTangent.pde", tags: ["2D"], epsilonOverride: 0.10 },
{ path: "curveTightness.pde", tags: ["2D"], epsilonOverride: 0.11 }, { path: "curveTightness.pde", tags: ["2D"], epsilonOverride: 0.11 },
Expand Down
25 changes: 25 additions & 0 deletions test/unit/pmatrix2d.pde
Expand Up @@ -56,6 +56,31 @@ _checkEqual(
0.5000, 0.0000, 0.5000 0.5000, 0.0000, 0.5000
], m1.array() ); ], 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 // APPLY
////////////////// //////////////////
Expand Down

0 comments on commit 714697f

Please sign in to comment.