mirror of
https://github.com/processing/processing4.git
synced 2026-02-13 10:30:44 +01:00
changing endShape()
This commit is contained in:
@@ -167,8 +167,8 @@ public interface PConstants {
|
||||
static final int POINTS = (1 << 4) | 0;
|
||||
|
||||
static final int LINES = (1 << 5) | 0;
|
||||
static final int LINE_STRIP = (1 << 5) | 1;
|
||||
static final int LINE_LOOP = (1 << 5) | 2;
|
||||
//static final int LINE_STRIP = (1 << 5) | 1;
|
||||
//static final int LINE_LOOP = (1 << 5) | 2;
|
||||
|
||||
static final int TRIANGLES = (1 << 6) | 0;
|
||||
static final int TRIANGLE_STRIP = (1 << 6) | 1;
|
||||
@@ -180,6 +180,9 @@ public interface PConstants {
|
||||
static final int POLYGON = (1 << 8) | 0;
|
||||
//static final int CONCAVE_POLYGON = (1 << 8) | 1;
|
||||
//static final int CONVEX_POLYGON = (1 << 8) | 2;
|
||||
|
||||
static final int OPEN = 1;
|
||||
static final int CLOSE = 2;
|
||||
|
||||
|
||||
// shape modes
|
||||
|
||||
@@ -1111,7 +1111,12 @@ public abstract class PGraphics extends PImage implements PConstants {
|
||||
}
|
||||
|
||||
|
||||
abstract public void endShape();
|
||||
public final void endShape() {
|
||||
endShape(OPEN);
|
||||
}
|
||||
|
||||
|
||||
abstract public void endShape(int mode);
|
||||
|
||||
|
||||
|
||||
@@ -1374,13 +1379,13 @@ public abstract class PGraphics extends PImage implements PConstants {
|
||||
fill = false;
|
||||
|
||||
val = 0;
|
||||
beginShape(LINE_LOOP);
|
||||
beginShape(); //LINE_LOOP);
|
||||
for (int i = 0; i < accuracy; i++) {
|
||||
vertex(centerX + cosLUT[(int) val] * hradius,
|
||||
centerY + sinLUT[(int) val] * vradius);
|
||||
val += inc;
|
||||
}
|
||||
endShape();
|
||||
endShape(CLOSE);
|
||||
|
||||
fill = savedFill;
|
||||
}
|
||||
@@ -1479,7 +1484,7 @@ public abstract class PGraphics extends PImage implements PConstants {
|
||||
int startLUT = (int) (0.5f + (start / TWO_PI) * SINCOS_LENGTH);
|
||||
int stopLUT = (int) (0.5f + (stop / TWO_PI) * SINCOS_LENGTH);
|
||||
|
||||
beginShape(LINE_STRIP);
|
||||
beginShape(); //LINE_STRIP);
|
||||
int increment = 1; // what's a good algorithm? stopLUT - startLUT;
|
||||
for (int i = startLUT; i < stopLUT; i += increment) {
|
||||
int ii = i % SINCOS_LENGTH;
|
||||
@@ -1621,7 +1626,7 @@ public abstract class PGraphics extends PImage implements PConstants {
|
||||
float x2, float y2,
|
||||
float x3, float y3,
|
||||
float x4, float y4) {
|
||||
beginShape(LINE_STRIP);
|
||||
beginShape(); //LINE_STRIP);
|
||||
vertex(x1, y1);
|
||||
bezierVertex(x2, y2, x3, y3, x4, y4);
|
||||
endShape();
|
||||
@@ -1632,7 +1637,7 @@ public abstract class PGraphics extends PImage implements PConstants {
|
||||
float x2, float y2, float z2,
|
||||
float x3, float y3, float z3,
|
||||
float x4, float y4, float z4) {
|
||||
beginShape(LINE_STRIP);
|
||||
beginShape(); //LINE_STRIP);
|
||||
vertex(x1, y1, z1);
|
||||
bezierVertex(x2, y2, z2,
|
||||
x3, y3, z3,
|
||||
@@ -1762,7 +1767,7 @@ public abstract class PGraphics extends PImage implements PConstants {
|
||||
float x2, float y2,
|
||||
float x3, float y3,
|
||||
float x4, float y4) {
|
||||
beginShape(LINE_STRIP);
|
||||
beginShape(); //LINE_STRIP);
|
||||
curveVertex(x1, y1);
|
||||
curveVertex(x2, y2);
|
||||
curveVertex(x3, y3);
|
||||
@@ -1775,7 +1780,7 @@ public abstract class PGraphics extends PImage implements PConstants {
|
||||
float x2, float y2, float z2,
|
||||
float x3, float y3, float z3,
|
||||
float x4, float y4, float z4) {
|
||||
beginShape(LINE_STRIP);
|
||||
beginShape(); //LINE_STRIP);
|
||||
curveVertex(x1, y1, z1);
|
||||
curveVertex(x2, y2, z2);
|
||||
curveVertex(x3, y3, z3);
|
||||
|
||||
@@ -220,7 +220,7 @@ public class PGraphics2D extends PGraphics {
|
||||
}
|
||||
|
||||
|
||||
public void endShape() {
|
||||
public void endShape(int mode) {
|
||||
// clear the 'shape drawing' flag in case of early exit
|
||||
//shape = 0;
|
||||
// hm can't do anymore..
|
||||
@@ -312,7 +312,8 @@ public class PGraphics2D extends PGraphics {
|
||||
if (!stroke) return;
|
||||
|
||||
// if it's a line loop, copy the vertex data to the last element
|
||||
if (shape == LINE_LOOP) {
|
||||
//if (shape == LINE_LOOP) {
|
||||
if (mode == CLOSE) {
|
||||
float v0[] = polygon.vertices[0];
|
||||
float v1[] = polygon.nextVertex();
|
||||
polyVertexCount++; // since it had already been read above
|
||||
|
||||
@@ -644,7 +644,7 @@ public class PGraphics3D extends PGraphics {
|
||||
}
|
||||
|
||||
|
||||
public void endShape() {
|
||||
public void endShape(int mode) {
|
||||
vertex_end = vertexCount;
|
||||
vertex_end_including_clip_verts = vertex_end;
|
||||
|
||||
@@ -707,8 +707,8 @@ public class PGraphics3D extends PGraphics {
|
||||
break;
|
||||
|
||||
case LINES:
|
||||
case LINE_STRIP:
|
||||
case LINE_LOOP:
|
||||
//case LINE_STRIP:
|
||||
//case LINE_LOOP:
|
||||
{
|
||||
// store index of first vertex
|
||||
int first = lineCount;
|
||||
@@ -725,7 +725,8 @@ public class PGraphics3D extends PGraphics {
|
||||
}
|
||||
|
||||
// for LINE_LOOP, close the loop with a final segment
|
||||
if (shape == LINE_LOOP) {
|
||||
//if (shape == LINE_LOOP) {
|
||||
if (mode == CLOSE) {
|
||||
add_line(stop, lines[first][VERTEX1]);
|
||||
}
|
||||
}
|
||||
@@ -838,8 +839,10 @@ public class PGraphics3D extends PGraphics {
|
||||
for (int i = vertex_start; i < stop; i++) {
|
||||
add_line(i, i+1);
|
||||
}
|
||||
// draw the last line connecting back to the first point in poly
|
||||
add_line(stop, lines[first][VERTEX1]);
|
||||
if (mode == CLOSE) {
|
||||
// draw the last line connecting back to the first point in poly
|
||||
add_line(stop, lines[first][VERTEX1]);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -219,6 +219,7 @@ public class PGraphicsJava2D extends PGraphics {
|
||||
}
|
||||
break;
|
||||
|
||||
/*
|
||||
case LINE_STRIP:
|
||||
case LINE_LOOP:
|
||||
if (gpath == null) {
|
||||
@@ -228,7 +229,8 @@ public class PGraphicsJava2D extends PGraphics {
|
||||
gpath.lineTo(x, y);
|
||||
}
|
||||
break;
|
||||
|
||||
*/
|
||||
|
||||
case TRIANGLES:
|
||||
if ((vertexCount % 3) == 0) {
|
||||
triangle(vertices[vertexCount - 3][MX],
|
||||
@@ -331,8 +333,8 @@ public class PGraphicsJava2D extends PGraphics {
|
||||
}
|
||||
|
||||
switch (shape) {
|
||||
case LINE_LOOP:
|
||||
case LINE_STRIP:
|
||||
//case LINE_LOOP:
|
||||
//case LINE_STRIP:
|
||||
case POLYGON:
|
||||
gpath.curveTo(x1, y1, x2, y2, x3, y3);
|
||||
break;
|
||||
@@ -348,9 +350,11 @@ public class PGraphicsJava2D extends PGraphics {
|
||||
float curveY[] = new float[4];
|
||||
|
||||
public void curveVertex(float x, float y) {
|
||||
if ((shape != LINE_LOOP) && (shape != LINE_STRIP) && (shape != POLYGON)) {
|
||||
//if ((shape != LINE_LOOP) && (shape != LINE_STRIP) && (shape != POLYGON)) {
|
||||
if (shape != POLYGON) {
|
||||
throw new RuntimeException("curveVertex() can only be used with " +
|
||||
"LINE_LOOP, LINE_STRIP, and POLYGON shapes");
|
||||
"POLYGON shapes");
|
||||
//"LINE_LOOP, LINE_STRIP, and POLYGON shapes");
|
||||
}
|
||||
|
||||
if (!curve_inited) curve_init();
|
||||
@@ -408,22 +412,13 @@ public class PGraphicsJava2D extends PGraphics {
|
||||
}
|
||||
|
||||
|
||||
public void endShape() {
|
||||
public void endShape(int mode) {
|
||||
if (gpath != null) { // make sure something has been drawn
|
||||
switch (shape) {
|
||||
case LINE_STRIP:
|
||||
stroke_shape(gpath);
|
||||
break;
|
||||
|
||||
case LINE_LOOP:
|
||||
gpath.closePath();
|
||||
stroke_shape(gpath);
|
||||
break;
|
||||
|
||||
case POLYGON:
|
||||
gpath.closePath();
|
||||
if (shape == POLYGON) {
|
||||
if (mode == CLOSE) {
|
||||
gpath.closePath();
|
||||
}
|
||||
draw_shape(gpath);
|
||||
break;
|
||||
}
|
||||
}
|
||||
shape = 0;
|
||||
|
||||
Reference in New Issue
Block a user