xxxxxxxxxx
49
p5.disableFriendlyErrors = true; // disables FES
let numTri = 182;
let x1, y1, x2, y2, x3, y3;
let hu = 0;
let cshift = .3;
let size = 22;
function setup() {
createCanvas(windowWidth, screen.availHeight);
background(0);
colorMode(HSB, 255);
x1 = width * 0.38;
y1 = height * 0.34; // center of figure
stroke(0, 50);
// first take the draw internal loop over t to the outside.
// speed would be by framerate.
//noLoop();
frameRate(10);
}
let t = 380,
dt = -20;
let numTrii = 1;
function draw() {
//ellipse(mouseX, mouseY, 20, 20);
let theta = 0;
// for (t = 380; t > 10; t -= 20){
hu = 0;
size = 22 * t / 200;
for (i = numTrii - 1; i > 0; i--) { // draw the triangles
radius = sqrt(i + 1);
let x2 = x1 + radius * cos(theta) * size;
let y2 = y1 + radius * sin(theta) * size;
radius = sqrt(i);
theta += atan2(1, radius) / 4;
let x3 = x1 + radius * cos(theta) * size;
let y3 = y1 + radius * sin(theta) * size
fill(hu, 255, 255);
triangle(x1, y1, x2, y2, x3, y3);
hu += 1.3;
}
if ( numTrii < numTri ) numTrii +=1;
if ( t > 20 ) t -= dt;
// }
}