xxxxxxxxxx
121
let colArray = []; //make an empty array
let label = "letter-h-poster";
function setup() {
createCanvas(600, 850);
//define color in the array
colArray[0] = color("#d80e0e");
colArray[1] = color("#fecc45");
colArray[2] = color("#00b1ff");
colArray[3] = color("#01ac6f");
colArray[3] = color("#c647bb");
frameRate(3); //lower the frame rate
}
function draw() {
background(255, 255, 255);
translate(35, 150);
//star
push();
strokeWeight(0.1);
star(20, -20, 50, 250, 20, 100);
pop();
endShape(CLOSE);
push();
strokeWeight(0.1);
rotate(radians(frameCount) * 0.5);
star(350, 600, 50, 250, 20, 100);
pop();
endShape(CLOSE);
push();
textSize(25);
text("is for", 250, 600);
pop();
push();
textSize(50);
text("HELP!", 210, 660);
pop();
push();
fill(random(colArray));
rect(0, 0, 220, 80, 0, 80, 0, 80);
fill(random(colArray));
rect(0, 0, 220, 40, 0, 80, 0, 80);
pop();
push();
fill(random(colArray));
rect(70, 80, 80, 380);
fill(random(colArray));
rect(70, 80, 40, 380);
pop();
push();
fill(random(colArray));
rect(0, 460, 220, 80, 80, 80, 0, 0);
fill(random(colArray));
rect(0, 460, 220, 40, 80, 80, 0, 0);
pop();
push();
fill(random(colArray));
rect(160, 222, 230, 80);
fill(random(colArray));
rect(160, 222, 230, 40);
pop();
push();
fill(random(colArray));
rect(390, 80, 80, 380);
fill(random(colArray));
rect(390, 80, 40, 380);
pop();
push();
fill(random(colArray));
rect(320, 0, 220, 80, 0, 80, 0, 80);
fill(random(colArray));
rect(320, 0, 220, 40, 0, 80, 0, 80);
pop();
push();
fill(random(colArray));
rect(320, 460, 220, 80, 80, 80, 0, 0);
fill(random(colArray));
rect(320, 460, 220, 40, 80, 80, 0, 0);
pop();
}
function star(x, y, radius1, radius2, npoints) {
let angle = TWO_PI / npoints;
let halfAngle = angle / 2.0;
beginShape();
for (let a = 0; a < TWO_PI; a += angle) {
let sx = x + cos(a) * radius2;
let sy = y + sin(a) * radius2;
vertex(sx, sy);
sx = x + cos(a + halfAngle) * radius1;
sy = y + sin(a + halfAngle) * radius1;
vertex(sx, sy);
}
}
function keyPressed() {
if (key === "s") {
if (this._renderer.elt.svg !== undefined) {
saveSVG(label + ".svg");
} else {
saveCanvas(label + ".png");
}
}
}
let isShowGrid = false;