Trasformazioni geometriche
// height=300 lines=auto
let vertici = []; // vertici del poligono
function setup() {
createCanvas(670,300);
// crea 20 vertici a caso per il poligono
for (let i=0; i<20; ++i) {
vertici[i] = createVector(random(width),random(height));
}
}
function draw() {
background( 200, 4 );
// TRASFORMAZIONE GEOMETRICA ////////////////////////////////
shearX( sin(frameCount/40) / 3 );
// disegna il poligono
beginShape();
for (let i=0; i<vertici.length; ++i) {
let vert = vertici[i];
vertex( vert.x, vert.y );
}
endShape(CLOSE);
}
shearX( sin(frameCount/40) / 3 );
Attiva uno "stiramento" orizzontale delle forme che verranno disegnate in seguito. L'entità dello "stiramento" oscillerà con un andamento sinusoidale (sin(frameCount/40)).