xxxxxxxxxx
55
let h = [
[0,1,1,0,1,1,0],
[1,1,1,1,1,1,1],
[1,1,1,1,1,1,1],
[0,1,1,1,1,1,0],
[0,0,1,1,1,0,0],
[0,0,0,1,0,0,0]
]
let d = 20;
let s = 20;
let H = [];
function setup() {
createCanvas(400, 400);
cx = width/2;
cy = height/2;
makePBN();
}
function draw() {
background(22);
drawPBN();
strokeWeight(2);
line(cx,0,cx,height)
line(0,cy,width,cy)
}
function drawPBN() {
stroke(200);
strokeWeight(s);
for (p of H) {
let x = cx + p.x * s;
let y = cy + p.y * s;
point(x, y);
}
}
function makePBN() {
chy = h.length / 2;
chx = h.length / 2;
hCols = h.length;
hRows = h[0].length;
for (y = 0; y < hCols; y++) {
for (x = 0; x < hRows; x++) {
if (h[y][x] === 1) {
H.push(createVector(x - chx, y - chy));
}
}
}
}