3D petals
@author
float maxRadious = 300;
PVector offset1, offset2;
float scale1 = 0.02;
float scale2 = 0.01;
color c1 = color(255);
color c2 = color(255, 77, 172);
void setup(){
size(640, 640, P3D);
noStroke();
offset1 = new PVector(random(10000), random(10000));
offset2 = new PVector(random(10000), random(10000));
}
void draw(){
background(240);
translate(width / 2, height * 3.0 / 4.0);
rotateX(PI / 4);
rotateZ(map(mouseX, 0, width, -HALF_PI, HALF_PI));
rotateX(map(mouseY, 0, height, -PI / 6, PI / 6));
float angStep = 10;
float time = frameCount * 0.01;
for(float radious = maxRadious; radious > 0; radious -= 10){
fill(lerpColor(c1, c2, radious / maxRadious));
for(float angle = 0; angle < 360; angle += angStep){
float rad1 = radians(angle);
float rad2 = radians(angle + angStep);
PVector p1 = new PVector(radious * cos(rad1), radious * sin(rad1));
PVector p2 = new PVector(radious * cos(rad2), radious * sin(rad2));
float nr1 = map(noise(p1.x * scale1 + offset1.x, p1.y * scale1 + offset1.y, time), 0, 1, -50, 50);
float nr2 = map(noise(p2.x * scale1 + offset1.x, p2.y * scale1 + offset1.y, time), 0, 1, -50, 50);
PVector np1 = new PVector((radious + nr1) * cos(rad1), (radious + nr1) * sin(rad1));
PVector np2 = new PVector((radious + nr2) * cos(rad2), (radious + nr2) * sin(rad2));
float z1 = 200 + map(noise(p1.x * scale2 + offset2.x, p1.y * scale2 + offset2.y, time), 0, 1, -100, 100);
float z2 = 200 + map(noise(p2.x * scale2 + offset2.x, p2.y * scale2 + offset2.y, time), 0, 1, -100, 100);
beginShape();
vertex(0, 0, 0);
vertex(np1.x, np1.y, z1);
vertex(np2.x, np2.y, z2);
endShape();
}
}
}