We are about to switch to a new forum software. Until then we have removed the registration on this forum.
//variable colors and leaves color background = color (255, 245, 245); //<>// color blue = color(166, 171, 214, 80); ArrayList list = new ArrayList ();
import processing.pdf.*; boolean capture; //set a boolean for recording a PDF of a single frame;
void setup() {
size(700, 700, P2D);
background (background);
smooth(8);
}
void draw() {
//if (capture) {
//beginRecord(PDF, "frame-####.pdf");
//}
for(int i = 0; i < list.size(); i++) {
list.get(i).drawball();
if(list.get(i).s - 7 < 1 && list.get(i).get) {
list.remove(i);
}
}
if (capture) { beginRecord(PDF, "frame-####.pdf"); }
// icon click if (capture) { endRecord(); capture = false; } }
void mouseClicked() { list.add(new leaves(mouseX, mouseY, random(10, 30), PI)); }
//maintain branch distinction //maybe if branches had their own colors class leaves { float x, y, s, ix, iy, d; boolean get; leaves(float ixv, float iyv, float sv, float dv) { ix=ixv; iy=iyv; s=sv; x=ix; y=iy; d=dv; }
void drawball() { noStroke(); ellipse(x, y, s, s); //fill(blue); fill( random(255), random(255), random(255), random(255)); //different shading patterns inside the dots in illustrator
x+=sin(d)*2;
y+=cos(d)*3;
get = dist(ix, iy, x, y) > 50;
if(get && s-random(0.25, .75) > 0) {
list.add(new leaves(x, y, s-10, random(PI/2, PI*1.5)));
s-=random(0.5, 1);
}
} }
void keyPressed() { //press the 's' key if you want to save a .tif in your sketch folder if (key == 's') { saveFrame("forest####.tif"); }
if (key == 'c'){ capture = true; } }
Answers
Please format your code. Edit your post (gear on top right side of any of your posts), select your code and hit ctrl+o. Leave an empty line above and below your block of code. Details here: https://forum.processing.org/two/discussion/15473/readme-how-to-format-code-and-text
Kf