Created
November 12, 2013 14:09
-
-
Save dimkir/7431405 to your computer and use it in GitHub Desktop.
Processing sketch : lettersExplodeTest
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//#GISTID: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); | |
} | |
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