xxxxxxxxxx
31
const cols = 40;
const rows = 40;
const scaleFactor = 50;
let img;
function preload() {
img = loadImage("heightmap.png")
img.resize(cols, rows)
img.loadPixels()
}
function setup() {
createCanvas(400, 400);
}
function draw() {
background(0);
let noise = []
// Grab the noise values from the image
for (let y = 0; y < img.height; y++) {
for (let x = 0; x < img.width; x++) {
let c = color(img.get(x, y));
let bright = (red(c) + green(c) + blue(c)) / 3;
noise.push(bright)
}
}
console.log(noise)
}