xxxxxxxxxx
let tileCountX;
let tileCountY;
let tileWidth;
let tileHeight;
let count = 0;
let randomArr = [];
let actStrokeCap;
function setup(){
createCanvas(windowHeight, windowHeight);
colorMode(HSB,360,100,100);
background(100);
randomArr = getRandomArr(100);
actStrokeCap = PROJECT;
}
function draw() {
strokeCap(actStrokeCap);
background(100);
tileCountX = 20;
tileCountY = 20;
tileWidth = width/tileCountX;
tileHeight = height/tileCountY;
for(let i = 0; i < tileCountX; i++){
for(let k = 0; k < tileCountY; k++){
let posX = i*tileWidth;
let posY = k*tileHeight;
strokeWeight(mouseX/20);
noFill();
if(randomArr[count%100] === 0){
arc(posX,posY,2*tileWidth,2*tileHeight,0,HALF_PI);
}else if(randomArr[count%100] === 1){
arc(posX + tileWidth,posY,2*tileWidth,2*tileHeight,HALF_PI,PI);
}else if(randomArr[count%100] === 2){
arc(posX + tileWidth,posY + tileHeight,2*tileWidth,2*tileHeight,PI,PI + HALF_PI);
}else{
arc(posX,posY + tileHeight,2*tileWidth,2*tileHeight,PI + HALF_PI,0);
}
count += 1;
}
}
count = 0;
}
function getRandomArr(arrLength){
let a = []
for(let i = 0;i < arrLength; i++){
a[i] = int(random(4));
}
return a;
}
function keyReleased() {
if(key == '1') actStrokeCap = ROUND;
if(key == '2') actStrokeCap = SQUARE;
if(key == '3') actStrokeCap = PROJECT;
}