Skip to content

Instantly share code, notes, and snippets.

@jedahan
Created October 3, 2013 21:11
Show Gist options
  • Select an option

  • Save jedahan/6817192 to your computer and use it in GitHub Desktop.

Select an option

Save jedahan/6817192 to your computer and use it in GitHub Desktop.
Make sure to install geomerative library in processing (Sketch -> Import Library -> Add Library)
import geomerative.*;
RShape shp1;
RShape shp2;
RShape shp3;
RShape cursorShape;
void setup()
{
size(400, 400);
smooth();
RG.init(this);
shp1 = RShape.createCircle(0,0,100.0);
shp2 = RShape.createCircle(50,50,100.0);
}
void draw()
{
background(255);
translate(width/2,height/2);
// Only intersection() does not work for shapes with more than one path
shp3 = RG.intersection( shp1, shp2 );
strokeWeight( 3 );
if(mousePressed){
fill( 0 , 220 , 0 , 30 );
stroke( 0 , 120 , 0 );
RG.shape(shp1);
fill( 220 , 0 , 0 , 30 );
stroke( 120 , 0 , 0 );
RG.shape(shp2);
}
else{
fill( 220 );
stroke( 120 );
RG.shape(shp3);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment