Skip to content

Instantly share code, notes, and snippets.

@dimkir
Created November 12, 2013 14:07
Show Gist options
  • Save dimkir/7431373 to your computer and use it in GitHub Desktop.
Save dimkir/7431373 to your computer and use it in GitHub Desktop.
Processing sketch : lettersExplodeTest
//#GIST:7431373
import geomerative.*;
import org.apache.batik.svggen.font.table.*;
import org.apache.batik.svggen.font.*;
RShape letterShape, polyshape;
int midX, midY;
void setup(){
size(800,600);
midX = width/2;
midY = height/2;
RG.init(this);
letterShape = RG.getText("R", "FreeSans.ttf", 72, CENTER);
}
// let's see if this is updated in the SketchCode
float mapMouseXBetween(float left, float right){
return map(mouseX, 0, width, left, right);
}
float mouseSeparation(){
return mapMouseXBetween(5, 200);
}
void shapeAt(float x, float y, RShape shp){
pushMatrix();
translate(x, y);
strokeWeight(2);
stroke(#304EF0);
shp.draw();
popMatrix();
}
/**
* Displays points of the shape.
*/
void shapePointsAt(float x, float y, RShape shp){
// fill(#FF0000);
stroke(#FCF61F);
pushMatrix();
translate(x, y);
for(RPoint p : shp.getPoints() ){
point(p.x, p.y);
}
popMatrix();
}
void draw()
{
background(128);
RG.setPolygonizer(RG.UNIFORMLENGTH);
RG.setPolygonizerLength(mouseSeparation());
polyshape = RG.polygonize(letterShape);
shapeAt(midX, midY, polyshape);
shapePointsAt(midX, midY, polyshape);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment