Yes, but it comes out flipped 100% of the time. I ran the train image 10 times and it was backwards (you can tell from the numbers) every single time. This is more than just chance.
Maybe that's why you don't use Javascript Math.Random() for cryptographic purposes? :-)
Shuffle function:
function doShuffle() {
var startTime = Date.now();
var pixels = shuffledImage.data;
while (shuffleStartColumn < width) {
// Pick a random column j in the range [i, width) and move it to position i.
// This Fisher-Yates shuffle is the less efficient than the Durstenfeld shuffle but more animatedly appealing.
var i = shuffleStartColumn;
var j = i + Math.floor(Math.random() * (width - i));
for (var y = 0; y < height; y++) {
for (var x = j - 1; x >= i; x--) {
var off = (y * width + x) * 4;
for (var k = 0; k < 4; k++) {
var temp = pixels[off + k];
pixels[off + k] = pixels[off + 4 + k];
pixels[off + 4 + k] = temp;
}
}
}
shuffleStartColumn++;
if (Date.now() - startTime > YIELD_AFTER_TIME)
break;
}