xxxxxxxxxx
59
//Here is my work using techniques learned, making a grid-based artwork which is inspired by halloween theme.
let rot = 0;
function setup() {
createCanvas(400, 400);
rectMode(CENTER);
noStroke();
}
function draw() {
background(30, 20, 50);
let colors = [color(255, 165, 0), color(0, 0, 0), color(128, 0, 128), color(0, 255, 0), color(139, 0, 0), color(0, 100, 255)];
for (let y = 0; y < 4; y++) {
for (let x = 0; x < 4; x++) {
push();
translate(x * 100 + 50, y * 100 + 50);
rotate(rot + noise(x, y) * TWO_PI);
let randomColor = random(colors);
fill(randomColor);
let shapeType = int(random(3));
if (shapeType === 0) {
ellipse(0, 0, 60, 80);
fill(0);
triangle(-15, -10, -5, -10, -10, -5);
triangle(5, -10, 15, -10, 10, -5);
arc(0, 10, 20, 10, 0, PI);
}
else if (shapeType === 1) {
let ghostSize = map(sin(25), -1, 1, 40, 70);
arc(0, 0, ghostSize, ghostSize, PI, TWO_PI);
} else if (shapeType === 2) {
triangle(-25, 25, 0, -25, 25, 25);
fill(255, 255, 0);
rect(0, 20, 30, 10);
}
pop();
}
}
rot += 0.01;
}