diff --git a/core/PApplet.java b/core/PApplet.java index 187c84d9d..b5f8bb9ad 100644 --- a/core/PApplet.java +++ b/core/PApplet.java @@ -4495,6 +4495,21 @@ v PApplet.this.stop(); // public functions for processing.core + public void imageMode(int mode) { + g.imageMode(mode); + } + + + public void smooth() { + g.smooth(); + } + + + public void noSmooth() { + g.noSmooth(); + } + + public void modified() { g.modified(); } @@ -4515,6 +4530,26 @@ v PApplet.this.stop(); } + public int get(int x, int y) { + return g.get(x, y); + } + + + public PImage get(int x, int y, int w, int h) { + return g.get(x, y, w, h); + } + + + public PImage get() { + return g.get(); + } + + + public void set(int x, int y, int c) { + g.set(x, y, c); + } + + public void alpha(int alpha[]) { g.alpha(alpha); } @@ -4545,21 +4580,6 @@ v PApplet.this.stop(); } - public int get(int x, int y) { - return g.get(x, y); - } - - - public PImage get(int x, int y, int w, int h) { - return g.get(x, y, w, h); - } - - - public void set(int x, int y, int c) { - g.set(x, y, c); - } - - public void copy(PImage src, int dx, int dy) { g.copy(src, dx, dy); } @@ -4571,7 +4591,8 @@ v PApplet.this.stop(); } - public void copy(PImage src, int sx1, int sy1, int sx2, int sy2, + public void copy(PImage src, + int sx1, int sy1, int sx2, int sy2, int dx1, int dy1, int dx2, int dy2) { g.copy(src, sx1, sy1, sx2, sy2, dx1, dy1, dx2, dy2); } @@ -4582,13 +4603,14 @@ v PApplet.this.stop(); } - public void blend(PImage src, int sx, int sy, int dx, int dy, int mode) { - g.blend(src, sx, sy, dx, dy, mode); + public void blend(int sx, int sy, int dx, int dy, int mode) { + g.blend(sx, sy, dx, dy, mode); } - public void blend(int sx, int sy, int dx, int dy, int mode) { - g.blend(sx, sy, dx, dy, mode); + public void blend(PImage src, + int sx, int sy, int dx, int dy, int mode) { + g.blend(src, sx, sy, dx, dy, mode); } @@ -4598,32 +4620,34 @@ v PApplet.this.stop(); } - public void blend(PImage src, int sx1, int sy1, int sx2, int sy2, + public void blend(PImage src, + int sx1, int sy1, int sx2, int sy2, int dx1, int dy1, int dx2, int dy2, int mode) { g.blend(src, sx1, sy1, sx2, sy2, dx1, dy1, dx2, dy2, mode); } - public PImage get() { - return g.get(); + static public boolean saveHeaderTIF(OutputStream output, + int width, int height) { + return PGraphics.saveHeaderTIF(output, width, height); } - static public void saveHeaderTIF(OutputStream output, - int width, int height) throws IOException { - PGraphics.saveHeaderTIF(output, width, height); + static public boolean saveTIF(OutputStream output, int pixels[], + int width, int height) { + return PGraphics.saveTIF(output, pixels, width, height); } - static public void saveTIF(OutputStream output, int pixels[], - int width, int height) throws IOException { - PGraphics.saveTIF(output, pixels, width, height); + static public boolean saveHeaderTGA(OutputStream output, + int width, int height) { + return PGraphics.saveHeaderTGA(output, width, height); } - static public void saveTGA(OutputStream output, int pixels[], - int width, int height) throws IOException { - PGraphics.saveTGA(output, pixels, width, height); + static public boolean saveTGA(OutputStream output, int pixels[], + int width, int height) { + return PGraphics.saveTGA(output, pixels, width, height); } @@ -4632,21 +4656,6 @@ v PApplet.this.stop(); } - public void smooth() { - g.smooth(); - } - - - public void noSmooth() { - g.noSmooth(); - } - - - public void imageMode(int mode) { - g.imageMode(mode); - } - - public void defaults() { g.defaults(); } @@ -4728,6 +4737,71 @@ v PApplet.this.stop(); } + public void point(float x, float y) { + g.point(x, y); + } + + + public void point(float x, float y, float z) { + g.point(x, y, z); + } + + + public void line(float x1, float y1, float x2, float y2) { + g.line(x1, y1, x2, y2); + } + + + public void line(float x1, float y1, float z1, + float x2, float y2, float z2) { + g.line(x1, y1, z1, x2, y2, z2); + } + + + public void triangle(float x1, float y1, float x2, float y2, + float x3, float y3) { + g.triangle(x1, y1, x2, y2, x3, y3); + } + + + public void rect(float x1, float y1, float x2, float y2) { + g.rect(x1, y1, x2, y2); + } + + + public void quad(float x1, float y1, float x2, float y2, + float x3, float y3, float x4, float y4) { + g.quad(x1, y1, x2, y2, x3, y3, x4, y4); + } + + + public void circle(float x, float y, float radius) { + g.circle(x, y, radius); + } + + + public void ellipseMode(int mode) { + g.ellipseMode(mode); + } + + + public void ellipse(float x, float y, float hradius, float vradius) { + g.ellipse(x, y, hradius, vradius); + } + + + public void arc(float start, float stop, + float x, float y, float radius) { + g.arc(start, stop, x, y, radius); + } + + + public void arc(float start, float stop, + float x, float y, float hr, float vr) { + g.arc(start, stop, x, y, hr, vr); + } + + public void bezier(float x1, float y1, float z1, float x2, float y2, float z2, float x3, float y3, float z3, diff --git a/core/PGraphics2.java b/core/PGraphics2.java index 4baf5a570..819f8befc 100644 --- a/core/PGraphics2.java +++ b/core/PGraphics2.java @@ -37,7 +37,7 @@ import java.awt.image.*; public class PGraphics2 extends PGraphics { Graphics2D graphics; - GeneralPath path; + GeneralPath gpath; int transformCount; AffineTransform transformStack[] = @@ -102,8 +102,7 @@ public class PGraphics2 extends PGraphics { // broken out because of subclassing for opengl protected void allocate() { image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); - - Graphics2D graphics = (Graphics2D) image.getGraphics(); + graphics = (Graphics2D) image.getGraphics(); } @@ -158,10 +157,10 @@ public class PGraphics2 extends PGraphics { case LINE_STRIP: case LINE_LOOP: if (vertexCount == 1) { - path = new GeneralPath(); - path.moveTo(x, y); + gpath = new GeneralPath(); + gpath.moveTo(x, y); } else { - path.lineTo(x, y); + gpath.lineTo(x, y); } break; @@ -181,16 +180,16 @@ public class PGraphics2 extends PGraphics { vertices[1][MX], vertices[1][MY], x, y); } else if (vertexCount > 3) { - path = new GeneralPath(); + gpath = new GeneralPath(); // when vertexCount == 4, draw an un-closed triangle // for indices 2, 3, 1 - path.moveTo(vertices[vertexCount - 2][MX], - vertices[vertexCount - 2][MY]); - path.lineTo(vertices[vertexCount - 1][MX], - vertices[vertexCount - 1][MY]); - path.lineTo(vertices[vertexCount - 3][MX], - vertices[vertexCount - 3][MY]); - draw_shape(path); + gpath.moveTo(vertices[vertexCount - 2][MX], + vertices[vertexCount - 2][MY]); + gpath.lineTo(vertices[vertexCount - 1][MX], + vertices[vertexCount - 1][MY]); + gpath.lineTo(vertices[vertexCount - 3][MX], + vertices[vertexCount - 3][MY]); + draw_shape(gpath); } break; @@ -200,15 +199,15 @@ public class PGraphics2 extends PGraphics { vertices[1][MX], vertices[1][MY], x, y); } else if (vertexCount > 3) { - path = new GeneralPath(); + gpath = new GeneralPath(); // when vertexCount > 3, draw an un-closed triangle // for indices 0 (center), previous, current - path.moveTo(vertices[0][MX], + gpath.moveTo(vertices[0][MX], vertices[0][MY]); - path.lineTo(vertices[vertexCount - 2][MX], + gpath.lineTo(vertices[vertexCount - 2][MX], vertices[vertexCount - 2][MY]); - path.lineTo(x, y); - draw_shape(path); + gpath.lineTo(x, y); + draw_shape(gpath); } break; @@ -236,17 +235,17 @@ public class PGraphics2 extends PGraphics { vertices[1][MX], vertices[1][MY]); } else if (vertexCount > 4) { - path = new GeneralPath(); + gpath = new GeneralPath(); // when vertexCount == 5, draw an un-closed triangle // for indices 2, 4, 5, 3 - path.moveTo(vertices[vertexCount - 3][MX], - vertices[vertexCount - 3][MY]); - path.lineTo(vertices[vertexCount - 1][MX], - vertices[vertexCount - 1][MY]); - path.lineTo(x, y); - path.lineTo(vertices[vertexCount - 2][MX], - vertices[vertexCount - 2][MY]); - draw_shape(path); + gpath.moveTo(vertices[vertexCount - 3][MX], + vertices[vertexCount - 3][MY]); + gpath.lineTo(vertices[vertexCount - 1][MX], + vertices[vertexCount - 1][MY]); + gpath.lineTo(x, y); + gpath.lineTo(vertices[vertexCount - 2][MX], + vertices[vertexCount - 2][MY]); + draw_shape(gpath); } break; @@ -254,10 +253,10 @@ public class PGraphics2 extends PGraphics { case CONCAVE_POLYGON: case CONVEX_POLYGON: if (vertexCount == 1) { - path = new GeneralPath(); - path.moveTo(x, y); + gpath = new GeneralPath(); + gpath.moveTo(x, y); } else { - path.lineTo(x, y); + gpath.lineTo(x, y); } break; } @@ -289,14 +288,14 @@ public class PGraphics2 extends PGraphics { case CONCAVE_POLYGON: case CONVEX_POLYGON: if (splineVertexCount == 1) { - path.moveTo(x, y); + gpath.moveTo(x, y); } else if (splineVertexCount >= 4) { - path.curveTo(splineVertices[splineVertexCount-3][MX], - splineVertices[splineVertexCount-3][MY], - splineVertices[splineVertexCount-2][MX], - splineVertices[splineVertexCount-2][MY], - x, y); + gpath.curveTo(splineVertices[splineVertexCount-3][MX], + splineVertices[splineVertexCount-3][MY], + splineVertices[splineVertexCount-2][MX], + splineVertices[splineVertexCount-2][MY], + x, y); } break; } @@ -313,19 +312,19 @@ public class PGraphics2 extends PGraphics { switch (shape) { case LINE_STRIP: - stroke_shape(path); + stroke_shape(gpath); break; case LINE_LOOP: - path.closePath(); - stroke_shape(path); + gpath.closePath(); + stroke_shape(gpath); break; case POLYGON: case CONCAVE_POLYGON: case CONVEX_POLYGON: - path.closePath(); - draw_shape(path); + gpath.closePath(); + draw_shape(gpath); break; } } @@ -380,13 +379,13 @@ public class PGraphics2 extends PGraphics { public void triangle(float x1, float y1, float x2, float y2, float x3, float y3) { - GeneralPath gp = new GeneralPath(); - gp.moveTo(x1, y1); - gp.lineTo(x2, y2); - gp.lineTo(x3, y3); - gp.closePath(); + gpath = new GeneralPath(); + gpath.moveTo(x1, y1); + gpath.lineTo(x2, y2); + gpath.lineTo(x3, y3); + gpath.closePath(); - draw_shape(gp); + draw_shape(gpath); }