Lots of tuning, lots of variants, one result. Horrible code by the way.
// Triangles
let t = [];
let rSpeed;
let fSpeed= 0.01;
function setup() {
createCanvas(400, 400);
rSpeed = 0;
t[0] = new Triangle(width/2, height/2, width/2, 0, 0);
t[1] = new Triangle(width/2, height/2, width/2, PI/3, 1);
t[2] = new Triangle(width/2, height/2, width/2, 1*PI/6, 2);
t[3] = new Triangle(width/2, height/2, width/2, 3*PI/6, 3);
t[4] = new Triangle(width/2, height/2, width/4, 0, 0);
t[5] = new Triangle(width/2, height/2, width/4, PI/3, 1);
t[6] = new Triangle(width/2, height/2, width/4, 1*PI/6, 2);
t[7] = new Triangle(width/2, height/2, width/4, 3*PI/6, 3);
t[8] = new Triangle(width/2, height/2, width/8, 0, 0);
t[9] = new Triangle(width/2, height/2, width/8, PI/3, 1);
t[10] = new Triangle(width/2, height/2, width/8, 1*PI/6, 2);
t[11] = new Triangle(width/2, height/2, width/8, 3*PI/6, 3);
noFill();
}
function draw() {
//for(i = 0; i < t.length; i++){
for(i = t.length-1; i >= 0; i--){
t[i].pulse(cos(frameCount*fSpeed)*t[i].rMax);
t[i].display();
t[i].rotate(rSpeed/(t[i].c+1));
}
point(width/2, height/2);
}
class Triangle{
constructor(cX,cY,rMax,a,c){
this.cX = cX;
this.cY = cY;
this.a1 = PI/2 + a;
this.a2 = -PI/6 + a;
this.a3 = PI/2 + PI/2 + PI/6 + a;
this.rMax = rMax;
this.c = c;
}
display(){
var p1x = this.cX + cos(this.a1) * this.r;
var p1y = this.cY - sin(this.a1) * this.r;
var p2x = this.cX + cos(this.a2) * this.r;
var p2y = this.cY - sin(this.a2) * this.r;
var p3x = this.cX + cos(this.a3) * this.r;
var p3y = this.cY - sin(this.a3) * this.r;
stroke(200 + sin(frameCount*0.01)*50);
triangle(p1x, p1y, p2x, p2y, p3x, p3y);
point(this.cX, this.cY);
}
pulse(dr){
this.r = dr;
}
rotate(a){
this.a1 += a;
this.a2 += a;
this.a3 += a;
}
}
function updateRSpeed(){
background(255);
rSpeed = slider.value();
}
Deja una respuesta