diff --git a/android/core/src/processing/core/PGraphics.java b/android/core/src/processing/core/PGraphics.java index e7d4df3c2..26aac6613 100644 --- a/android/core/src/processing/core/PGraphics.java +++ b/android/core/src/processing/core/PGraphics.java @@ -1533,8 +1533,84 @@ public class PGraphics extends PImage implements PConstants { protected void rectImpl(float x1, float y1, float x2, float y2) { quad(x1, y1, x2, y1, x2, y2, x1, y2); } + + + public void rect(float a, float b, float c, float d, float r) { + rect(a, b, c, d, r, r, r, r); + } + public void rect(float a, float b, float c, float d, + float tl, float tr, float br, float bl) { + float hradius, vradius; + switch (rectMode) { + case CORNERS: + break; + case CORNER: + c += a; d += b; + break; + case RADIUS: + hradius = c; + vradius = d; + c = a + hradius; + d = b + vradius; + a -= hradius; + b -= vradius; + break; + case CENTER: + hradius = c / 2.0f; + vradius = d / 2.0f; + c = a + hradius; + d = b + vradius; + a -= hradius; + b -= vradius; + } + + if (a > c) { + float temp = a; a = c; c = temp; + } + + if (b > d) { + float temp = b; b = d; d = temp; + } + + rectImpl(a, b, c, d, tl, tr, br, bl); + } + + + protected void rectImpl(float x1, float y1, float x2, float y2, + float tl, float tr, float br, float bl) { + beginShape(); +// vertex(x1+tl, y1); + if (tr != 0) { + vertex(x2-tr, y1); + quadraticVertex(x2, y1, x2, y1+tr); + } else { + vertex(x2, y1); + } + if (br != 0) { + vertex(x2, y2-br); + quadraticVertex(x2, y2, x2-br, y2); + } else { + vertex(x2, y2); + } + if (bl != 0) { + vertex(x1+bl, y2); + quadraticVertex(x1, y2, x1, y2-bl); + } else { + vertex(x1, y2); + } + if (tl != 0) { + vertex(x1, y1+tl); + quadraticVertex(x1, y1, x1+tl, y1); + } else { + vertex(x1, y1); + } +// endShape(); + endShape(CLOSE); + } + + ////////////////////////////////////////////////////////////// diff --git a/core/src/processing/core/PApplet.java b/core/src/processing/core/PApplet.java index 37be2378c..04a19806d 100644 --- a/core/src/processing/core/PApplet.java +++ b/core/src/processing/core/PApplet.java @@ -7972,15 +7972,15 @@ public class PApplet extends Applet } - public void quadVertex(float cx, float cy, - float x3, float y3) { - if (recorder != null) recorder.quadrativVertex(cx, cy, x3, y3); - g.quadrativVertex(cx, cy, x3, y3); + public void quadraticVertex(float cx, float cy, + float x3, float y3) { + if (recorder != null) recorder.quadraticVertex(cx, cy, x3, y3); + g.quadraticVertex(cx, cy, x3, y3); } - public void quadVertex(float cx, float cy, float cz, - float x3, float y3, float z3) { + public void quadraticVertex(float cx, float cy, float cz, + float x3, float y3, float z3) { if (recorder != null) recorder.quadraticVertex(cx, cy, cz, x3, y3, z3); g.quadraticVertex(cx, cy, cz, x3, y3, z3); } @@ -8142,16 +8142,16 @@ public class PApplet extends Applet } - public void rect(float a, float b, float c, float d, float hr, float vr) { - if (recorder != null) recorder.rect(a, b, c, d, hr, vr); - g.rect(a, b, c, d, hr, vr); + public void rect(float a, float b, float c, float d, float r) { + if (recorder != null) recorder.rect(a, b, c, d, r); + g.rect(a, b, c, d, r); } public void rect(float a, float b, float c, float d, - float tl, float tr, float bl, float br) { - if (recorder != null) recorder.rect(a, b, c, d, tl, tr, bl, br); - g.rect(a, b, c, d, tl, tr, bl, br); + float tl, float tr, float br, float bl) { + if (recorder != null) recorder.rect(a, b, c, d, tl, tr, br, bl); + g.rect(a, b, c, d, tl, tr, br, bl); } diff --git a/core/src/processing/core/PGraphics.java b/core/src/processing/core/PGraphics.java index 81541dc21..22427d6cb 100644 --- a/core/src/processing/core/PGraphics.java +++ b/core/src/processing/core/PGraphics.java @@ -1325,7 +1325,7 @@ public class PGraphics extends PImage implements PConstants { } - public void quadrativVertex(float cx, float cy, + public void quadraticVertex(float cx, float cy, float x3, float y3) { float[] prev = vertices[vertexCount-1]; float x1 = prev[X]; @@ -1704,73 +1704,25 @@ public class PGraphics extends PImage implements PConstants { // (e.g. not all renderers use the vertices array) // Also seems to be some issues on quality here (too dense) // http://code.google.com/p/processing/issues/detail?id=265 - private void quadraticVertex(float cpx, float cpy, float x, float y) { - float[] prev = vertices[vertexCount - 1]; - float prevX = prev[X]; - float prevY = prev[Y]; - float cp1x = prevX + 2.0f/3.0f*(cpx - prevX); - float cp1y = prevY + 2.0f/3.0f*(cpy - prevY); - float cp2x = cp1x + (x - prevX)/3.0f; - float cp2y = cp1y + (y - prevY)/3.0f; - bezierVertex(cp1x, cp1y, cp2x, cp2y, x, y); - } +// private void quadraticVertex(float cpx, float cpy, float x, float y) { +// float[] prev = vertices[vertexCount - 1]; +// float prevX = prev[X]; +// float prevY = prev[Y]; +// float cp1x = prevX + 2.0f/3.0f*(cpx - prevX); +// float cp1y = prevY + 2.0f/3.0f*(cpy - prevY); +// float cp2x = cp1x + (x - prevX)/3.0f; +// float cp2y = cp1y + (y - prevY)/3.0f; +// bezierVertex(cp1x, cp1y, cp2x, cp2y, x, y); +// } - public void rect(float a, float b, float c, float d, float hr, float vr) { - float hradius, vradius; - switch (rectMode) { - case CORNERS: - break; - case CORNER: - c += a; d += b; - break; - case RADIUS: - hradius = c; - vradius = d; - c = a + hradius; - d = b + vradius; - a -= hradius; - b -= vradius; - break; - case CENTER: - hradius = c / 2.0f; - vradius = d / 2.0f; - c = a + hradius; - d = b + vradius; - a -= hradius; - b -= vradius; - } - - if (a > c) { - float temp = a; a = c; c = temp; - } - - if (b > d) { - float temp = b; b = d; d = temp; - } - - rectImpl(a, b, c, d, hr, vr); - } - - - protected void rectImpl(float x1, float y1, float x2, float y2, float hr, float vr) { - beginShape(); -// vertex(x1+hr, y1); - vertex(x2-hr, y1); - quadraticVertex(x2, y1, x2, y1+vr); - vertex(x2, y2-vr); - quadraticVertex(x2, y2, x2-hr, y2); - vertex(x1+hr, y2); - quadraticVertex(x1, y2, x1, y2-vr); - vertex(x1, y1+vr); - quadraticVertex(x1, y1, x1+hr, y1); -// endShape(); - endShape(CLOSE); + public void rect(float a, float b, float c, float d, float r) { + rect(a, b, c, d, r, r, r, r); } public void rect(float a, float b, float c, float d, - float tl, float tr, float bl, float br) { + float tl, float tr, float br, float bl) { float hradius, vradius; switch (rectMode) { case CORNERS: @@ -1803,12 +1755,12 @@ public class PGraphics extends PImage implements PConstants { float temp = b; b = d; d = temp; } - rectImpl(a, b, c, d, tl, tr, bl, br); + rectImpl(a, b, c, d, tl, tr, br, bl); } protected void rectImpl(float x1, float y1, float x2, float y2, - float tl, float tr, float bl, float br) { + float tl, float tr, float br, float bl) { beginShape(); // vertex(x1+tl, y1); if (tr != 0) { diff --git a/core/src/processing/core/PGraphicsJava2D.java b/core/src/processing/core/PGraphicsJava2D.java index 0f0aaf881..809bfeff0 100644 --- a/core/src/processing/core/PGraphicsJava2D.java +++ b/core/src/processing/core/PGraphicsJava2D.java @@ -426,7 +426,7 @@ public class PGraphicsJava2D extends PGraphics /*PGraphics2D*/ { // QUADRATIC BEZIER VERTICES - public void quadrativVertex(float ctrlX, float ctrlY, + public void quadraticVertex(float ctrlX, float ctrlY, float endX, float endY) { bezierVertexCheck(); Point2D cur = gpath.getCurrentPoint(); diff --git a/core/src/processing/core/PShape.java b/core/src/processing/core/PShape.java index db6b5aa19..929d21f87 100644 --- a/core/src/processing/core/PShape.java +++ b/core/src/processing/core/PShape.java @@ -606,7 +606,7 @@ public class PShape implements PConstants { break; case QUAD_BEZIER_VERTEX: - g.quadrativVertex(vertices[index+0][X], vertices[index+0][Y], + g.quadraticVertex(vertices[index+0][X], vertices[index+0][Y], vertices[index+1][X], vertices[index+1][Y]); // float x1 = vertices[index+0][X]; // float y1 = vertices[index+0][Y]; diff --git a/core/todo.txt b/core/todo.txt index a3fdc279a..57b8a2bde 100644 --- a/core/todo.txt +++ b/core/todo.txt @@ -56,6 +56,18 @@ X http://code.google.com/p/processing/issues/detail?id=198 X how should quadVertex() be named? bezierVertex() quadraticVertex() X decision: quadraticVertex() to avoid confusion with quads X more efficient version of copy() added for 2D +X move to new XML library +X add XHTML parsing or any others? +X html parser? javax.swing.text.html.parser... has binary DTDs +X decision: it's someone else's job +X XMLElemnt.parse() or new XMLElement(xmldata)? +X same goes for PShape.. parse from a string? +X http://code.google.com/p/processing/issues/detail?id=277 +X rounded rectangle method +X http://code.google.com/p/processing/issues/detail?id=265 +X clockwise from upper-left +X check with casey about finalizing and adding to the docs + cleanup o if too many errors come through during setup, app will terminate @@ -347,6 +359,7 @@ _ rewrite documentation about pdf fonts (errors with non-native fonts) _ figure out why font naming not working correctly _ add blendMode() to reference, remove blend() _ need documentation for quadraticVertex() +_ docs for rect(x, y, w, h, r) and rect(x, y, w, h, tl, tr, br, bl) 2.0 _ toArray(), toArray(float[]), toVectorArray(), toVectorArray(PVector[]) @@ -375,24 +388,14 @@ _ however in an XML file, that's , meaning the name of the tag _ change it to getShape(name)? also for fonts getShape(char c) _ decision: use getShape() (maybe add getShapeCount and getShape(int)) _ and remove getChild() from PShape -_ move to new XML library -_ add XHTML parsing or any others? -_ html parser? javax.swing.text.html.parser... has binary DTDs -_ decision: it's someone else's job _ load/save methods.. is it save("blah.svg") or saveSVG("blah.svg") _ also works that way with tables _ decision: useExtension() or something like that -_ XMLElemnt.parse() or new XMLElement(xmldata)? -_ same goes for PShape.. parse from a string? -_ http://code.google.com/p/processing/issues/detail?id=277 _ how should stroke work w/ arcs? _ has an effect elliptical arc _ http://code.google.com/p/processing/issues/detail?id=130 -_ decision: we should do pie, you can make the other kind w/o it -_ rounded rectangle method -_ http://code.google.com/p/processing/issues/detail?id=265 -_ clockwise from upper-left -X check with casey about finalizing and adding to the docs +o decision: we should do pie, you can make the other kind w/o it +_ add an additional parameter for the others _ require people to put things in the data folder _ make sure that loadXxxx() methods are used after init() _ nasty errors when loadImage/Font/createFont/etc used outside