Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perlin.get() always returns 0 #4

Open
PierBover opened this issue Apr 10, 2023 · 1 comment
Open

perlin.get() always returns 0 #4

PierBover opened this issue Apr 10, 2023 · 1 comment

Comments

@PierBover
Copy link

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
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants