/**
turning ants to letters by guru
click on the text ...
*/
import geomerative.*;
import java.util.ArrayList;
Particle[] particles;
RFont font;
RGroup grp;
PGraphics g;
int mode = 0;
void setup() {
size(400, 400);
smooth();
RG.init(this);
font = new RFont( "VeraBd.ttf", 75, RFont.CENTER);
grp = font.toGroup("Ants!");
grp.translate( 0, -10 );
RCommand.setSegmentLength(5);
RCommand.setSegmentator(RCommand.UNIFORMLENGTH);
grp = grp.toPolygonGroup();
initP();
}
void draw() {
background(255);
translate(width/2, height/2+35);
stroke(0, 128);
fill(255, 128);
for ( int i =0; i < particles.length; i++) {
particles[i].update();
particles[i].draw();
}
}
void mousePressed() {
if ( mode == 0 ) {
mode = 1;
} else {
mode = 0;
initP();
}
}
void initP() {
RPoint[] pnts = grp.getPoints();
particles = new Particle[ pnts.length ];
for ( int i=0; i < pnts.length; i++) {
PVector target = new PVector( pnts[i].x, pnts[i].y);
PVector pos = new PVector( random( width )-width/2, random( height )-height/2);
particles[i] = new Particle( pos, target );
}
}