xxxxxxxxxx
114
// Convert Simple shapes to a face
//
// Ewan Klein
// ewan@prewired.org
//
// background;
let bgB = 220;
// line
let lineX0 = 100;
let lineY0 = 5;
let lineX1 = 100;
let lineY1 = 400;
let lineA = 255;
let lineIncr = 5;
// ellipse
let ellWidth = 80;
let ellHeight = 80;
// rectangle
let rectX = 100;
let rectY = 60;
let rectW = 60;
let rectH = 100;
let rectA = 0;
// triangle
let tri0A = 255
let tri1A = 0;
function setup() {
createCanvas(400, 400);
frameRate(20);
rectMode(CENTER);
// save();
}
function draw() {
angleMode(DEGREES);
background(220, 220, bgB);
if (bgB > 99) {
bgB = bgB - 0.5;
}
noStroke();
// ellipse
fill(0, 255, 0);
ellipse(200, 240, ellWidth, ellHeight);
if (ellWidth < 350) {
ellWidth += 3;
}
if (ellHeight < 400) {
ellHeight += 3;
}
// line
stroke(255, 0, 255, lineA);
if (lineA > 0) {
lineA -= lineIncr;
}
strokeWeight(5);
line(lineX0, lineY0, lineX1, lineY1);
if (lineX1 < 150) {
lineX1 += lineIncr;
}
if (lineY1 > 300) {
lineY1 -= lineIncr;
}
if (lineX0 < 250) {
lineX0 += lineIncr;
}
if (lineY0 < 300) {
lineY0 += lineIncr;
}
noStroke();
fill(255, 100, 0);
rect(rectX, rectY, rectW, rectH);
if (rectY < 150) {
rectY = rectY + 1;
}
if (rectH > 20) {
rectH -= 1;
}
fill(255, 100, 0, rectA);
rect(250, 150, 60, 20);
if (rectA < 255) {
rectA += 2.5;
}
// triangle
fill(0, 0, 255, tri0A);
triangle(250, 250, 390, 250, 310, 80);
if (tri0A > 0) {
tri0A -= 5;
}
fill(0, 0, 255, rectA);
triangle(150, 300, 230, 300, 200, 180);
// arc
angleMode(RADIANS);
fill(255, 0, 255, rectA);
arc(200, 330, 150, 60, TWO_PI, PI);
}