diff --git a/core/PApplet.java b/core/PApplet.java index d3d7c9939..bfe56982c 100644 --- a/core/PApplet.java +++ b/core/PApplet.java @@ -4794,30 +4794,19 @@ v PApplet.this.stop(); } - 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 ellipse(float a, float b, float c, float d) { + g.ellipse(a, b, c, d); } 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); + float a, float b, float c, float d) { + g.arc(start, stop, a, b, c, d); } diff --git a/core/PGraphics.java b/core/PGraphics.java index 4ac0fc241..09dc2b71c 100644 --- a/core/PGraphics.java +++ b/core/PGraphics.java @@ -828,36 +828,7 @@ public class PGraphics extends PImage implements PConstants { ////////////////////////////////////////////////////////////// - // CIRCLES AND ELLIPSES - - - public void circle(float x, float y, float radius) { - switch (ellipseMode) { - case CENTER_RADIUS: - break; - case CENTER: - radius /= 2f; radius /= 2f; - break; - case CORNER: - radius /= 2f; radius /= 2f; - x += radius; y += radius; - break; - case CORNERS: - radius = (radius - x) / 2f; - radius = (radius - y) / 2f; - x += radius; - y += radius; - break; - } - - // TODO make a circle happen - } - - - - ////////////////////////////////////////////////////////////// - - // ELLIPSE + // ELLIPSE AND ARC public void ellipseMode(int mode) { @@ -865,72 +836,58 @@ public class PGraphics extends PImage implements PConstants { } - public void ellipse(float x, float y, float hradius, float vradius) { - switch (ellipseMode) { - case CENTER_RADIUS: - break; - case CENTER: - hradius /= 2f; vradius /= 2f; - break; - case CORNER: - hradius /= 2f; vradius /= 2f; - x += hradius; y += vradius; - break; - case CORNERS: - hradius = (hradius - x) / 2f; - vradius = (vradius - y) / 2f; - x += hradius; - y += vradius; - break; + public void ellipse(float a, float b, float c, float d) { + float x = a; + float y = b; + float w = c; + float h = d; + + if (ellipseMode == CORNERS) { + w = c - a; + h = d - b; + + } else if (ellipseMode == CENTER_RADIUS) { + x = a - c; + y = b - d; + w = c * 2; + h = d * 2; + + } else if (ellipseMode == CENTER) { + x = a - c/2f; + y = b - d/2f; } // TODO draw an ellipse } - - ////////////////////////////////////////////////////////////// - - // ARC - - - //public void arcMode(int mode) { - //arcMode = mode; - //} - - /** * Identical parameters and placement to ellipse, * but draws only an arc of that ellipse. + * + * angleMode() sets DEGREES or RADIANS for the start & stop + * ellipseMode() sets the placement. */ public void arc(float start, float stop, - float x, float y, float radius) { - arc(start, stop, x, y, radius, radius); - } + float a, float b, float c, float d) { + float x = a; + float y = b; + float w = c; + float h = d; + if (ellipseMode == CORNERS) { + w = c - a; + h = d - b; - /** - * Identical parameters and placement to ellipse, - * but draws only an arc of that ellipse. - */ - public void arc(float start, float stop, - float x, float y, float hr, float vr) { - switch (ellipseMode) { - case CENTER_RADIUS: - break; - case CENTER: - hr /= 2f; vr /= 2f; - break; - case CORNER: - hr /= 2f; vr /= 2f; - x += hr; y += vr; - break; - case CORNERS: - hr = (hr - x) / 2f; - vr = (vr - y) / 2f; - x += hr; - y += vr; - break; + } else if (ellipseMode == CENTER_RADIUS) { + x = a - c; + y = b - d; + w = c * 2; + h = d * 2; + + } else if (ellipseMode == CENTER) { + x = a - c/2f; + y = b - d/2f; } if (angleMode == DEGREES) { @@ -2254,6 +2211,12 @@ public class PGraphics extends PImage implements PConstants { ////////////////////////////////////////////////////////////// + /** + * Note that background() must be called before any + * transformations occur, because some implementations may + * require the current transformation matrix to be identity + * before drawing. + */ public void background(int rgb) { if (((rgb & 0xff000000) == 0) && (rgb <= colorModeX)) { // see above background((float) rgb); diff --git a/core/PGraphics2.java b/core/PGraphics2.java index 819f8befc..166e5d54e 100644 --- a/core/PGraphics2.java +++ b/core/PGraphics2.java @@ -421,27 +421,59 @@ public class PGraphics2 extends PGraphics { } + public void ellipse(float a, float b, float c, float d) { + float x = a; + float y = b; + float w = c; + float h = d; + + if (ellipseMode == CORNERS) { + w = c - a; + h = d - b; + + } else if (ellipseMode == CENTER_RADIUS) { + x = a - c; + y = b - d; + w = c * 2; + h = d * 2; + + } else if (ellipseMode == CENTER) { + x = a - c/2f; + y = b - d/2f; + } + + ellipse.setFrame(x, y, w, h); + draw_shape(ellipse); + } + + /* public void arc(float start, float stop, float x, float y, float radius) { arc(start, stop, x, y, radius, radius); } + */ public void arc(float start, float stop, - float x, float y, float w, float h) { + float a, float b, float c, float d) { + float x = a; + float y = b; + float w = c; + float h = d; + if (ellipseMode == CORNERS) { - w -= x; - h -= y; + w = c - a; + h = d - b; } else if (ellipseMode == CENTER_RADIUS) { - x -= w; - y -= h; - w *= 2; - h *= 2; + x = a - c; + y = b - d; + w = c * 2; + h = d * 2; } else if (ellipseMode == CENTER) { - x -= w; - y -= h; + x = a - c/2f; + y = b - d/2f; } arc.setArc(x, y, w, h, start, stop-start, Arc2D.PIE); @@ -449,12 +481,6 @@ public class PGraphics2 extends PGraphics { } - public void ellipse(float x, float y, float hradius, float vradius) { - ellipse.setFrame(x, y, hradius, vradius); - draw_shape(ellipse); - } - - //public void circle(float x, float y, float radius) { //ellipse(x, y, radius, radius); //} @@ -533,8 +559,8 @@ public class PGraphics2 extends PGraphics { protected void check_image_cache(PImage who) { if (who.cache == null) { - cache = new BufferedImage(who.width, who.height, - BufferedImage.TYPE_INT_ARGB); + who.cache = new BufferedImage(who.width, who.height, + BufferedImage.TYPE_INT_ARGB); who.modified(); // mark the whole thing for update } @@ -647,9 +673,6 @@ public class PGraphics2 extends PGraphics { public void printMatrix() { - // TODO maybe format this the same way as the superclass - //AffineTransform t = graphics.getTransform(); - //System.out.println(t); // not sure what this does graphics.getTransform().getMatrix(transform); m00 = (float) transform[0]; diff --git a/core/PImage.java b/core/PImage.java index b6d4caf3e..ee5c3aba9 100644 --- a/core/PImage.java +++ b/core/PImage.java @@ -219,8 +219,8 @@ public class PImage implements PConstants, Cloneable { public void modified() { mx1 = 0; my1 = 0; - mx2 = width; - my2 = height; + mx2 = width - 1; + my2 = height - 1; modified = true; } diff --git a/core/PMethods.java b/core/PMethods.java index b0d6b88ca..9e01bbec1 100755 --- a/core/PMethods.java +++ b/core/PMethods.java @@ -155,8 +155,8 @@ public interface PMethods { //public void arcMode(int mode); - public void arc(float start, float stop, - float x, float y, float radius); + //public void arc(float start, float stop, + // float x, float y, float radius); public void arc(float start, float stop, float x, float y, float hr, float vr); diff --git a/core/make.sh b/core/make.sh new file mode 100755 index 000000000..bf9b6912e --- /dev/null +++ b/core/make.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +jikes -d . +D *.java +#jikes -d . +D PApplet.java