joeiddon / perlin

A JavaScript library for Perlin Noise generation
113 stars 22 forks source link

perlin.get() always returns 0 #4

Open PierBover opened 1 year ago

PierBover commented 1 year ago

I'm trying to replicate your demo but for some reason perlin.get() is always returning 0 or -0.

Is there anything obviously wrong with this?

perlin.seed();

for (var y = 0; y < 200; y += 1){
  for (var x = 0; x < 200; x += 1){
    const random = parseInt((perlin.get(x, y) / 2 + 0.5) * 255);
    context.fillStyle = `rgb(${random},${random},${random})`;
    context.fillRect(x, y, 1, 1);
  }
}
Marnix47 commented 1 year ago

I had the same issue, I solved it by (in your case) making the x and y parameters smaller. You can try dividing them by 10 or even 100, it should work then.