var angle; function setup() { createCanvas(800, 800); colorMode(HSB, 100); } function draw() { background(0); noFill(); a = 3; b = .25; d = 1.8; stars(width/2, height/2, 4); angle = PI / 14; for (i=0; i<2*PI; i = i+2*PI/13) { push(); stroke(255); x = sin(i)*width/sqrt(2) + width/2; y = cos(i)*height/sqrt(2) + height/2; translate(x*random(0.9,1.1), y*random(0.9,1.1)); rotate(-i*random(0.9,1.1)); branch(90*random(0.6, 1.4), 1); pop(); } noLoop(); } function stars(x, y, size) { n_circle = 40; var i; for (i = 0; i < n_circle; i++) { theta = i*2*PI/11; xNew = x + a*exp(b*theta)*cos(theta)*size; yNew = y + a*exp(b*theta)*sin(theta)*size; stroke(color(i*100/n_circle, 70, 70, 50)); if (size>d) { stars(xNew, yNew, size*0.6); } else { ellipse(xNew, yNew, d, d); } } } function branch(len, generation) { // Draw the branch strokeWeight(map(generation, 1, 10, 4, .2)); if (len < 3) { stroke(color('yellow')); } line(0, 0, 0, -len); // Move to the end and shrink. translate(0, -len); len *= (.66 * random(0.9, 1.1)); generation++; if (len > .5) { //stroke(240,230,140); if (random() <.8) { push(); rotate(angle * random(1, 1.2)); branch(len, generation); pop(); } push(); rotate(- angle * random(0.8, 1)); branch(len, generation); pop(); } }