@antiplastik
Ah, your solution is nice too. I overlooked the way to make transparent background, hence my drawing of the image in the buffer, but it is limited (static) unlike true transparency.
And the usage of translate is smart too, I haven't use the Processing's transformation matrices yet, it is a good illustration of their use.
I tried to draw a static image, then copy it progressively, but I get a white rectangle on top of the ellipse (behind it) and a black one at the bottom. What I am missing?
Code:PImage pi; // Background image
PGraphics pg; // Off-screen graphic buffer
int x = 0, sz = 80;
int cx = 50, cy = 70;
void setup()
{
size(200, 200);
smooth();
pi = loadImage("../../Globe.png"); // Any graphic will do, this is to show it is hidden only by the real graphics
pg = createGraphics(width, height, JAVA2D);
pg.beginDraw();
pg.ellipseMode(CORNER);
pg.background(255, 0); // Transparent background
// draw a green ellipse and a red rectangle
// in point cy
pg.stroke(0); pg.fill(20, 200, 10);
pg.ellipse(cx, cy, sz, sz);//green ellipse
pg.fill(200, 20, 20);
pg.rect(cx, cy+30, sz/2, sz/2); // red rectangle
pg.endDraw();
}
void draw()
{
if (x > sz)
{
println("End");
noLoop(); // Stop
return;
}
image(pi, 0, 0); // Draw background on display (clear it)
copy(pg, cx, cy, sz, x, cx, cy+sz-x, sz+1, x+1);
x++;
}