xxxxxxxxxx
// canvas size and colors
var cols = 4;
var rows = 5;
var colors = ['#d6b475', '#b3a58a', '#5d4f46', '#c8b592'];
var bgColor = '#f5e9da';
var titleF;
function preload() {
serathinedemo = loadFont('Serathine Demo.ttf');
}
function setup() {
createCanvas(500, 700); // Canvas Size
noLoop();
}
function draw() {
background(bgColor); // background color
// canvas width and height
let w = width / cols;
let h = (height - 100) / rows;
for (let y = 0; y < rows; y++) {
for (let x = 0; x < cols; x++) {
let colorIndex = int(random(colors.length));
let cellColor = colors[colorIndex];
// borders for circles
push();
translate(x * w, y * h); // Hücreyi pozisyonla
fill(cellColor);
noStroke();
// semi circles
arc(0, 0, w * 2, h * 2, 0, HALF_PI);
arc(w, 0, w * 2, h * 2, HALF_PI, PI);
arc(0, h, w * 2, h * 2, -HALF_PI, 0);
arc(w, h, w * 2, h * 2, PI, PI + HALF_PI);
stroke(255);
strokeWeight(3);
noFill();
arc(0, 0, w * 1.6, h * 1.6, 0, HALF_PI);
arc(w, 0, w * 1.6, h * 1.6, HALF_PI, PI);
arc(0, h, w * 1.6, h * 1.6, -HALF_PI, 0);
arc(w, h, w * 1.6, h * 1.6, PI, PI + HALF_PI);
pop();
}
}
// Title ıntermezzo
fill(50);
textSize(55);
textFont(serathinedemo);
textAlign(CENTER, CENTER);
text("Intermezzo", width / 2, height - 80);
textSize(20);
textFont(serathinedemo);
text("by Sally Rooney", 370, height -40);
}
// keybord functions
function keyPressed() {
if (key === 'S') {
saveCanvas('poster', 'jpg'); // s = jpg
}
else if (key === 'R') {
redraw(); // redraw elements with random colors when pressing R
}
}