Permalink
Browse files

Optimized use of curRectMode and curEllipseMode [#1676]

  • Loading branch information...
2 parents b64b3b3 + c7514e0 commit 87c380b6675e92486f63c700d5a4ddce5acc522e @jbuck committed Oct 4, 2011
View
@@ -13327,13 +13327,11 @@
if (curEllipseMode === PConstants.CORNERS) {
width = width - x;
height = height - y;
-
} else if (curEllipseMode === PConstants.RADIUS) {
x = x - width;
y = y - height;
width = width * 2;
height = height * 2;
-
} else if (curEllipseMode === PConstants.CENTER) {
x = x - width/2;
y = y - height/2;
@@ -13762,12 +13760,12 @@
if (curRectMode === PConstants.CORNERS) {
width -= x;
height -= y;
- }
- if (curRectMode === PConstants.RADIUS) {
+ } else if (curRectMode === PConstants.RADIUS) {
width *= 2;
height *= 2;
- }
- if (curRectMode === PConstants.CENTER || curRectMode === PConstants.RADIUS) {
+ x -= width / 2;
+ y -= height / 2;
+ } else if (curRectMode === PConstants.CENTER) {
x -= width / 2;
y -= height / 2;
}
@@ -13802,12 +13800,12 @@
if (curRectMode === PConstants.CORNERS) {
width -= x;
height -= y;
- }
- if (curRectMode === PConstants.RADIUS) {
+ } else if (curRectMode === PConstants.RADIUS) {
width *= 2;
height *= 2;
- }
- if (curRectMode === PConstants.CENTER || curRectMode === PConstants.RADIUS) {
+ x -= width / 2;
+ y -= height / 2;
+ } else if (curRectMode === PConstants.CENTER) {
x -= width / 2;
y -= height / 2;
}
@@ -13890,7 +13888,7 @@
*
* @see ellipseMode
*/
- DrawingShared.prototype.ellipse = function(x, y, width, height) {
+ Drawing2D.prototype.ellipse = function(x, y, width, height) {
x = x || 0;
y = y || 0;
@@ -13901,46 +13899,28 @@
if (curEllipseMode === PConstants.RADIUS) {
width *= 2;
height *= 2;
- }
-
- if (curEllipseMode === PConstants.CORNERS) {
+ } else if (curEllipseMode === PConstants.CORNERS) {
width = width - x;
height = height - y;
- }
-
- if (curEllipseMode === PConstants.CORNER || curEllipseMode === PConstants.CORNERS) {
+ x += width / 2;
+ y += height / 2;
+ } else if (curEllipseMode === PConstants.CORNER) {
x += width / 2;
y += height / 2;
}
- return {'x':x, 'y':y, 'width':width, 'height':height};
- };
-
- Drawing2D.prototype.ellipse = function(x, y, width, height) {
- var params = DrawingShared.prototype.ellipse.apply(this, arguments), offsetStart = 0;
-
- if (!params) {
- return;
- }
-
- x = params['x'];
- y = params['y'];
- width = params['width'];
- height = params['height'];
-
// Shortcut for drawing a 2D circle
if (width === height) {
curContext.beginPath();
- curContext.arc(x - offsetStart, y - offsetStart, width / 2, 0, PConstants.TWO_PI, false);
+ curContext.arc(x, y, width / 2, 0, PConstants.TWO_PI, false);
executeContextFill();
executeContextStroke();
- curContext.closePath();
} else {
var w = width / 2,
- h = height / 2,
- C = 0.5522847498307933;
- var c_x = C * w,
- c_y = C * h;
+ h = height / 2,
+ C = 0.5522847498307933,
+ c_x = C * w,
+ c_y = C * h;
p.beginShape();
p.vertex(x + w, y);
@@ -13953,22 +13933,31 @@
};
Drawing3D.prototype.ellipse = function(x, y, width, height) {
- var params = DrawingShared.prototype.ellipse.apply(this, arguments), offsetStart = 0;
+ x = x || 0;
+ y = y || 0;
- if (!params) {
+ if (width <= 0 && height <= 0) {
return;
}
- x = params['x'];
- y = params['y'];
- width = params['width'];
- height = params['height'];
+ if (curEllipseMode === PConstants.RADIUS) {
+ width *= 2;
+ height *= 2;
+ } else if (curEllipseMode === PConstants.CORNERS) {
+ width = width - x;
+ height = height - y;
+ x += width / 2;
+ y += height / 2;
+ } else if (curEllipseMode === PConstants.CORNER) {
+ x += width / 2;
+ y += height / 2;
+ }
var w = width / 2,
- h = height / 2,
- C = 0.5522847498307933;
- var c_x = C * w,
- c_y = C * h;
+ h = height / 2,
+ C = 0.5522847498307933,
+ c_x = C * w,
+ c_y = C * h;
p.beginShape();
p.vertex(x + w, y);
View

Large diffs are not rendered by default.

Oops, something went wrong.

Large diffs are not rendered by default.

Oops, something went wrong.

Large diffs are not rendered by default.

Oops, something went wrong.

Large diffs are not rendered by default.

Oops, something went wrong.
View

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -429,9 +429,15 @@
s.onExit = validateResult;
p = new Processing(current, s);
} catch (e) {
- title.innerHTML = titleText(i+1, tl, 0, test.name, true, "Processing failed: " + e.toString());
- result.className = "failed";
- failedCount++;
+ if (test.knownFailureTicket) {
+ title.innerHTML = titleText(i+1, tl, 0, test.name, true, "Processing failed: " + e.toString() + ". Known failure. See <a href='https://processing-js.lighthouseapp.com/projects/41284/tickets/" + test.knownFailureTicket + "'>ticket #" + test.knownFailureTicket + "</a>");
+ result.className = "knownfailure";
+ knownFailedCount++;
+ } else {
+ title.innerHTML = titleText(i+1, tl, 0, test.name, true, "Processing failed: " + e.toString());
+ result.className = "failed";
+ failedCount++;
+ }
return nextTest(i+1);
}
}
View
@@ -3,11 +3,12 @@
void setup() {
size(100, 100, OPENGL);
- background(255);
colorMode(HSB);
}
void draw() {
+ background(255);
+
// Default mode is CORNER
fill(127, 200, 75);
rect(15, 15, 20, 20);
View
@@ -39,7 +39,7 @@ var tests = [
{ path: "bouncy-bubbles.pde", tags: ["2D", "Test Suite"] },
{ path: "brownian.pde", tags: ["2D", "Test Suite"], epsilonOverride: 0.07 },
{ path: "circle-collision.pde", tags: ["2D", "Test Suite"] },
- { path: "color-wheel.pde", tags: ["2D", "Test Suite"] },
+ { path: "color-wheel.pde", tags: ["2D", "Test Suite"], knownFailureTicket: "1700" },
{ path: "composite-objects.pde", tags: ["2D", "Test Suite"] },
{ path: "conway.pde", tags: ["2D", "Test Suite"] },
{ path: "double-random.pde", tags: ["2D", "Test Suite"] },
@@ -72,7 +72,7 @@ var tests = [
{ path: "sine.pde", tags: ["2D", "Test Suite"] },
{ path: "spore1.pde", tags: ["2D", "Test Suite"] },
{ path: "translate.pde", tags: ["2D", "Test Suite"] },
- { path: "vertices.pde", tags: ["2D", "Test Suite"] },
+ { path: "vertices.pde", tags: ["2D", "Test Suite"], knownFailureTicket: "1700" },
{ path: "wolfram.pde", tags: ["2D", "Test Suite"] },
{ path: "loadShape.pde", tags: ["2D","SVG"], epsilonOverride: 0.06 },
{ path: "loadShape2.pde", tags: ["2D","SVG"], epsilonOverride: 0.08 },
@@ -203,25 +203,28 @@ var tests = [
{ path: "arc_ref3.pde", tags: ["2D", "Crisp"], epsilonOverride: 0.11 },
{ path: "bezier.pde", tags: ["2D"], epsilonOverride: 0.08 },
{ path: "ellipse.pde", tags: ["2D"] },
- { path: "ellipse-mode.pde", tags: ["2D"], epsilonOverride: 0.10 },
+ { path: "ellipseMode.pde", tags: ["2D"] },
+ { path: "ellipseMode-3d.pde", tags: ["3D"], epsilonOverride: 0.13 },
+ { path: "ellipseMode-arc.pde", tags: ["2D"], epsilonOverride: 0.18 },
+ { path: "ellipseMode-arc-3d.pde", tags: ["3D"], epsilonOverride: 0.13 },
{ path: "piechart.pde", tags: ["2D"] },
{ path: "point-stroke-array-2d.pde", tags: ["2D", "Crisp"] },
{ path: "bezier-ellipse.pde", tags: ["2D", "Crisp"], epsilonOverride: 0.06 },
{ 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: "curve-3D.pde", tags: ["3D"], epsilonOverride: 0.11, knownFailureTicket: "1700" },
{ path: "curveDetail.pde", tags: ["3D"], knownFailureTicket: "1416" },
{ path: "curvePoint.pde", tags: ["2D"], epsilonOverride: 0.11 },
{ path: "curveTangent.pde", tags: ["2D"] },
{ path: "curveTightness.pde", tags: ["2D"], epsilonOverride: 0.11 },
{ path: "continuous-curve.pde", tags: ["2D"], epsilonOverride: 0.09 },
{ path: "points-lines.pde", tags: ["2D", "Crisp"] },
{ path: "rectMode.pde", tags: ["2D", "Crisp"] },
- { path: "rectMode-3d.pde", tags: ["3D"] },
+ { path: "rectMode-3d.pde", tags: ["3D"], knownFailureTicket: "1271" },
{ path: "rect-quad.pde", tags: ["2D"] },
{ path: "size-fill-rect.pde", tags: ["2D"] },
{ path: "triangle.pde", tags: ["2D"] },
- { path: "3d-arc-4-combo.pde", tags: ["3D"], epsilonOverride: 0.13 },
+ { path: "3d-arc-4-combo.pde", tags: ["3D"], epsilonOverride: 0.13, knownFailureTicket: "1700" },
{ path: "line-3d.pde", tags: ["3D"], epsilonOverride: 0.08 },
{ path: "default_perspective.pde", tags: ["3D"], epsilonOverride: 0.11 },
{ path: "default_perspective_2.pde", tags: ["3D"], epsilonOverride: 0.11 },
@@ -253,7 +256,7 @@ var tests = [
{ path: "shininess_p5test.pde", tags: ["3D"] },
{ path: "specular_p5test.pde", tags: ["3D"]},
{ path: "spotLight_p5test.pde", tags: ["3D"], knownFailureTicket: "1239" }, /* See ticket #1202 */
- { path: "3d-ellipse-fill-noFill-stoke-noStroke.pde", tags: ["3D"], epsilonOverride: 0.15 },
+ { path: "3d-ellipse-fill-noFill-stoke-noStroke.pde", tags: ["3D"], epsilonOverride: 0.15, knownFailureTicket: "1700" },
{ path: "createGraphics.pde", tags: ["3D"], epsilonOverride: 0.07 }, /* See ticket #1075 */
{ path: "rect-directional-light.pde", tags: ["3D"] },
{ path: "hint_depth.pde", tags: ["3D"], epsilonOverride: 0.11 },

0 comments on commit 87c380b

Please sign in to comment.