It can be done. As this block of code shows, you can render the objects to their own off-screen buffers, then examine the pixels in those buffers to see if there are any pixels that are different from the background color in both.
Quote:boolean touching;
PGraphics g2, g3;
void setup(){
size(200,200, P2D);
g2 = createGraphics(200,200, P2D);
g3 = createGraphics(200,200, P2D);
noStroke();
}
void draw(){
pushMatrix();
g2.beginDraw();
g2.background(0);
g2.fill(255);
g2.noStroke();
g2.rect(20,30,40,50);
g2.rect(20,30,100,5);
g2.ellipse(190,190,40,60);
g2.loadPixels();
g2.endDraw();
g3.beginDraw();
g3.background(128);
g3.fill(255);
g3.noStroke();
g3.rect(mouseX-5,mouseY-5,10,10);
g3.loadPixels();
g3.endDraw();
touching = false;
for( int i = 0; i < 200*200; i++){
touching = touching || (g3.pixels[i] == g2.pixels[i]);
}
background(!touching?color(128,0,0):color(0,128,0));
fill(196,0,196);
rect(20,30,40,50);
fill(0,0,0);
rect(20,30,100,5);
fill(200,100,50);
ellipse(190,190,40,60);
fill(196,196,0);
rect(mouseX-5, mouseY-5, 10, 10);
popMatrix();
}