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);
strokeWeight(16);
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;
if(randomArr[count%100] === 0){
strokeWeight(mouseX/20);
line(posX, posY, posX + tileWidth, posY + tileHeight);
}else{
strokeWeight(mouseY/20);
line(posX, posY + tileHeight, posX + tileWidth, posY);
}
count += 1;
}
}
count = 0;
}
function getRandomArr(arrLength){
let a = []
for(let i = 0;i < arrLength; i++){
a[i] = int(random(2));
}
return a;
}
function keyReleased() {
if(key == '1') actStrokeCap = ROUND;
if(key == '2') actStrokeCap = SQUARE;
if(key == '3') actStrokeCap = PROJECT;
}