xxxxxxxxxx
let cellNum;
let cellSize;
let pos = [];
let img;
function preload() {
/*
pixabay
https://pixabay.com/
*/
img = loadImage("01.jpg");
}
function setup() {
createCanvas(800, 800);
noLoop();
cellNum = 50;
cellSize = width/cellNum;
image(img, 0, 0);
for (let i = 0; i < cellNum; i++) {
for (let j = 0; j < cellNum; j++) {
let x = i * cellSize + (cellSize/2);
let y = j * cellSize + (cellSize/2);
let col = color(get(x, y));
let arr = [x, y, col];
pos.push(arr);
}
}
}
function draw() {
background("#000000");
stroke("#ffffff");
for(let i=0; i<pos.length; i++){
let x = pos[i][0];
let y = pos[i][1];
let col = pos[i][2];
let hs = cellSize*0.5;
let bri = brightness(col);
let sw = map(bri, 100, 0, hs, 0);
let nScl = 0.01;
strokeWeight(sw);
if(noise(x * nScl, y * nScl) < 0.5){
// if(random(1) < 0.5){
line(x - hs, y - hs, x + hs, y + hs);
}else{
line(x - hs, y + hs, x + hs, y - hs);
}
}
}