http://www.cricketschirping.com/processing/CirclePacking1/ is certainly a nice one!
as can be read in the script, here is an explanation:
http://wiki.mcneel.com/developer/sdksamples/2dcirclepacking
The example file has to be modified a bit, the noc library is deprecated and you can replace it with PVector:
PVector v = new PVector(); // instead of Vector3D v = new Vector3D();
The circles have a random radius, you can change this in: ArrayList createRandomCircles(int n) .....
float myRadius = 30;//this was 10 + random (30)
Circle c = new Circle(random(width), random(height), myRadius);
The radius is chosen for all the circles which are put in the arraylist (the return of this function)
So here you can make the link between an array with data (for instance from the NYTimes Api examples).
With
text( "hello", (int)x, (int)y );
in the circle class:
public void draw() {
fill(myColor);
stroke(myColor);
strokeWeight(3);
ellipse((int)x, (int)y, (int)radius*2, (int)radius*2);
text( "hello", (int)x, (int)y );
}
you can add a text to the circles. This text is static at the moment, but could come from an array of names of countries...
Here is this modified version of the script:
http://www.contrechoc.com/crosslab/circlePacking.zip
(Thx to Martijn, who found this script.)
other circle scripts can be found here:
http://www.openprocessing.org/visuals/?visualID=11727
Aucun commentaire:
Enregistrer un commentaire