Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You need to use a pseudo random number generator (PRNG), with a fixed start seed. The Math.random method in javascript is a PRNG, but you can't set the seed like you can in other languages.</p> <p>A PRNG is reasonably simple to create - lots of code on the internet. Given a fixed start seed it will always generate the same sequence of random numbers, which is what you're asking for.</p> <p>Whether those colors look pleasing or not, is <a href="https://stackoverflow.com/questions/43044/coloring-algorithm">another question entirely</a>...</p> <p>One javascript implementation with seeding capability:<br> <a href="http://www.erikoest.dk/rng2.htm" rel="nofollow noreferrer">http://www.erikoest.dk/rng2.htm</a></p> <p>You'll also find C implementations (easy to convert to javascript) and other details of building your own PRNG of the Lehmer type here:<br> <a href="http://www.google.com/search?q=Lehmer%20random%20number%20generator" rel="nofollow noreferrer">http://www.google.com/search?q=Lehmer%20random%20number%20generator</a></p> <p>Another one with code (<a href="http://en.wikipedia.org/wiki/Mersenne_Twister" rel="nofollow noreferrer">Mersenne twister</a>):<br> <a href="http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/VERSIONS/JAVASCRIPT/java-script.html" rel="nofollow noreferrer">http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/VERSIONS/JAVASCRIPT/java-script.html</a></p> <p>This question covers several types of PRNG in javascript:<br> <a href="https://stackoverflow.com/questions/424292/how-to-create-my-own-javascript-random-number-generator-that-i-can-also-set-the-s">Seedable JavaScript random number generator</a></p> <p>If you give the same starting seed to the PRNG at the beginning of the function, it will always return the same number sequence with each successive call.</p> <p>Convert that number into a color, and you're all set.</p> <p>-Adam</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload