diff --git a/app/tools/Archiver.java b/app/tools/Archiver.java index ab6d4dee2..0d6ea18c5 100755 --- a/app/tools/Archiver.java +++ b/app/tools/Archiver.java @@ -35,7 +35,7 @@ public class Archiver { Editor editor; // someday these will be settable - boolean useDate = true; //false; + boolean useDate; int digits = 3; NumberFormat numberFormat; @@ -79,6 +79,9 @@ public class Archiver { String namely = null; int index = 0; do { + // only use the date if the sketch name isn't the default name + useDate = !name.startsWith("sketch_"); + if (useDate) { String purty = dateFormat.format(new Date()); String stamp = purty + ((char) ('a' + index)); diff --git a/core/src/processing/core/PApplet.java b/core/src/processing/core/PApplet.java index cd389c666..922e0c747 100644 --- a/core/src/processing/core/PApplet.java +++ b/core/src/processing/core/PApplet.java @@ -184,7 +184,7 @@ public class PApplet extends Applet * Pixel buffer from this applet's PGraphics. *
* When used with OpenGL or Java2D, this value will
- * be null until beginPixels() has been called.
+ * be null until loadPixels() has been called.
*/
public int pixels[];
@@ -1137,7 +1137,7 @@ public class PApplet extends Applet
// if depth() is called inside setup, pixels/width/height
// will be ok by the time it's back out again
- //this.pixels = g.pixels; // make em call beginPixels
+ //this.pixels = g.pixels; // make em call loadPixels
// now for certain that we've got a valid size
this.width = g.width;
this.height = g.height;
@@ -6429,14 +6429,13 @@ public class PApplet extends Applet
//////////////////////////////////////////////////////////////
+ /**
+ * Override the g.pixels[] function to set the pixels[] array
+ * that's part of the PApplet object. Allows the use of
+ * pixels[] in the code, rather than g.pixels[].
+ */
public void loadPixels() {
- System.err.println("Use beginPixels() instead of loadPixels() " +
- "with release 0116 and later.");
- }
-
-
- public void beginPixels() {
- g.beginPixels();
+ g.loadPixels();
pixels = g.pixels;
}
@@ -6465,15 +6464,15 @@ public class PApplet extends Applet
}
- public void endPixels() {
- if (recorder != null) recorder.endPixels();
- g.endPixels();
+ public void updatePixels() {
+ if (recorder != null) recorder.updatePixels();
+ g.updatePixels();
}
- public void endPixels(int x1, int y1, int x2, int y2) {
- if (recorder != null) recorder.endPixels(x1, y1, x2, y2);
- g.endPixels(x1, y1, x2, y2);
+ public void updatePixels(int x1, int y1, int x2, int y2) {
+ if (recorder != null) recorder.updatePixels(x1, y1, x2, y2);
+ g.updatePixels(x1, y1, x2, y2);
}
diff --git a/core/src/processing/core/PGraphics.java b/core/src/processing/core/PGraphics.java
index ca0799006..50cedd1f9 100644
--- a/core/src/processing/core/PGraphics.java
+++ b/core/src/processing/core/PGraphics.java
@@ -2279,19 +2279,19 @@ public abstract class PGraphics extends PImage implements PConstants {
/**
* Draw a single character on screen.
* Extremely slow when used with textMode(SCREEN) and Java 2D,
- * because beginPixels has to be called first and updatePixels last.
+ * because loadPixels has to be called first and updatePixels last.
*/
public void text(char c, float x, float y) {
if (textFont == null) {
throw new RuntimeException("use textFont() before text()");
}
- if (textMode == SCREEN) beginPixels();
+ if (textMode == SCREEN) loadPixels();
textBuffer[0] = c;
textLineImpl(textBuffer, 0, 1, x, y);
- if (textMode == SCREEN) endPixels();
+ if (textMode == SCREEN) updatePixels();
}
@@ -2332,7 +2332,7 @@ public abstract class PGraphics extends PImage implements PConstants {
throw new RuntimeException("use textFont() before text()");
}
- if (textMode == SCREEN) beginPixels();
+ if (textMode == SCREEN) loadPixels();
int length = str.length();
if (length > textBuffer.length) {
@@ -2353,7 +2353,7 @@ public abstract class PGraphics extends PImage implements PConstants {
if (start < length) {
textLineImpl(textBuffer, start, index, x, y);
}
- if (textMode == SCREEN) endPixels();
+ if (textMode == SCREEN) updatePixels();
}
@@ -2423,7 +2423,7 @@ public abstract class PGraphics extends PImage implements PConstants {
throw new RuntimeException("use textFont() before text()");
}
- if (textMode == SCREEN) beginPixels();
+ if (textMode == SCREEN) loadPixels();
float hradius, vradius;
switch (rectMode) {
@@ -2551,7 +2551,7 @@ public abstract class PGraphics extends PImage implements PConstants {
textLineImpl(textBuffer, lineStart, index, lineX, currentY);
}
- if (textMode == SCREEN) endPixels();
+ if (textMode == SCREEN) updatePixels();
}
diff --git a/core/src/processing/core/PGraphics2D.java b/core/src/processing/core/PGraphics2D.java
index 929f09e79..d1b846f54 100644
--- a/core/src/processing/core/PGraphics2D.java
+++ b/core/src/processing/core/PGraphics2D.java
@@ -29,8 +29,8 @@ import java.awt.image.MemoryImageSource;
/**
- * Subclass of PGraphics that handles fast 2D rendering,
- * more commonly referred to as P2D. This class uses no Java2D
+ * Subclass of PGraphics that handles fast 2D rendering,
+ * more commonly referred to as P2D. This class uses no Java2D
* and will run with Java 1.1.
*/
public class PGraphics2D extends PGraphics {
@@ -44,29 +44,29 @@ public class PGraphics2D extends PGraphics {
private PPolygon tpolygon;
private int TPOLYGON_MAX_VERTICES = 512;
private int tpolygon_vertex_order[]; // = new int[MAX_VERTICES];
-
+
PLine line;
-
+
//boolean untransformed;
boolean strokeChanged = true;
boolean fillChanged = true;
-
+
static final int CVERTEX_ALLOC = 128;
float cvertex[][] = new float[CVERTEX_ALLOC][VERTEX_FIELD_COUNT];
int cvertexIndex;
-
-
+
+
//////////////////////////////////////////////////////////////
-
+
protected PGraphics2D() { }
-
-
+
+
public PGraphics2D(int iwidth, int iheight) {
this(iwidth, iheight, null);
}
-
+
public PGraphics2D(int iwidth, int iheight, PApplet applet) {
if (applet != null) {
this.parent = applet;
@@ -75,13 +75,13 @@ public class PGraphics2D extends PGraphics {
resize(iwidth, iheight);
}
-
+
//resize handled by superclass
-
-
+
+
//requestDisplay handled by superclass
-
-
+
+
protected void allocate() {
pixelCount = width * height;
pixels = new int[pixelCount];
@@ -102,31 +102,31 @@ public class PGraphics2D extends PGraphics {
}
}
-
+
//////////////////////////////////////////////////////////////
-
+
public void beginDraw() {
// need to call defaults(), but can only be done when it's ok
// to draw (i.e. for opengl, no drawing can be done outside
// beginDraw/endDraw).
if (!defaultsInited) {
defaults();
-
+
polygon = new PPolygon(this);
fpolygon = new PPolygon(this);
spolygon = new PPolygon(this);
spolygon.vertexCount = 4;
svertices = new float[2][];
}
-
+
resetMatrix(); // reset model matrix
-
+
// reset vertices
vertexCount = 0;
}
-
-
+
+
public void endDraw() {
// moving this back here (post-68) because of macosx thread problem
if (mis != null) {
@@ -134,35 +134,35 @@ public class PGraphics2D extends PGraphics {
}
// mark pixels as having been updated, so that they'll work properly
// when this PGraphics is drawn using image().
- endPixels();
+ updatePixels();
}
-
-
+
+
//////////////////////////////////////////////////////////////
-
+
public void beginShape(int kind) {
shape = kind;
vertexCount = 0;
splineVertexCount = 0;
-
+
polygon.reset(0);
fpolygon.reset(4);
spolygon.reset(4);
polygon.interpUV = false;
}
-
-
+
+
// PGraphics will throw a depthError
//public void normal(float nx, float ny, float nz)
-
+
// PGraphics will handle setting these
//public void textureMode(int mode)
//public void texture(PImage image)
//protected void textureVertex(float u, float v)
-
+
public void vertex(float x, float y) {
float vertex[] = polygon.nextVertex();
cvertexIndex = 0; // reset curves to start
@@ -189,26 +189,26 @@ public class PGraphics2D extends PGraphics {
if (textureImage != null) {
vertex[U] = textureU;
vertex[V] = textureV;
- }
+ }
}
-
+
public void vertex(float x, float y, float u, float v) {
textureVertex(u, v);
vertex(x, y);
}
-
+
public void vertex(float x, float y, float z) {
depthErrorXYZ("vertex");
}
-
+
public void vertex(float x, float y, float z, float u, float v) {
depthErrorXYZ("vertex");
}
-
-
+
+
public void endShape() {
// clear the 'shape drawing' flag in case of early exit
//shape = 0;
@@ -228,65 +228,65 @@ public class PGraphics2D extends PGraphics {
polyVertices[i][Y] = m10*polyVertices[i][MX] + m11*polyVertices[i][MY] + m13;
}
}
-
+
// ------------------------------------------------------------------
// TEXTURES
-
+
if (polygon.interpUV) {
fpolygon.texture(textureImage); //polygon.timage);
}
-
-
+
+
// ------------------------------------------------------------------
// COLORS
// calculate RGB for each vertex
-
+
spolygon.interpARGB = strokeChanged; //false;
fpolygon.interpARGB = fillChanged; //false;
-
+
// all the values for r, g, b have been set with calls to vertex()
// (no need to re-calculate anything here)
-
-
+
+
// ------------------------------------------------------------------
// RENDER SHAPES
-
+
int increment;
-
+
switch (shape) {
case POINTS:
if (untransformed() && (strokeWeight == 1)) {
if (!strokeChanged) {
for (int i = 0; i < polyVertexCount; i++) {
- thin_point((int) polyVertices[i][X], (int) polyVertices[i][Y],
+ thin_point((int) polyVertices[i][X], (int) polyVertices[i][Y],
0, strokeColor);
}
} else {
for (int i = 0; i < polyVertexCount; i++) {
thin_point((int) polyVertices[i][X], (int) polyVertices[i][Y],
- 0, float_color(polyVertices[i][SR],
- polyVertices[i][SG],
+ 0, float_color(polyVertices[i][SR],
+ polyVertices[i][SG],
polyVertices[i][SB]));
}
//strokei = strokeiSaved;
}
} else {
float f[] = polyVertices[0];
-
+
for (int i = 0; i < polyVertexCount; i++) {
float v[] = polyVertices[i];
-
+
// if this is the first time (i == 0)
// or if lighting is enabled
// or the stroke color has changed inside beginShape/endShape
// then re-calculate the color at this vertex
if ((i == 0) || strokeChanged) {
// push calculated color into 'f' (this way, f is always valid)
- calc_lighting(v[SR], v[SG], v[SB],
+ calc_lighting(v[SR], v[SG], v[SB],
v[X], v[Y], v[Z],
v[NX], v[NY], v[NZ], f, R);
}
- // uses [SA], since stroke alpha isn't moved into [A] the
+ // uses [SA], since stroke alpha isn't moved into [A] the
// way that [SR] goes to [R] etc on the calc_lighting call
// (there's no sense in copying it to [A], except consistency
// in the code.. but why the extra slowness?)
@@ -294,27 +294,27 @@ public class PGraphics2D extends PGraphics {
}
}
break;
-
+
case LINES:
//case LINE_STRIP:
//case LINE_LOOP:
if (!stroke) return;
-
+
// if it's a line loop, copy the vertex data to the last element
if (shape == LINE_LOOP) {
float v0[] = polygon.vertices[0];
float v1[] = polygon.nextVertex();
polyVertexCount++; // since it had already been read above
-
+
v1[X] = v0[X]; v1[Y] = v0[Y]; v1[Z] = v0[Z];
v1[SR] = v0[SR]; v1[SG] = v0[SG]; v1[SB] = v0[SB];
}
-
+
// increment by two for individual lines
increment = (shape == LINES) ? 2 : 1;
draw_lines(polyVertices, polyVertexCount-1, 1, increment, 0);
break;
-
+
case TRIANGLES:
case TRIANGLE_STRIP:
increment = (shape == TRIANGLES) ? 3 : 1;
@@ -328,11 +328,11 @@ public class PGraphics2D extends PGraphics {
fpolygon.vertices[j][G] = polyVertices[i+j][G];
fpolygon.vertices[j][B] = polyVertices[i+j][B];
fpolygon.vertices[j][A] = polyVertices[i+j][A];
-
+
fpolygon.vertices[j][X] = polyVertices[i+j][X];
fpolygon.vertices[j][Y] = polyVertices[i+j][Y];
fpolygon.vertices[j][Z] = polyVertices[i+j][Z];
-
+
if (polygon.interpUV) {
fpolygon.vertices[j][U] = polyVertices[i+j][U];
fpolygon.vertices[j][V] = polyVertices[i+j][V];
@@ -348,14 +348,14 @@ public class PGraphics2D extends PGraphics {
} else {
draw_lines(polyVertices, polyVertexCount-1, 1, 1, 3);
}
- // then draw from vertex (n) to (n+2)
+ // then draw from vertex (n) to (n+2)
// incrementing n using the same as above
draw_lines(polyVertices, polyVertexCount-2, 2, increment, 0);
// changed this to vertexCount-2, because it seemed
// to be adding an extra (nonexistant) line
}
break;
-
+
case QUADS:
case QUAD_STRIP:
//System.out.println("pooping out a quad");
@@ -368,11 +368,11 @@ public class PGraphics2D extends PGraphics {
fpolygon.vertices[j][G] = polyVertices[i+j][G];
fpolygon.vertices[j][B] = polyVertices[i+j][B];
fpolygon.vertices[j][A] = polyVertices[i+j][A];
-
+
fpolygon.vertices[j][X] = polyVertices[i+j][X];
fpolygon.vertices[j][Y] = polyVertices[i+j][Y];
fpolygon.vertices[j][Z] = polyVertices[i+j][Z];
-
+
if (polygon.interpUV) {
fpolygon.vertices[j][U] = polyVertices[i+j][U];
fpolygon.vertices[j][V] = polyVertices[i+j][V];
@@ -388,19 +388,19 @@ public class PGraphics2D extends PGraphics {
} else { // skip every few for quads
draw_lines(polyVertices, polyVertexCount, 1, 1, 4);
}
- // then draw from vertex (n) to (n+3)
+ // then draw from vertex (n) to (n+3)
// incrementing n by the same increment as above
draw_lines(polyVertices, polyVertexCount-2, 3, increment, 0);
}
break;
-
+
case POLYGON:
if (isConvex()) {
if (fill) {
polygon.render();
if (stroke) polygon.unexpand();
}
-
+
if (stroke) {
draw_lines(polyVertices, polyVertexCount-1, 1, 1, 0);
// draw the last line connecting back to the first point in poly
@@ -420,10 +420,10 @@ public class PGraphics2D extends PGraphics {
//if (stroke && !hints[DISABLE_SMOOTH_HACK]) smooth = smoov;
if (stroke) smooth = smoov;
}
-
+
if (stroke) {
draw_lines(polyVertices, polyVertexCount-1, 1, 1, 0);
- // draw the last line connecting back
+ // draw the last line connecting back
// to the first point in poly
svertices[0] = polyVertices[polyVertexCount-1];
svertices[1] = polyVertices[0];
@@ -432,18 +432,18 @@ public class PGraphics2D extends PGraphics {
}
break;
}
-
+
// to signify no shape being drawn
shape = 0;
}
-
-
+
+
//////////////////////////////////////////////////////////////
-
+
// CONCAVE/CONVEX POLYGONS
-
-
+
+
private boolean isConvex() {
float v[][] = polygon.vertices;
int n = polygon.vertexCount;
@@ -451,11 +451,11 @@ public class PGraphics2D extends PGraphics {
int flag = 0;
float z;
//float tol = 0.001f;
-
+
if (n < 3)
// ERROR: this is a line or a point, render with CONVEX
return true;
-
+
// iterate along border doing dot product.
// if the sign of the result changes, then is concave
for (int i=0;i
- * Unlike in PImage, where endPixels() only asks that the
+ * Unlike in PImage, where updatePixels() only asks that the
* update happens, in PGraphicsJava, this will happen immediately.
*/
- public void endPixels() {
- //endPixels(0, 0, width, height);
+ public void updatePixels() {
+ //updatePixels(0, 0, width, height);
WritableRaster raster = ((BufferedImage) image).getRaster();
raster.setDataElements(0, 0, width, height, pixels);
}
@@ -1035,14 +1035,14 @@ public class PGraphicsJava2D extends PGraphics {
/**
* Update the pixels[] buffer to the PGraphics image.
*
- * Unlike in PImage, where endPixels() only asks that the
+ * Unlike in PImage, where updatePixels() only asks that the
* update happens, in PGraphicsJava, this will happen immediately.
*/
- public void endPixels(int x, int y, int c, int d) {
+ public void updatePixels(int x, int y, int c, int d) {
if ((x == 0) && (y == 0) && (c == width) && (d == height)) {
- endPixels();
+ updatePixels();
} else {
- throw new RuntimeException("endPixels(x, y, c, d) not implemented");
+ throw new RuntimeException("updatePixels(x, y, c, d) not implemented");
}
/*
((BufferedImage) image).setRGB(x, y,
@@ -1194,16 +1194,16 @@ public class PGraphicsJava2D extends PGraphics {
public void filter(int kind) {
- beginPixels();
+ loadPixels();
super.filter(kind);
- endPixels();
+ updatePixels();
}
public void filter(int kind, float param) {
- beginPixels();
+ loadPixels();
super.filter(kind, param);
- endPixels();
+ updatePixels();
}
@@ -1229,9 +1229,9 @@ public class PGraphicsJava2D extends PGraphics {
public void copy(PImage src,
int sx1, int sy1, int sx2, int sy2,
int dx1, int dy1, int dx2, int dy2) {
- beginPixels();
+ loadPixels();
super.copy(src, sx1, sy1, sx2, sy2, dx1, dy1, dx2, dy2);
- endPixels();
+ updatePixels();
}
@@ -1239,32 +1239,32 @@ public class PGraphicsJava2D extends PGraphics {
public void blend(PImage src, int sx, int sy, int dx, int dy, int mode) {
- beginPixels();
+ loadPixels();
super.blend(src, sx, sy, dx, dy, mode);
- endPixels();
+ updatePixels();
}
public void blend(int sx, int sy, int dx, int dy, int mode) {
- beginPixels();
+ loadPixels();
super.blend(sx, sy, dx, dy, mode);
- endPixels();
+ updatePixels();
}
public void blend(int sx1, int sy1, int sx2, int sy2,
int dx1, int dy1, int dx2, int dy2, int mode) {
- beginPixels();
+ loadPixels();
super.blend(sx1, sy1, sx2, sy2, dx1, dy1, dx2, dy2, mode);
- endPixels();
+ updatePixels();
}
public void blend(PImage src, int sx1, int sy1, int sx2, int sy2,
int dx1, int dy1, int dx2, int dy2, int mode) {
- beginPixels();
+ loadPixels();
super.blend(src, sx1, sy1, sx2, sy2, dx1, dy1, dx2, dy2, mode);
- endPixels();
+ updatePixels();
}
@@ -1273,7 +1273,7 @@ public class PGraphicsJava2D extends PGraphics {
public void save(String filename) {
//System.out.println("start load");
- beginPixels();
+ loadPixels();
//System.out.println("end load, start save");
super.save(filename);
//System.out.println("done with save");
diff --git a/core/src/processing/core/PImage.java b/core/src/processing/core/PImage.java
index d6f097e99..e01f0df01 100644
--- a/core/src/processing/core/PImage.java
+++ b/core/src/processing/core/PImage.java
@@ -296,17 +296,17 @@ public class PImage implements PConstants, Cloneable {
/*
public void loadPixels() { // ignore
- System.err.println("Use beginPixels() instead of loadPixels() " +
+ System.err.println("Use loadPixels() instead of loadPixels() " +
"with release 0116 and later.");
- beginPixels();
+ loadPixels();
}
public void updatePixels() {
- System.err.println("Use endPixels() instead of updatePixels() " +
+ System.err.println("Use updatePixels() instead of updatePixels() " +
"with release 0116 and later.");
System.err.flush();
- endPixels();
+ updatePixels();
}
*/
@@ -318,7 +318,7 @@ public class PImage implements PConstants, Cloneable {
* For subclasses where the pixels[] buffer isn't set by default,
* this should copy all data into the pixels[] array
*/
- public void beginPixels() { // ignore
+ public void loadPixels() { // ignore
}
@@ -328,8 +328,8 @@ public class PImage implements PConstants, Cloneable {
*
* |
- * \ NNW | NNE /
- * \ | /
+ * \ NNW | NNE /
+ * \ | /
* WNW \ | / ENE
* -------------------
* WSW / | \ ESE
@@ -859,9 +859,9 @@ public class PGraphics2D extends PGraphics {
}
/**
- * Heavily adapted version of the above algorithm that handles
- * filling the ellipse. Works by drawing from the center and
- * outwards to the points themselves. Has to be done this way
+ * Heavily adapted version of the above algorithm that handles
+ * filling the ellipse. Works by drawing from the center and
+ * outwards to the points themselves. Has to be done this way
* because the values for the points are changed halfway through
* the function, making it impossible to just store a series of
* left and right edges to be drawn more quickly.
@@ -910,7 +910,7 @@ public class PGraphics2D extends PGraphics {
// unfortunately this can't handle fill and stroke simultaneously,
// because the fill will later replace some of the stroke points
- private final void flat_ellipse_symmetry(int centerX, int centerY,
+ private final void flat_ellipse_symmetry(int centerX, int centerY,
int ellipseX, int ellipseY,
boolean filling) {
if (filling) {
@@ -928,7 +928,7 @@ public class PGraphics2D extends PGraphics {
/**
- * Bresenham-style ellipse drawing function, adapted from a posting to
+ * Bresenham-style ellipse drawing function, adapted from a posting to
* comp.graphics.algortihms.
*
* This function is included because the quality is so much better,
@@ -940,7 +940,7 @@ public class PGraphics2D extends PGraphics {
* @param a horizontal radius
* @param b vertical radius
*/
- private void flat_ellipse_internal(int centerX, int centerY,
+ private void flat_ellipse_internal(int centerX, int centerY,
int a, int b, boolean filling) {
int x, y, a2, b2, s, t;
@@ -971,8 +971,8 @@ public class PGraphics2D extends PGraphics {
} while (y > 0);
}
-
-
+
+
private void flat_ellipse(int centerX, int centerY, int a, int b) {
if (unwarped()) {
float x = m00*centerX + m01*centerY + m02;
@@ -984,28 +984,28 @@ public class PGraphics2D extends PGraphics {
if (stroke) flat_ellipse_internal(centerX, centerY, a, b, false);
}
-
+
// TODO really need a decent arc function in here..
-
+
//protected void arcImpl(float x1, float y1, float w, float h,
// float start, float stop)
-
+
//////////////////////////////////////////////////////////////
// BOX & SPHERE
-
+
// The PGraphics superclass will throw errors for these fellas
-
-
+
+
//////////////////////////////////////////////////////////////
// BEZIER & CURVE
-
+
public void bezier(float x1, float y1, float z1,
float x2, float y2, float z2,
float x3, float y3, float z3,
@@ -1013,45 +1013,45 @@ public class PGraphics2D extends PGraphics {
depthErrorXYZ("bezier");
}
-
+
public void curve(float x1, float y1, float z1,
float x2, float y2, float z2,
float x3, float y3, float z3,
float x4, float y4, float z4) {
depthErrorXYZ("curve");
}
-
-
+
+
//////////////////////////////////////////////////////////////
-
+
// IMAGE
-
+
protected void imageImpl(PImage image,
float x1, float y1, float x2, float y2,
int u1, int v1, int u2, int v2) {
- if ((x2 - x1 == image.width) &&
+ if ((x2 - x1 == image.width) &&
(y2 - y1 == image.height) &&
- !tint && unwarped()) {
+ !tint && unwarped()) {
flat_image(image, (int) (x1 + m02), (int) (y1 + m12), u1, v1, u2, v2);
-
+
} else {
super.imageImpl(image, x1, y1, x2, y2, u1, v1, u2, v2);
}
}
-
-
+
+
/**
* Image drawn in flat "screen space", with no scaling or warping.
- * this is so common that a special routine is included for it,
+ * this is so common that a special routine is included for it,
* because the alternative is much slower.
*
* @param image image to be drawn
* @param sx1 x coordinate of upper-lefthand corner in screen space
* @param sy1 y coordinate of upper-lefthand corner in screen space
*/
- private void flat_image(PImage image, int sx1, int sy1,
+ private void flat_image(PImage image, int sx1, int sy1,
int ix1, int iy1, int ix2, int iy2) {
/*
int ix1 = 0;
@@ -1059,20 +1059,20 @@ public class PGraphics2D extends PGraphics {
int ix2 = image.width;
int iy2 = image.height;
*/
-
+
if (imageMode == CENTER) {
sx1 -= image.width / 2;
sy1 -= image.height / 2;
}
-
+
int sx2 = sx1 + image.width;
int sy2 = sy1 + image.height;
-
+
// don't draw if completely offscreen
// (without this check, ArrayIndexOutOfBoundsException)
- if ((sx1 > width1) || (sx2 < 0) ||
+ if ((sx1 > width1) || (sx2 < 0) ||
(sy1 > height1) || (sy2 < 0)) return;
-
+
if (sx1 < 0) { // off left edge
ix1 -= sx1;
sx1 = 0;
@@ -1089,18 +1089,18 @@ public class PGraphics2D extends PGraphics {
iy2 -= sy2 - height;
sy2 = height;
}
-
+
int source = iy1 * image.width + ix1;
int target = sy1 * width;
-
+
if (image.format == ARGB) {
for (int y = sy1; y < sy2; y++) {
int tx = 0;
-
+
for (int x = sx1; x < sx2; x++) {
- pixels[target + x] =
- _blend(pixels[target + x],
- image.pixels[source + tx],
+ pixels[target + x] =
+ _blend(pixels[target + x],
+ image.pixels[source + tx],
image.pixels[source + tx++] >>> 24);
}
source += image.width;
@@ -1109,17 +1109,17 @@ public class PGraphics2D extends PGraphics {
} else if (image.format == ALPHA) {
for (int y = sy1; y < sy2; y++) {
int tx = 0;
-
+
for (int x = sx1; x < sx2; x++) {
- pixels[target + x] =
- _blend(pixels[target + x],
- fillColor,
+ pixels[target + x] =
+ _blend(pixels[target + x],
+ fillColor,
image.pixels[source + tx++]);
}
source += image.width;
target += width;
}
-
+
} else if (image.format == RGB) {
target += sx1;
int tw = sx2 - sx1;
@@ -1132,21 +1132,21 @@ public class PGraphics2D extends PGraphics {
}
}
}
-
-
+
+
//////////////////////////////////////////////////////////////
// TEXT/FONTS
-
+
// These will be handled entirely by PGraphics.
-
-
-
+
+
+
//////////////////////////////////////////////////////////////
- // expects properly clipped coords, hence does
+ // expects properly clipped coords, hence does
// NOT check if x/y are in bounds [toxi]
private void thin_pointAt(int x, int y, float z, int color) {
int index = y*width+x; // offset values are pre-calced in constructor
@@ -1161,8 +1161,8 @@ public class PGraphics2D extends PGraphics {
zbuffer[offset] = z;
}
- // points are inherently flat, but always tangent
- // to the screen surface. the z is only so that things
+ // points are inherently flat, but always tangent
+ // to the screen surface. the z is only so that things
// get scaled properly if the pt is way in back
private void thick_point(float x, float y, float z, // note floats
float r, float g, float b, float a) {
@@ -1179,7 +1179,7 @@ public class PGraphics2D extends PGraphics {
svertex[R] = r;
svertex[G] = g;
svertex[B] = b;
- svertex[A] = a;
+ svertex[A] = a;
svertex = spolygon.vertices[1];
svertex[X] = x + strokeWidth2;
@@ -1205,7 +1205,7 @@ public class PGraphics2D extends PGraphics {
int nx1,ny1,nx2,ny2;
// get the "dips" for the points to clip
- int code1 = thin_flat_lineClipCode(x1, y1);
+ int code1 = thin_flat_lineClipCode(x1, y1);
int code2 = thin_flat_lineClipCode(x2, y2);
if ((code1 & code2)!=0) {
@@ -1260,9 +1260,9 @@ public class PGraphics2D extends PGraphics {
// special case: vertical line
if (ny1>ny2) { int ty=ny1; ny1=ny2; ny2=ty; }
int offset=ny1*width+nx1;
- for(int j=ny1; j<=ny2; j++) {
- thin_pointAtIndex(offset,0,strokeColor);
- offset+=width;
+ for(int j=ny1; j<=ny2; j++) {
+ thin_pointAtIndex(offset,0,strokeColor);
+ offset+=width;
}
return;
} else if (ny1==ny2) {
@@ -1281,11 +1281,11 @@ public class PGraphics2D extends PGraphics {
return;
}
longLen+=ny1;
- for (int j=0x8000+(nx1<<16);ny1>=longLen;--ny1) {
+ for (int j=0x8000+(nx1<<16);ny1>=longLen;--ny1) {
thin_pointAt(j>>16, ny1, 0, strokeColor);
j-=decInc;
}
- return;
+ return;
} else if (longLen>0) {
longLen+=nx1;
for (int j=0x8000+(ny1<<16);nx1<=longLen;++nx1) {
@@ -1306,7 +1306,7 @@ public class PGraphics2D extends PGraphics {
(x < 0 ? 2 : 0) | (x > width1 ? 1 : 0));
}
- private float thin_flat_lineSlope(float x1, float y1,
+ private float thin_flat_lineSlope(float x1, float y1,
float x2, float y2, int border) {
switch (border) {
case 4: {
@@ -1326,11 +1326,11 @@ public class PGraphics2D extends PGraphics {
}
- private boolean flat_line_retribution(float x1, float y1,
+ private boolean flat_line_retribution(float x1, float y1,
float x2, float y2,
float r1, float g1, float b1) {
/*
- // assume that if it is/isn't big in one dir, then the
+ // assume that if it is/isn't big in one dir, then the
// other doesn't matter, cuz that's a weird case
float lwidth = m00*strokeWeight + m01*strokeWeight;
//float lheight = m10*strokeWeight + m11*strokeWeight;
@@ -1339,7 +1339,7 @@ public class PGraphics2D extends PGraphics {
//if (abs(lwidth) < 1.5f) {
//System.out.println("flat line retribution " + r1 + " " + g1 + " " + b1);
int strokeSaved = strokeColor;
- strokeColor = float_color(r1, g1, b1);
+ strokeColor = float_color(r1, g1, b1);
thin_flat_line((int)x1, (int)y1, (int)x2, (int)y2);
strokeColor = strokeSaved;
return true;
@@ -1349,14 +1349,14 @@ public class PGraphics2D extends PGraphics {
}
- private void thick_flat_line(float ox1, float oy1,
+ private void thick_flat_line(float ox1, float oy1,
float r1, float g1, float b1, float a1,
- float ox2, float oy2,
+ float ox2, float oy2,
float r2, float g2, float b2, float a2) {
spolygon.interpARGB = (r1 != r2) || (g1 != g2) || (b1 != b2) || (a1 != a2);
spolygon.interpZ = false;
- if (!spolygon.interpARGB &&
+ if (!spolygon.interpARGB &&
flat_line_retribution(ox1, oy1, ox2, oy2, r1, g1, b1)) {
return;
}
@@ -1413,11 +1413,11 @@ public class PGraphics2D extends PGraphics {
/*
// OPT version without z coords can save 8 multiplies and some other
- private void spatial_line(float x1, float y1,
- float r1, float g1, float b1,
- float x2, float y2,
+ private void spatial_line(float x1, float y1,
+ float r1, float g1, float b1,
+ float x2, float y2,
float r2, float g2, float b2) {
- spatial_line(x1, y1, 0, r1, g1, b1,
+ spatial_line(x1, y1, 0, r1, g1, b1,
x2, y2, 0, r2, g2, b2);
}
@@ -1426,11 +1426,11 @@ public class PGraphics2D extends PGraphics {
// and the colors have been calculated
private void spatial_line(float x1, float y1, float z1,
- float r1, float g1, float b1,
- float x2, float y2, float z2,
+ float r1, float g1, float b1,
+ float x2, float y2, float z2,
float r2, float g2, float b2) {
spolygon.interpARGB = (r1 != r2) || (g1 != g2) || (b1 != b2);
- if (!spolygon.interpARGB &&
+ if (!spolygon.interpARGB &&
flat_line_retribution(x1, y1, x2, y2, r1, g1, b1)) {
return;
}
@@ -1495,7 +1495,7 @@ public class PGraphics2D extends PGraphics {
// max is what to count to
// offset is offset to the 'next' vertex
// increment is how much to increment in the loop
- private void draw_lines(float vertices[][], int max,
+ private void draw_lines(float vertices[][], int max,
int offset, int increment, int skip) {
if (strokeWeight < 2) {
@@ -1524,17 +1524,17 @@ public class PGraphics2D extends PGraphics {
for (int i = 0; i < max; i += increment) {
if ((skip != 0) && (((i+offset) % skip) == 0)) continue;
- thin_flat_line((int) vertices[i][X],
- (int) vertices[i][Y],
- (int) vertices[i+offset][X],
+ thin_flat_line((int) vertices[i][X],
+ (int) vertices[i][Y],
+ (int) vertices[i+offset][X],
(int) vertices[i+offset][Y]);
}
- } else {
+ } else {
for (int i = 0; i < max; i += increment) {
if ((skip != 0) && (((i+offset) % skip) == 0)) continue;
float v1[] = vertices[i];
float v2[] = vertices[i+offset];
- thick_flat_line(v1[X], v1[Y], v1[SR], v1[SG], v1[SB], v1[SA],
+ thick_flat_line(v1[X], v1[Y], v1[SR], v1[SG], v1[SB], v1[SA],
v2[X], v2[Y], v2[SR], v2[SG], v2[SB], v2[SA]);
}
}
@@ -1550,16 +1550,16 @@ public class PGraphics2D extends PGraphics {
private void thin_point(int x, int y, float z, int color) {
// necessary? [fry] yes! [toxi]
- if (x<0 || x>width1 || y<0 || y>height1) return;
+ if (x<0 || x>width1 || y<0 || y>height1) return;
int index = y*width + x;
if ((color & 0xff000000) == 0xff000000) { // opaque
- pixels[index] = color;
+ pixels[index] = color;
} else { // transparent
// couldn't seem to get this working correctly
- //pixels[index] = _blend(pixels[index],
+ //pixels[index] = _blend(pixels[index],
// color & 0xffffff, (color >> 24) & 0xff);
// a1 is how much of the orig pixel
@@ -1575,28 +1575,28 @@ public class PGraphics2D extends PGraphics {
pixels[index] = 0xff000000 | (r << 8) | g | b;
- //pixels[index] = _blend(pixels[index],
+ //pixels[index] = _blend(pixels[index],
// color & 0xffffff, (color >> 24) & 0xff);
/*
- pixels[index] = 0xff000000 |
- ((((a1 * ((pixels[index] >> 16) & 0xff) +
+ pixels[index] = 0xff000000 |
+ ((((a1 * ((pixels[index] >> 16) & 0xff) +
a2 * ((color >> 16) & 0xff)) & 0xff00) << 24) << 8) |
- (((a1 * ((pixels[index] >> 8) & 0xff) +
+ (((a1 * ((pixels[index] >> 8) & 0xff) +
a2 * ((color >> 8) & 0xff)) & 0xff00) << 16) |
- (((a1 * ( pixels[index] & 0xff) +
+ (((a1 * ( pixels[index] & 0xff) +
a2 * ( color & 0xff)) >> 8));
*/
}
zbuffer[index] = z;
}
-
-
+
+
//////////////////////////////////////////////////////////////
// BACKGROUND AND FRIENDS
-
+
/**
* Clear the pixel buffer.
*/
@@ -1606,29 +1606,29 @@ public class PGraphics2D extends PGraphics {
}
}
-
+
//////////////////////////////////////////////////////////////
// INTERNAL SCHIZZLE
-
+
private boolean untransformed() {
return ((m00 == 1) && (m01 == 0) && (m02 == 0) &&
(m10 == 0) && (m11 == 1) && (m12 == 0));
}
-
-
+
+
private boolean unwarped() {
return ((m00 == 1) && (m01 == 0) && (m10 == 0) && (m11 == 1));
}
-
-
+
+
// doesn't really do lighting per se...
private void calc_lighting(float r, float g, float b,
float ix, float iy, float iz,
- float nx, float ny, float nz,
+ float nx, float ny, float nz,
float target[], int toffset) {
target[toffset + 0] = r;
target[toffset + 1] = g;
@@ -1637,7 +1637,7 @@ public class PGraphics2D extends PGraphics {
static private final int float_color(float r, float g, float b) {
- return (0xff000000 |
+ return (0xff000000 |
((int) (255.0f * r)) << 16 |
((int) (255.0f * g)) << 8 |
((int) (255.0f * b)));
diff --git a/core/src/processing/core/PGraphics3D.java b/core/src/processing/core/PGraphics3D.java
index aac0ae427..4876b01b0 100644
--- a/core/src/processing/core/PGraphics3D.java
+++ b/core/src/processing/core/PGraphics3D.java
@@ -228,7 +228,7 @@ public class PGraphics3D extends PGraphics {
}
*/
insideResize = true;
-
+
width = iwidth;
height = iheight;
width1 = width - 1;
@@ -325,7 +325,7 @@ public class PGraphics3D extends PGraphics {
public void beginDraw() {
insideResizeWait();
insideDraw = true;
-
+
// need to call defaults(), but can only be done when it's ok
// to draw (i.e. for opengl, no drawing can be done outside
// beginDraw/endDraw).
@@ -384,7 +384,7 @@ public class PGraphics3D extends PGraphics {
}
// mark pixels as having been updated, so that they'll work properly
// when this PGraphics is drawn using image().
- endPixels();
+ updatePixels();
//System.out.println(this + " end draw");
insideDraw = false;
diff --git a/core/src/processing/core/PGraphicsJava2D.java b/core/src/processing/core/PGraphicsJava2D.java
index 545c13693..504f4ad1c 100644
--- a/core/src/processing/core/PGraphicsJava2D.java
+++ b/core/src/processing/core/PGraphicsJava2D.java
@@ -132,7 +132,7 @@ public class PGraphicsJava2D extends PGraphics {
public void endDraw() {
// hm, mark pixels as changed, because this will instantly do a full
// copy of all the pixels to the surface.. so that's kind of a mess.
- //endPixels();
+ //updatePixels();
}
@@ -557,7 +557,7 @@ public class PGraphicsJava2D extends PGraphics {
int u1, int v1, int u2, int v2) {
if (who.cache == null) {
who.cache = new ImageCache(who);
- who.endPixels(); // mark the whole thing for update
+ who.updatePixels(); // mark the whole thing for update
}
ImageCache cash = (ImageCache) who.cache;
@@ -567,7 +567,7 @@ public class PGraphicsJava2D extends PGraphics {
(tint && (cash.tintedColor != tintColor)) ||
(!tint && cash.tinted)) {
// for tint change, mark all pixels as needing update
- who.endPixels();
+ who.updatePixels();
}
if (who.modified) {
@@ -1009,7 +1009,7 @@ public class PGraphicsJava2D extends PGraphics {
//////////////////////////////////////////////////////////////
- public void beginPixels() {
+ public void loadPixels() {
if ((pixels == null) || (pixels.length != width * height)) {
pixels = new int[width * height];
}
@@ -1022,11 +1022,11 @@ public class PGraphicsJava2D extends PGraphics {
/**
* Update the pixels[] buffer to the PGraphics image.
*