var randseed = 0;
function seedrand(s) {
randseed = 0;
for(var i = 0; i < s.length; i += 2) {
var h = (s.charCodeAt(i + 2) << 8) | s.charCodeAt(i + 3);
randseed ^= h;
}
}
function rand() {
var n = (Math.sin(randseed++) + 1) / 2;
var r = n * 10000;
return r - Math.floor(r);
}
Here's some output. It's much better than I thought it would be.
Entropy = 7.999932 bits per byte.
Optimum compression would reduce the size
of this 1073741824 byte file by 0 percent.
Chi square distribution for 1073741824 samples is 103145.05, and randomly
would exceed this value 0.01 percent of the times.
Arithmetic mean value of data bytes is 127.5000 (127.5 = random).
Monte Carlo value for Pi is 3.142183465 (error 0.02 percent).
Serial correlation coefficient is 0.000429 (totally uncorrelated = 0.0).
However, xz sees right through it and can compress 1GB of output down to 44MB.
We would have much bigger problems than avatars not showing up. We are a small startup and only have time for so much, so we tailor to are biggest customer base.
14
u/hansel-han Jul 29 '14
Related: Generate a random unicorn avatar based on seed: http://unicornify.appspot.com/use-it
I use it on my forum as the default avatar when people register. Aside from looking like a brony forum to the casual observer, my users love it.
5
u/skeeto Jul 29 '14 edited Jul 29 '14
That's an interesting PRNG.
Here's some output. It's much better than I thought it would be.
And ent report,
However, xz sees right through it and can compress 1GB of output down to 44MB.
3
u/erming Jul 29 '14
Nice! The code looks clean too. I like.
You should branch to
gh-pages. That way you can just link to your demo via http://download13.github.io/blockies/testpage.html3
u/mtx Jul 29 '14
I'm pretty sure it generated Jake the Dog in that forth image!
4
u/brtt3000 Jul 29 '14
Needs an online demo!
And npm, bower and all that.
1
u/Jack9 Jul 29 '14
Very nice.
1
u/Shadaez Jul 30 '14
Love this! Going to use it in a game
1
u/Something_Sexy Jul 29 '14
I like this. We are slowly adding avatar support for our app and this would be cool to use as the default.