public int getWidth() { return i == null ? 0 : i.getWidth(null); }
public void setClip(int x, int y, int x2, int y2) { g.setClip(x, y, x2 - x, y2 - y); }
- public void drawPicture(Picture source, int x, int y) {
- drawPicture(source, x, y, x + source.getWidth(), y + source.getHeight(), 0, 0, source.getWidth(), source.getHeight());
- }
-
public void drawPicture(Picture source, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2) {
g.drawImage(((AWTPicture)source).i, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2, null);
}
+ public void drawPictureAlphaOnly(Picture source, int dx1, int dy1, int dx2, int dy2,
+ int sx1, int sy1, int sx2, int sy2, int rgb) {
+ AWTPicture p = (AWTPicture)source;
+ Graphics g = p.i.getGraphics();
+ g.setXORMode(new Color(rgb));
+ g.fillRect(0, 0, p.i.getWidth(null), p.i.getHeight(null));
+ drawPicture(source, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2);
+ g.fillRect(0, 0, p.i.getWidth(null), p.i.getHeight(null));
+ }
+
public void fillRect(int x, int y, int x2, int y2, int argb) {
// FEATURE: use an LRU cache for Color objects
- g.setColor(new Color((argb & 0x00FF0000) >> 16, (argb & 0x0000FF00) >> 8, (argb & 0x000000FF)));
- g.fillRect(x, y, x2 - x, y2 - y);
}
+ // FIXME: try to use os acceleration
+ public void fillTrapezoid(int x1, int x2, int y1, int x3, int x4, int y2, int argb) {
+ g.setColor(new Color((argb & 0x00FF0000) >> 16, (argb & 0x0000FF00) >> 8, (argb & 0x000000FF)));
+ if (x1 == x3 && x2 == x4) {
+ g.fillRect(x1, y1, x4 - x1, y2 - y1);
+ } else for(int y=y1; y<y2; y++) {
+ int _x1 = (int)Math.floor((y - y1) * (x3 - x1) / (y2 - y1) + x1);
+ int _y1 = (int)Math.floor(y);
+ int _x2 = (int)Math.ceil((y - y1) * (x4 - x2) / (y2 - y1) + x2);
+ int _y2 = (int)Math.floor(y) + 1;
+ if (_x1 > _x2) { int _x0 = _x1; _x1 = _x2; _x2 = _x0; }
+ g.fillRect(_x1, _y1, _x2 - _x1, _y2 - _y1);
+ }
+ }
}