title: Perlin Noise Generation
body: <p>I've been trying to get Perlin Noise generation working all day, and I'm having trouble implementing the pseudocode in <a href="https://web.archive.org/web/20160530124230/http://freespace.virgin.net/hugo.elias/models/m_perlin.htm" rel="nofollow noreferrer">this tutorial</a>. </p>
  
  <p>Similar code is shown in the answer to <a href="https://stackoverflow.com/questions/4753055/perlin-noise-generation-for-terrain">this question</a>.</p>
  
  <p>The trouble is that I have no idea what the input values for x and y are supposed to be in the <code>PerlinNoise_2D</code> function near the bottom of the Hugo Elias article (or the i and j values in the <code>Total</code> function if you're looking at the earlier Stack Overflow question).</p>
  
  <p>I have a 500 by 500 array that I'm storing my pixel values into, so at first I thought I was just supposed to loop through the <code>PerlinNoise_2D</code> (or <code>Total</code>) function for each and every pixel, but that causes me to go out of bounds of my array IMMEDIATELY, because one of the first function calls has code that uses the index <code>x - 1</code>, which of course means when I give it my first x index (0, obviously), it breaks.</p>
  
  <p>The <code>PerlinNoise_2D</code> (or <code>Total</code>) function definitely looks like the intended entry point for the Perlin class, and it also looks like the function that will give me back the values I want, but I can't for the life of me figure out what I'm supposed to be passing in, because it definitely isn't my x and y pixel array indices.</p>
  
  <p>Does anybody know what I'm supposed to be passing in here?</p>