xxxxxxxxxx
37
/////////////////////////////////////
// Try adjusting these variables //
// and see what happens //
/////////////////////////////////////
var number = 5000; // number of shapes to draw
var size = 100; // size of each shape
var stepSize = 1; // size of each step
var opacity = 20; // color opacity [0-255]
var animate = true; // control animation [true or false]
var time = 0;
function setup() {
createCanvas(750, 750); // create a 750 x 750 canvas
noStroke(); // disables drawing an outline
}
function draw() {
background(0); // draw black background
fill(255, opacity); // set color to white
translate(width / 2, height / 2) // move center to middle of canvas
if (animate) number = frameCount; // controls animation
var goldenAngle = PI * (3.0 - sqrt(5)); // https://en.wikipedia.org/wiki/Golden_angle
rotate(time);
for (var i = 0; i < number; i++) {
translate(0, i * stepSize); // take step forward
rotate(goldenAngle); // rotate by the golden angle
/////////////////////
// Draw the shape! //
/////////////////////
triangle(-size, 0, 0, size, size, 0); // draw a triangle
//ellipse(0, 0, size); // draw an ellipse (circle)
//rect(0, 0, size, size); // draw a rectangle
}
time += 0.001;
}