xxxxxxxxxx
/*---------------------------
Diversity/Community
by Travis McDaniel
Created Feb 23rd-Mar 7th
mcdaniel.639@osu.edu
----------------------------*/
//Library imports
//import processing.pdf.*;
//Global Variable Declaration
float chaos = 0;
float pi = 3.14159265359;
float shapeSize;
float spokes;
float imageCounter=0;
void setup()
{
size(2400, 2400);
shapeSize = width/100;
spokes = 15;
smooth();
noStroke();
rectMode(CENTER);
}
void draw()
{
//Start writing to PDF
//beginRecord(PDF, "Capture###.pdf");
background(255); //White Background
translate(width/2,height/2); //Set origin to center of canvas
//Nested loops to draw a radial pattern first going around the edge of the pattern then moving inwards and repeating until it reaches the center
for (int y = height*2/3; y > 0; y-=shapeSize*3) //Going towards the center
{
for (float r = 0; r < 2*pi; r+=2*pi/spokes) //rotating the canvas to get a radial effect
{
//Draw stuff
Person person1;
//Outer communities
if (y > height/8)
{
//Red Circles
if(r < 2*pi/3) // 1/3 of outside radial
{
//fill(random(55) + 200, random(120), random(120));
fill(75);
person1 = new Person(random(chaos)-chaos/2, y + random(chaos)-chaos/2, shapeSize, 0);
person1.Draw();
}
//Green Triangles
else if(r < 4*pi/3)
{
fill(150);
//fill(random(120), random(55) + 200, random(120));
person1 = new Person(random(chaos)-chaos/2, y + random(chaos)-chaos/2, shapeSize, 1);
person1.Draw();
}
//Blue Squares
else if(r < 2*pi)
{
fill(225);
//fill (random(120), random(120), random(55)+200);
person1 = new Person(random(chaos)-chaos/2, y + random(chaos)-chaos/2, shapeSize, 2);
person1.Draw();
}
}
//Inner Community
else
{
//Determine color by chance
int chance = int(random(3));
if (chance == 0) //Red
{
fill (75);
//fill(random(55) + 200, random(120), random(120));
}
else if (chance == 1) //Green
{
fill(150);
//fill(random(120), random(55) + 200, random(120));
}
else //Blue
{
fill(225);
//fill (random(120), random(120), random(55)+200);
}
//Determine shape by chance
chance = int(random(3));
if (chance == 0) //Circle
{
person1 = new Person(random(chaos)-chaos/2, y + random(chaos)-chaos/2, shapeSize, 0);
person1.Draw();
}
else if (chance == 1) //Triangle
{
person1 = new Person(random(chaos)-chaos/2, y + random(chaos)-chaos/2, shapeSize, 1);
person1.Draw();
}
else //Square
{
person1 = new Person(random(chaos)-chaos/2, y + random(chaos)-chaos/2, shapeSize, 2);
person1.Draw();
}
}
//Rotate canvas
rotate(2*pi/spokes);
}
//Increase chaos
chaos+=10;
spokes+=random(5);
resetMatrix();
translate(width/2,height/2);
}
resetMatrix();
chaos = 0;
spokes = 15;
//Stop PDF recording
//endRecord();
//Stop loop after 20 records
//if (imageCounter>20)
//{
noLoop();
//}
//else
//{
//imageCounter++;
//saveFrame("Capture###.tif");
//}
}
void keyReleased()
{
if (key == 'n' || key == 'N')
{
loop();
}
else if (key == 'p' || key == 'P')
{
//saveFrame("Capture####.tif");
}
}