summaryrefslogtreecommitdiff
path: root/js/vendor/gif-encode/util.js
diff options
context:
space:
mode:
authorjules <jules@okfoc.us>2013-12-13 15:28:31 -0500
committerjules <jules@okfoc.us>2013-12-13 15:28:31 -0500
commit346f3a9817b1e0812565396b9811a1ce5adc97b8 (patch)
tree47944eb9a2762ef2036d140430a69be5afa9f368 /js/vendor/gif-encode/util.js
parent96fd8423cc0793d47cab9117b0167fe19041cdea (diff)
reorganize
Diffstat (limited to 'js/vendor/gif-encode/util.js')
-rw-r--r--js/vendor/gif-encode/util.js15
1 files changed, 15 insertions, 0 deletions
diff --git a/js/vendor/gif-encode/util.js b/js/vendor/gif-encode/util.js
new file mode 100644
index 0000000..92d8129
--- /dev/null
+++ b/js/vendor/gif-encode/util.js
@@ -0,0 +1,15 @@
+function shuffle(a){
+ var aa = new Array(a.length);
+ aa[0] = a[0];
+
+ for (var i = 1; i < a.length; i++) {
+ var j = Math.floor( Math.random() * i );
+ aa[i] = aa[j];
+ aa[j] = a[i];
+ }
+ return aa;
+}
+function sample(a, n) {
+ var aa = shuffle(a);
+ return aa.slice(0,n);
+}