xxxxxxxxxx
function setup(){
// creating a canvas
createCanvas(600, 600);
// function that stops the loop
noLoop();
// transparant
noFill();
//backgroung color
background(255);
rectMode(CENTER);
}
// adjusting the number of the tiles in each horizontal and vertical plane
let tile_value = 5;
// adjusting the width of tiles
let tile_size = 600/tile_value;
let sr = 0;
let sg = 0;
let sb = 0;
function draw(){
// nested loop for creating a tile with designs
for(i=0;i<tile_value+1; i++){
for(j=0;j<tile_value+1; j++){
//determining the strokeweight
stroke(sr, sg, sb);
strokeWeight(tile_size/6);
push();
//to displace the tiles
translate(i*tile_size,j*tile_size);
// to rotate the tiles randomly with times of 90 degrees
rotate(floor(random(1,4))*PI*0.5);
//drawing arc
arc(tile_size/ 2, -tile_size / 2, tile_size, tile_size, QUARTER_PI, PI);
arc(-tile_size / 2, tile_size / 2, tile_size, tile_size, -PI * 0.5, HALF_PI);
fill(color(0,0,0,0));
stroke('#757373');
strokeWeight(tile_size/20);
rect(tile_size/2,tile_size/2,tile_size/8);
pop();
}
}
}
function keyPressed() {
if(key == 'r') {
clear();
draw();
}
if(key == 's') {
save('test.jpg');
}
if(key == 't') {
sr = random(0, 255);
sg = random(0, 255);
sb = random(0, 255);
clear();
draw();
}
}