Emma Paviota – Geometric Typography

Ho provato a realizzare la lettera E inserendo anche un movimento delle aste che la compongono.

let rectW = 200; // lunghezza aste esterne
let rectW2 = 100; // lunghezza asta interna
let rectH = 70; // alstezza aste

//lunghezze iniziali delle aste
let startW1 = 200;
let startW2 = 100;

let dir = 1; // direzione unica
let maxW = 300; // lunghezza massima comune

function setup() {
createCanvas(400, 400);
}

function draw() {
background(0);

fill(100, rectW2, rectW);
rect(100, 57, rectW, rectH);
rect(100, 165, rectW2, rectH);
rect(100, 273, rectW, rectH);

// movimento sincronizzato
rectW += 1 * dir;
rectW2 += 1 * dir;

// inversione ai limiti
if (dir === 1 && rectW >= maxW) {
dir = -1; // iniziano a tornare indietro
}

if (dir === -1 && rectW <= startW1) {
// quando tornano alla lunghezza iniziale ripartono
dir = 1;
rectW = startW1;
rectW2 = startW2;
}
}

Commenti

Lascia un commento