misc cleanup on api stuff with PGraphics2

This commit is contained in:
benfry
2005-06-08 23:44:32 +00:00
parent 9f220a8fbc
commit e62e5d79a4
3 changed files with 52 additions and 9 deletions

View File

@@ -724,15 +724,18 @@ public class PGraphics2 extends PGraphics {
public float screenX(float x, float y) {
g2.getTransform().getMatrix(transform);
//return m00*x + m01*y + m02;
return (float)transform[0]*x + (float)transform[2]*y + (float)transform[4];
loadMatrix();
return super.screenX(x, y);
//g2.getTransform().getMatrix(transform);
//return (float)transform[0]*x + (float)transform[2]*y + (float)transform[4];
}
public float screenY(float x, float y) {
g2.getTransform().getMatrix(transform);
return (float)transform[1]*x + (float)transform[3]*y + (float)transform[5];
loadMatrix();
return super.screenY(x, y);
//g2.getTransform().getMatrix(transform);
//return (float)transform[1]*x + (float)transform[3]*y + (float)transform[5];
}
@@ -967,6 +970,19 @@ public class PGraphics2 extends PGraphics {
//////////////////////////////////////////////////////////////
public void mask(int alpha[]) {
throw new RuntimeException("mask() cannot be used with JAVA2D");
}
public void mask(PImage alpha) {
throw new RuntimeException("mask() cannot be used with JAVA2D");
}
//////////////////////////////////////////////////////////////
public void filter(int kind) {
loadPixels();
super.filter(kind);
@@ -984,7 +1000,24 @@ public class PGraphics2 extends PGraphics {
//////////////////////////////////////////////////////////////
public void copy(PImage src, int sx1, int sy1, int sx2, int sy2,
public void copy(int sx, int sy, int sw, int sh,
int dx, int dy, int dw, int dh) {
if ((sw != dw) || (sh != dh)) {
// use slow version if changing size
copy(this, sx, sy, sw, sh, dx, dy, dw, dh);
}
if (imageMode == CORNERS) {
sw -= sx;
sh -= sy;
}
dx = dx - sx; // java2d's "dx" is the delta, not dest
dy = dy - sy;
g2.copyArea(sx, sy, sw, sh, dx, dy);
}
public void copy(PImage src,
int sx1, int sy1, int sx2, int sy2,
int dx1, int dy1, int dx2, int dy2) {
loadPixels();
super.copy(src, sx1, sy1, sx2, sy2, dx1, dy1, dx2, dy2);
@@ -992,6 +1025,9 @@ public class PGraphics2 extends PGraphics {
}
//////////////////////////////////////////////////////////////
public void blend(PImage src, int sx, int sy, int dx, int dy, int mode) {
loadPixels();
super.blend(src, sx, sy, dx, dy, mode);
@@ -1022,10 +1058,11 @@ public class PGraphics2 extends PGraphics {
}
//////////////////////////////////////////////////////////////
public void save(String filename) {
loadPixels();
super.save(filename);
//boolean ImageIO.write(RenderedImage im, String formatName, File output)
}
}

View File

@@ -819,7 +819,7 @@ public class PImage implements PConstants, Cloneable {
* <PRE>
* BLEND - linear interpolation of colours: C = A*factor + B
* ADD - additive blending with white clip: C = min(A*factor + B, 255)
* SUBSTRACT - substractive blending with black clip: C = max(B - A*factor, 0)
* SUBSTRACT - substractive blend with black clip: C = max(B - A*factor, 0)
* DARKEST - only the darkest colour succeeds: C = min(A*factor, B)
* LIGHTEST - only the lightest colour succeeds: C = max(A*factor, B)
* REPLACE - destination colour equals colour of source pixel: C = A
@@ -1558,6 +1558,11 @@ public class PImage implements PConstants, Cloneable {
}
// TODO write reflection code here to use java 1.4 imageio methods
// for writing out images that might be much better
// won't want to use them in all cases.. how to determine?
// maybe for the 1.4 kids, would be nice to have:
//boolean ImageIO.write(RenderedImage im, String formatName, File output)
public void save(String filename) { // ignore
boolean success = false;

View File

@@ -10,6 +10,7 @@ X vars like cameraX etc need to be in PGraphics
X otherwise g.xxxx won't work
X how far should this go? vertices etc?
X vertices not included because switching to triangleImpl and lineImpl
X fix for copy() in java2d to make things a little speedier
_ change PGraphics to PGraphics2
_ or not, because PGraphics has all the base stuff for 3D