Skip to content

Instantly share code, notes, and snippets.

@timpulver
Created December 4, 2012 15:23
Show Gist options
  • Save timpulver/4205105 to your computer and use it in GitHub Desktop.
Save timpulver/4205105 to your computer and use it in GitHub Desktop.
[Processing] Graphical intersection ellipse
/*
* Copied from: Stack Overflow user V.K. http://stackoverflow.com/users/1690199/v-k
* Tags: Intersection, ellipse, blend, intersect, difference, overlap, overlapping
*
*/
PGraphics c;
PGraphics d;
void setup() {
size(300, 300);
background(255);
c = createGraphics(width, height, JAVA2D);
d = createGraphics(width, height, JAVA2D);
c.beginDraw();
c.smooth();
c.endDraw();
d.beginDraw();
d.smooth();
d.endDraw();
}
void draw() {
background(255);
c.beginDraw();
c.background(0, 0);
c.fill(255);
c.stroke(0);
c.ellipse(mouseX, mouseY, 30, 30);
c.endDraw();
d.beginDraw();
d.background(0, 0);
d.fill(255);
d.stroke(0);
d.ellipse(width/2, height/2, 30, 30);
d.endDraw();
d.blend(c, 0, 0, width, height, 0, 0, width, height, DIFFERENCE);
image(d, 0, 0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment