diff --git a/processing/core/PFont.java b/processing/core/PFont.java index e272e5b23..614556054 100644 --- a/processing/core/PFont.java +++ b/processing/core/PFont.java @@ -87,7 +87,7 @@ public class PFont implements PConstants { public int space; int ascii[]; // quick lookup for the ascii chars - boolean cached; + //boolean cached; // used by the text() functions to avoid over-allocation of memory private char textBuffer[] = new char[8 * 1024]; @@ -208,7 +208,7 @@ public class PFont implements PConstants { } //System.out.println(); } - cached = false; + ///cached = false; resetSize(); //resetLeading(); // ?? @@ -414,11 +414,13 @@ public class PFont implements PConstants { int glyph = index(c); if (glyph == -1) return; + /* if (!cached) { // cache on first run, to ensure a graphics context exists parent.cache(images); cached = true; } + */ if (space == OBJECT_SPACE) { float high = (float) height[glyph] / fheight; diff --git a/processing/core/PGraphics.java b/processing/core/PGraphics.java index f22f04496..a677c8d06 100644 --- a/processing/core/PGraphics.java +++ b/processing/core/PGraphics.java @@ -161,6 +161,10 @@ public class PGraphics extends PImage implements PConstants { // ........................................................ + Path path; + + // ........................................................ + /** * Type of shape passed to beginShape(), * zero if no shape is currently being drawn. @@ -484,7 +488,7 @@ public class PGraphics extends PImage implements PConstants { case LINE_STRIP: case LINE_LOOP: if (vertexCount == 1) { - path = new GeneralPath(); + path = new Path(); path.moveTo(x, y); } else { path.lineTo(x, y); @@ -507,7 +511,7 @@ public class PGraphics extends PImage implements PConstants { vertices[1][MX], vertices[1][MY], x, y); } else if (vertexCount > 3) { - path = new GeneralPath(); + path = new Path(); // when vertexCount == 4, draw an un-closed triangle // for indices 2, 3, 1 path.moveTo(vertices[vertexCount - 2][MX], @@ -526,7 +530,7 @@ public class PGraphics extends PImage implements PConstants { vertices[1][MX], vertices[1][MY], x, y); } else if (vertexCount > 3) { - path = new GeneralPath(); + path = new Path(); // when vertexCount > 3, draw an un-closed triangle // for indices 0 (center), previous, current path.moveTo(vertices[0][MX], @@ -562,7 +566,7 @@ public class PGraphics extends PImage implements PConstants { vertices[1][MX], vertices[1][MY]); } else if (vertexCount > 4) { - path = new GeneralPath(); + path = new Path(); // when vertexCount == 5, draw an un-closed triangle // for indices 2, 4, 5, 3 path.moveTo(vertices[vertexCount - 3][MX], @@ -580,7 +584,7 @@ public class PGraphics extends PImage implements PConstants { case CONCAVE_POLYGON: case CONVEX_POLYGON: if (vertexCount == 1) { - path = new GeneralPath(); + path = new Path(); path.moveTo(x, y); } else { path.lineTo(x, y); @@ -690,6 +694,38 @@ public class PGraphics extends PImage implements PConstants { + ////////////////////////////////////////////////////////////// + + // STROKE/FILL/DRAW + + + protected void fill_shape(Shape s) { + if (fill) { + //graphics.setColor(fillColorObject); + //graphics.fill(s); + } + } + + protected void stroke_shape(Shape s) { + if (stroke) { + //graphics.setColor(strokeColorObject); + //graphics.draw(s); + } + } + + protected void draw_shape(Shape s) { + if (fill) { + //graphics.setColor(fillColorObject); + //graphics.fill(s); + } + if (stroke) { + //graphics.setColor(strokeColorObject); + //graphics.draw(s); + } + } + + + ////////////////////////////////////////////////////////////// // POINT @@ -1376,7 +1412,7 @@ public class PGraphics extends PImage implements PConstants { public void image(PImage image, - float x1, float y1, float x2, float y2, + float a, float b, float c, float d, int u1, int v1, int u2, int v2) { if (imageMode == CORNER) { draw_image(image, @@ -1643,8 +1679,9 @@ public class PGraphics extends PImage implements PConstants { public void push() { if (matrixStackDepth+1 == MATRIX_STACK_DEPTH) { + throw new RuntimeException("too many calls to push()"); //message(COMPLAINT, "matrix stack overflow, to much pushmatrix"); - return; + //return; } float mat[] = matrixStack[matrixStackDepth]; mat[0] = m00; mat[1] = m01; mat[2] = m02; @@ -1655,6 +1692,8 @@ public class PGraphics extends PImage implements PConstants { public void pop() { if (matrixStackDepth == 0) { + throw new RuntimeException("too many calls to pop() " + + "(and not enough to push)"); //message(COMPLAINT, "matrix stack underflow, to many popmatrix"); return; } @@ -1778,21 +1817,27 @@ public class PGraphics extends PImage implements PConstants { public float screenX(float x, float y, float z) { + return 0; } public float screenY(float x, float y, float z) { + return 0; } public float screenZ(float x, float y, float z) { + return 0; } public float objectX(float x, float y, float z) { + return 0; } public float objectY(float x, float y, float z) { + return 0; } public float objectZ(float x, float y, float z) { + return 0; } @@ -2501,5 +2546,31 @@ public class PGraphics extends PImage implements PConstants { if (angleMode == DEGREES) angle *= DEG_TO_RAD; return (float)Math.tan(angle); } + + + + ////////////////////////////////////////////////////////////// + + // PATH + + class Path { + + public void moveTo(float x, float y) { + } + + public void lineTo(float x, float y) { + } + + public void curveTo(float x1, float y1, + float x2, float y2, + float x3, float y3) { + } + + public void closePath() { + } + } + + class Shape extends Path { + } } diff --git a/processing/core/PGraphics2.java b/processing/core/PGraphics2.java index 6eb1e9bf5..87370afe5 100644 --- a/processing/core/PGraphics2.java +++ b/processing/core/PGraphics2.java @@ -134,7 +134,7 @@ public class PGraphics2 extends PGraphics { float temp[][] = new float[vertexCount<<1][VERTEX_FIELD_COUNT]; System.arraycopy(vertices, 0, temp, 0, vertexCount); vertices = temp; - message(CHATTER, "allocating more vertices " + vertices.length); + //message(CHATTER, "allocating more vertices " + vertices.length); } // not everyone needs this, but just easier to store rather // than adding another moving part to the code... @@ -430,17 +430,17 @@ public class PGraphics2 extends PGraphics { public void arc(float start, float stop, float x, float y, float w, float h) { - if (arcMode == CORNERS) { + if (ellipseMode == CORNERS) { w -= x; h -= y; - } else if (arcMode == CENTER_RADIUS) { + } else if (ellipseMode == CENTER_RADIUS) { x -= w; y -= h; w *= 2; h *= 2; - } else if (arcMode == CENTER) { + } else if (ellipseMode == CENTER) { x -= w; y -= h; } @@ -456,9 +456,9 @@ public class PGraphics2 extends PGraphics { } - public void circle(float x, float y, float radius) { - ellipse(x, y, radius, radius); - } + //public void circle(float x, float y, float radius) { + //ellipse(x, y, radius, radius); + //} public void bezier(float x1, float y1, diff --git a/processing/core/PGraphics3.java b/processing/core/PGraphics3.java index 29f3b03fa..8552c27b0 100644 --- a/processing/core/PGraphics3.java +++ b/processing/core/PGraphics3.java @@ -379,7 +379,7 @@ public class PGraphics3 extends PGraphics { float temp[][] = new float[vertexCount<<1][VERTEX_FIELD_COUNT]; System.arraycopy(vertices, 0, temp, 0, vertexCount); vertices = temp; - message(CHATTER, "allocating more vertices " + vertices.length); + //message(CHATTER, "allocating more vertices " + vertices.length); } float vertex[] = vertices[vertexCount++]; @@ -433,9 +433,11 @@ public class PGraphics3 extends PGraphics { */ protected void texture_vertex(float u, float v) { if (textureImage == null) { - message(PROBLEM, "gotta use texture() " + - "after beginShape() and before vertex()"); - return; + throw new RuntimeException("need to set an image with texture() " + + "before using u and v coordinates"); + //message(PROBLEM, "gotta use texture() " + + // "after beginShape() and before vertex()"); + //return; } if (textureMode == IMAGE_SPACE) { u /= (float) textureImage.width; @@ -608,7 +610,7 @@ public class PGraphics3 extends PGraphics { PImage temp[] = new PImage[texture_index<<1]; System.arraycopy(textures, 0, temp, 0, texture_index); textures = temp; - message(CHATTER, "allocating more textures " + textures.length); + //message(CHATTER, "allocating more textures " + textures.length); } if (textures[0] != null) { // wHY? @@ -878,7 +880,7 @@ public class PGraphics3 extends PGraphics { int temp[][] = new int[lineCount<<1][LINE_FIELD_COUNT]; System.arraycopy(lines, 0, temp, 0, lineCount); lines = temp; - message(CHATTER, "allocating more lines " + lines.length); + //message(CHATTER, "allocating more lines " + lines.length); } lines[lineCount][VERTEX1] = a; lines[lineCount][VERTEX2] = b; @@ -898,7 +900,7 @@ public class PGraphics3 extends PGraphics { int temp[][] = new int[triangleCount<<1][TRIANGLE_FIELD_COUNT]; System.arraycopy(triangles, 0, temp, 0, triangleCount); triangles = temp; - message(CHATTER, "allocating more triangles " + triangles.length); + //message(CHATTER, "allocating more triangles " + triangles.length); } triangles[triangleCount][VERTEX1] = a; triangles[triangleCount][VERTEX2] = b; @@ -1801,8 +1803,9 @@ public class PGraphics3 extends PGraphics { public void push() { if (matrixStackDepth+1 == MATRIX_STACK_DEPTH) { - message(COMPLAINT, "matrix stack overflow, to much pushmatrix"); - return; + throw new RuntimeException("too many calls to push()"); + //message(COMPLAINT, "matrix stack overflow, to much pushmatrix"); + //return; } float mat[] = matrixStack[matrixStackDepth]; mat[ 0] = m00; mat[ 1] = m01; mat[ 2] = m02; mat[ 3] = m03; @@ -1815,8 +1818,10 @@ public class PGraphics3 extends PGraphics { public void pop() { if (matrixStackDepth == 0) { - message(COMPLAINT, "matrix stack underflow, to many popmatrix"); - return; + throw new RuntimeException("too many calls to pop() " + + "(and not enough to push)"); + //message(COMPLAINT, "matrix stack underflow, to many popmatrix"); + //return; } matrixStackDepth--; float mat[] = matrixStack[matrixStackDepth]; diff --git a/processing/core/PImage.java b/processing/core/PImage.java index 249bfb5bd..b6d4caf3e 100644 --- a/processing/core/PImage.java +++ b/processing/core/PImage.java @@ -1169,11 +1169,12 @@ public class PImage implements PConstants, Cloneable { index -= width; } output.flush(); + return true; } catch (IOException e) { e.printStackTrace(); - return false; } + return false; } diff --git a/processing/core/todo.txt b/processing/core/todo.txt index 66d935940..31a5fcb52 100644 --- a/processing/core/todo.txt +++ b/processing/core/todo.txt @@ -30,6 +30,11 @@ o or is just a message to save the next frame (problem for anim) X vertices max out at 512.. make it grow X add gzipInput and gzipOutput +api changes +X removed circle.. it's dumb when ellipse() is in there +X (it's not like we have square() in the api) +X arcMode is gone.. just uses ellipseMode() + _ beginShape() _ don't allow you to draw stroked items unless stroke() is called _ don't allow beginShape() if shape is already set