Hello,
I wanna try to set specific pixels, but only when the 2d-array position has an “x”. What do I wrong? I cant find the mistake I do
//this will store the crap-mountain
var data = {};
function preload() {
data = loadJSON('assets/mountain.json');
}
var mountainTest = Array(100).fill(0).map(() => Array(100).fill("0"));
function setup() {
createCanvas(100,100);
background(0);
mountainTest[50][88].fill("x");// = "x";
mountainTest[49][98] = "x";
mountainTest[50][99] = "x";
mountainTest[49][99] = "x";
mountainTest[51][99] = "x";
}
function draw() {
let black = color(255, 102, 204);
let img = createImage(100, 100);
img.loadPixels();
for (let i = 0; i < img.width; i++) {
for (let j = 0; j < img.height; j++) {
//if(mountainTest[i][j] == 'x'){
//console.log(mountainTest[50][88]);
img.set(i, j, color(0, 90, 102));
//}
}
}
img.updatePixels();
//save(img, 'asstes/mountain.json');
image(img,0,0);
}
Thanks a lot for helping!
+aeh