アートワーク
plainmusicのコンピのアートワークを作っています。
let colors;
function setup() {
createCanvas(1600, 1600);
colors = [color(238, 214, 191), color(217, 164, 157), color(95, 125, 130), color(209, 201, 176), color(0), color(255)];
noLoop();
}
function draw() {
background(245, 238, 224);
drawPattern();
}
function drawPattern() {
let tileSize = 100;
for (let y = 0; y < height; y += 0.89*tileSize) {
for (let x = 0; x < width; x += tileSize) {
drawTile(x, y, tileSize);
}
}
}
function drawTile(x, y, size) {
let shapes = [drawTriangle, drawSquare, drawHexagon];
let shape = random(shapes);
let col = random(colors);
shape(x, y, size, col);
}
function drawTriangle(x, y, size, col) {
fill(col);
noStroke();
let offset = random([0, HALF_PI, PI, PI + HALF_PI]);
push();
translate(x + size / 2, y + size / 2);
rotate(offset);
beginShape();
vertex(-size / 2, size / 3);
vertex(size / 2, size / 1.5);
vertex(0, -size / 3);
endShape(CLOSE);
pop();
}
function drawSquare(x, y, size, col) {
fill(col);
noStroke();
rect(x, y, size, size);
}
function drawHexagon(x, y, size, col) {
fill(col);
noStroke();
let angle = TWO_PI / 6;
push();
translate(x * size / 2, y + size / 2);
beginShape();
for (let i = 0; i < 6; i++) {
let x = size / 1.7 * cos(angle * i);
let y = size / 2 * sin(angle * i);
vertex(x, y);
}
endShape(CLOSE);
pop();
}
function drawFold(x, y, size, col) {
fill(col);
noStroke();
beginShape();
vertex(x, y);
vertex(x + size, y);
vertex(x + size * 0.8, y + size * 0.8);
vertex(x, y + size);
endShape(CLOSE);
}
function mousePressed() {
saveCanvas('geometric_pattern', 'png');
}
よろしければサポートお願いします!