summaryrefslogtreecommitdiff
path: root/www/external/gifwriter.min.js
diff options
context:
space:
mode:
Diffstat (limited to 'www/external/gifwriter.min.js')
-rw-r--r--www/external/gifwriter.min.js64
1 files changed, 64 insertions, 0 deletions
diff --git a/www/external/gifwriter.min.js b/www/external/gifwriter.min.js
new file mode 100644
index 00000000..427fd50f
--- /dev/null
+++ b/www/external/gifwriter.min.js
@@ -0,0 +1,64 @@
+// (c) Dean McNamee <dean@gmail.com>, 2013.
+// //
+// // https://github.com/deanm/omggif
+// //
+// // Permission is hereby granted, free of charge, to any person obtaining a copy
+// // of this software and associated documentation files (the "Software"), to
+// // deal in the Software without restriction, including without limitation the
+// // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+// // sell copies of the Software, and to permit persons to whom the Software is
+// // furnished to do so, subject to the following conditions:
+// //
+// // The above copyright notice and this permission notice shall be included in
+// // all copies or substantial portions of the Software.
+// //
+// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+// // IN THE SOFTWARE.
+// //
+// // omggif is a JavaScript implementation of a GIF 89a encoder and decoder,
+// // including animation and compression. It does not rely on any specific
+// // underlying system, so should run in the browser, Node, or Plask.
+// Main compression routine, palette indexes -> LZW code stream.
+// |index_stream| must have at least one entry.
+"use strict"
+function _classCallCheck(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}function check_palette_and_num_colors(r){var e=r.length
+if(e<2||e>256||e&e-1)throw new Error("Invalid code/color length, must be power of 2 and 2 .. 256.")
+return e}function GifWriterOutputLZWCodeStream(r,e,t,a){function n(t){for(;s>=t;)r[e++]=255&v,v>>=8,s-=8,e===i+256&&(r[i]=255,i=e++)}function o(r){v|=r<<s,s+=c,n(8)}r[e++]=t
+var i=e++,l=1<<t,u=l-1,f=l+1,d=f+1,c=t+1,s=0,v=0,h=a[0]&u,p={}
+o(l)
+for(var w=1,g=a.length;w<g;++w){var _=a[w]&u,y=h<<8|_,m=p[y]
+if(void 0===m){for(v|=h<<s,s+=c;s>=8;)r[e++]=255&v,v>>=8,s-=8,e===i+256&&(r[i]=255,i=e++)
+4096===d?(o(l),d=f+1,c=t+1,p={}):(d>=1<<c&&++c,p[y]=d++),h=_}else h=m}return o(h),o(f),n(1),i+1===e?r[i]=0:(r[i]=e-i-1,r[e++]=0),e}var GifWriter=function(){function r(e,t,a){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{}
+_classCallCheck(this,r)
+var o=n.loop,i=n.palette,l=0,u=[],f=i
+if(t<=0||a<=0||t>65535||a>65535)throw new Error("Width/Height invalid.")
+u[l++]=71,u[l++]=73,u[l++]=70,u[l++]=56,u[l++]=57,u[l++]=97
+var d=0,c=0
+if(f){for(var s=check_palette_and_num_colors(f);s>>=1;)++d
+if(s=1<<d,d--,void 0!==n.background){if(c=n.background,c>=s)throw new Error("Background index out of range.")
+if(0===c)throw new Error("Background index explicitly passed as 0.")}}if(u[l++]=255&t,u[l++]=t>>8&255,u[l++]=255&a,u[l++]=a>>8&255,u[l++]=(f?128:0)|d,u[l++]=c,u[l++]=0,f)for(var v=f,h=Array.isArray(v),p=0,v=h?v:v[Symbol.iterator]();;){var w
+if(h){if(p>=v.length)break
+w=v[p++]}else{if(p=v.next(),p.done)break
+w=p.value}var g=w
+u[l++]=g>>16&255,u[l++]=g>>8&255,u[l++]=255&g}if(Number.isInteger(o)){if(o<0||o>65535)throw"Loop count invalid."
+u[l++]=33,u[l++]=255,u[l++]=11,u[l++]=78,u[l++]=69,u[l++]=84,u[l++]=83,u[l++]=67,u[l++]=65,u[l++]=80,u[l++]=69,u[l++]=50,u[l++]=46,u[l++]=48,u[l++]=3,u[l++]=1,u[l++]=255&o,u[l++]=o>>8&255,u[l++]=0}var _=this,y=e.getReader()
+return new ReadableStream({start:function(r){r.enqueue(new Uint8Array(u))},pull:function(r){return y.read().then(function(e){var t=e.done,a=e.value
+return t?(r.enqueue(new Uint8Array([59])),void r.close()):void _.addFrame.apply(_,[r].concat(a))})}})}return r.prototype.addFrame=function(r,e,t,a,n,o){var i=arguments.length>6&&void 0!==arguments[6]?arguments[6]:{},l=0,u=[]
+if(e<0||t<0||e>65535||t>65535)throw new Error("x/y invalid.")
+if(a<=0||n<=0||a>65535||n>65535)throw"Width/Height invalid."
+if(o.length<a*n)throw"Not enough pixels for the frame size."
+var f=!0,d=i.palette
+if(void 0!==d&&null!==d||(f=!1,d=global_palette),void 0===d||null===d)throw"Must supply either a local or global palette."
+for(var c=check_palette_and_num_colors(d),s=0;c>>=1;)++s
+c=1<<s
+var v=void 0===i.delay?0:i.delay,h=void 0===i.disposal?0:i.disposal
+if(h<0||h>3)throw"Disposal out of range."
+var p=!1,w=0
+if(void 0!==i.transparent&&null!==i.transparent&&(p=!0,w=i.transparent,w<0||w>=c))throw"Transparent color index."
+if((0!==h||p||0!==v)&&(u[l++]=33,u[l++]=249,u[l++]=4,u[l++]=h<<2|(p===!0?1:0),u[l++]=255&v,u[l++]=v>>8&255,u[l++]=w,u[l++]=0),u[l++]=44,u[l++]=255&e,u[l++]=e>>8&255,u[l++]=255&t,u[l++]=t>>8&255,u[l++]=255&a,u[l++]=a>>8&255,u[l++]=255&n,u[l++]=n>>8&255,u[l++]=f===!0?128|s-1:0,f===!0)for(var g=0,_=d.length;g<_;++g){var y=d[g]
+u[l++]=y>>16&255,u[l++]=y>>8&255,u[l++]=255&y}GifWriterOutputLZWCodeStream(u,l,s<2?2:s,o),r.enqueue(new Uint8Array(u))},r}()