methods for getting params from shapes, also rect() with rounded corners

This commit is contained in:
benfry
2010-06-25 15:20:31 +00:00
parent 8ad2754238
commit f49fc642fb
4 changed files with 103 additions and 4 deletions

View File

@@ -7869,6 +7869,12 @@ 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);
}
/**
* The origin of the ellipse is modified by the <b>ellipseMode()</b>
* function. The default configuration is <b>ellipseMode(CENTER)</b>,

View File

@@ -1614,6 +1614,74 @@ public class PGraphics extends PImage implements PConstants {
}
// Still need to do a lot of work here to make it behave across renderers
// (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);
}
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();
}
//////////////////////////////////////////////////////////////

View File

@@ -670,7 +670,7 @@ public class PShape implements PConstants {
/**
* Same as getChild(name), except that it first walks all the way up the
* hierarchy to the farthest parent, so that children can be found anywhere.
* hierarchy to the eldest grandparent, so that children can be found anywhere.
*/
public PShape findChild(String target) {
if (parent == null) {
@@ -735,6 +735,25 @@ public class PShape implements PConstants {
return primitive;
}
public float[] getParams() {
return getParams(null);
}
public float[] getParams(float[] target) {
if (target == null || target.length != params.length) {
target = new float[params.length];
}
PApplet.arrayCopy(params, target);
return target;
}
public float getParam(int index) {
return params[index];
}
public int getVertexCount() {
return vertexCount;

View File

@@ -1,5 +1,13 @@
0186 core
X more Linux PDF fixes from Matthias Breuer
fixed in 0185
X PDF library matrix is not reset between frames
X http://dev.processing.org/bugs/show_bug.cgi?id=1227
_ change skewX/Y to shearX/Y
_ possibly add rounded rect method
_ cover the svg changes in a future release
@@ -13,10 +21,9 @@ _ http://dev.processing.org/bugs/show_bug.cgi?id=1504
_ new PGraphics(... OutputStream)
_ http://dev.processing.org/bugs/show_bug.cgi?id=1502
_ PDF library matrix is not reset between frames
_ http://dev.processing.org/bugs/show_bug.cgi?id=1227
_ transparency issue (might just be a bug in their code?)
_ http://dev.processing.org/bugs/show_bug.cgi?id=1280
_ http://code.google.com/p/processing/issues/detail?id=182
_ only top left 100 x 100 pixels are displayed in presentation mode (Linux 1.1+)
_ also was just crashing in main() for me, check on this later
@@ -24,7 +31,6 @@ _ http://dev.processing.org/bugs/show_bug.cgi?id=1560
_ need to make sure the createFont() reference is up to date for charset
_ change skewX/Y to shearX/Y
_ make determination on shape(x,y,z,w,h,d) or no
stop() mess