xxxxxxxxxx
function setup(){
// creating a canvas
createCanvas(600, 600);
// function that stops the loop
noLoop();
// transparant
noFill();
//backgroung color
background(255);
}
// adjusting the number of the tiles in each horizontal and vertical plane
let tile_value = 20;
// adjusting the width of tiles
let tile_size = 600/tile_value;
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
strokeWeight(tile_size/5);
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, PI * 0.5, PI);
arc(-tile_size / 2, tile_size / 2, tile_size, tile_size, -PI * 0.5, 0);
pop();
}
}
}
function mousePressed() {
// to clear the canvas on each mouse stroke
clear();
// to draw the design again on each mouse stroke
redraw();
}