xxxxxxxxxx
ArrayList<rose> roses;
float R = 0;
float t = 0;
float n = 2;
float outerrnum;
void setup()
{
fullScreen();
//size(640, 480);
colorMode(HSB);
outerrnum = 8;
roses = new ArrayList<rose>();
roses.add(new rose());
for (int i = 0; i < outerrnum; i++)
{
roses.add(new orose(t, 6));
t += radians(360/outerrnum);
}
}
void draw()
{
background(51);
translate(width/2, height/2);
rotate(R);
for (rose rose : roses)
{
rose.show();
rose.update();
if (R > TWO_PI)
{
rose.c = color(random(359), 255, 86+51);
R = 0;
}
}
//ellipse(0, 0, 5, 5);
R += .01;
}
void keyPressed()
{
reset();
}
void reset()
{
roses = new ArrayList<rose>();
roses.add(new rose());
for (int i = 0; i < 8; i++)
{
roses.add(new orose(t, 6));
t += radians(45);
}
R = 0;
}
class orose extends rose
{
float postheta;
float posr;
orose(float t, float num)
{
theta = 0;
postheta = t;
posr = amplitude * 3;
n = num/2;
d = 2;
k = n/d;
origin = new PVector();
origin.x = posr * cos(postheta);
origin.y = posr * sin(postheta);
pos = new PVector(r * cos(theta) + origin.x, r * sin(theta) + origin.y);
}
}
class rose
{
float amplitude;
float k;
float theta;
float n;
float d;
float r;
PVector pos;
PVector origin;
PVector vel;
PVector acc;
ArrayList<PVector> history;
color c;
rose()
{
theta = 0;
n = 7;
d = 8;
k = n/d;
c = color(353, 255, 86+51);
//amplitude = (width/2) - 80;
amplitude = 100;
history = new ArrayList<PVector>();
origin = new PVector(0, 0);
r = (amplitude*cos(k*theta));
pos = new PVector(r * cos(theta) + origin.x, r * sin(theta) + origin.y);
acc = new PVector(0, 0);
vel = new PVector(0, 0);
}
void update()
{
history.add(pos.get());
r = (amplitude*cos(k*theta));
pos.x = r * cos(theta) + origin.x;
pos.y = r * sin(theta) + origin.y;
theta += radians(1);
}
void show()
{
stroke(c);
strokeWeight(3);
noFill();
beginShape();
for (PVector p : history)
{
curveVertex(p.x, p.y);
}
endShape();
fill(255);
ellipse(pos.x, pos.y, 5, 5);
fill(0);
ellipse(origin.x, origin.y, 25, 25);
if (history.size() > (d*2) * (360/2))
{
history.remove(0);
}
if (theta > d * TWO_PI)
{
//saveFrame("Rose" + k + ".png");
//history.clear();
c = color(random(359), 255, 86);
theta = 0;
}
}
void reset()
{
theta = 0;
n = 5;
d = 7;
k = n/d;
history = new ArrayList<PVector>();
origin = new PVector(0, 0);
pos = new PVector((100*cos(k*theta) * cos(theta)) + origin.x, (100*cos(k*theta) * sin(theta)) + origin.y);
}
}