Get() returns an empty pixels array

Hello @javagar, thank you so much for your help!
I have pixelShuffle function here by modifying a random sort algorithm, but it doesn’t seem to be working (looks like it just returns the original image). If possible, could you look at this?

function pixelShuffle(pixels) {
  pixels.loadPixels();
  for(var i = (pixels.length - 1); 0 < i; i -= 4){

    var r = Math.floor(Math.random() * (i + 1));
    var arr1 = pixels.splice(r, 4);
    var arr2 = pixels.splice(i, 4);
    pixels = pixels.concat(arr1);
    Array.prototype.splice.apply(pixels, [r, 0].concat(arr2));
  }
  pixels.updatePixels();
  return pixels;
}
1 Like