UNPKG

@sabre-js/sabre

Version:

A gpu accelerated ecmascript renderer for Advanced Substation Alpha (ASS) subtitles. Renders .ass and .ssa files over video in the browser.

11 lines (9 loc) 3.67 kB
(function(global,external){var window=null;var self=null;var sabre=external.$;{var p="function"==typeof Object.defineProperties?Object.defineProperty:function(b,d,e){if(b==Array.prototype||b==Object.prototype)return b;b[d]=e.value;return b};function q(b){b=["object"==typeof globalThis&&globalThis,b,"object"==typeof window&&window,"object"==typeof self&&self,"object"==typeof global&&global];for(var d=0;d<b.length;++d){var e=b[d];if(e&&e.Math==Math)return e}throw Error("Cannot find global object");}var r=q(this); function t(b,d){if(d)a:{var e=r;b=b.split(".");for(var f=0;f<b.length-1;f++){var c=b[f];if(!(c in e))break a;e=e[c]}b=b[b.length-1];f=e[b];d=d(f);d!=f&&null!=d&&p(e,b,{configurable:!0,writable:!0,value:d})}}var u="function"==typeof Object.assign?Object.assign:function(b,d){for(var e=1;e<arguments.length;e++){var f=arguments[e];if(f)for(var c in f)Object.prototype.hasOwnProperty.call(f,c)&&(b[c]=f[c])}return b};t("Object.assign",function(b){return b||u}); function v(b,d){var e=["r","g","b","a"];var f=null!=f?f:[!0,!1,!1,!1];if(f.length!==e.length)throw Error("invertChannel must be the same length as componentOrder.");var c;d=null!=(c=d)?c:8;if(1>d||32<d)throw Error("bitDepth must be between 1 and 32 (inclusive).");if(32<e.length*d)throw Error("Unable to represent color with more than 32 bits.");c={};var a,h=(1<<d)-1;for(a=0;a<e.length;a++)c[e[a]]=(b&h)/h,b>>>=d;for(a=0;a<f.length;a++)c[e[a]]=1-c[e[a]];return c} sabre.cleanRawColor=function(b){return b.replace(/^[&H]*(?:0x)?((?:[0-9a-fA-F][0-9a-fA-F])+)[&H]*/,"$1")}; sabre.SSAColor=function(b,d,e,f,c){var a={r:0,g:0,b:0,a:0};"number"===typeof b&&("number"!==typeof d?Object.assign(a,v(b,null!=c?c:8)):"number"!==typeof c?(a.r=b,a.g=d,a.b=e,a.a=f):(a.r=b/((1<<c)-1),a.g=d/((1<<c)-1),a.b=e/((1<<c)-1),a.a=f/((1<<c)-1)));return Object.create(Object,{toJSON:{value:function(){return[a.r,a.g,a.b,a.a]},writable:!1},getRGBA:{value:function(){return[a.r,a.g,a.b,a.a]},writable:!1},getRGB:{value:function(){return[a.r,a.g,a.b]},writable:!1},getR:{value:function(){return a.r}, writable:!1},getG:{value:function(){return a.g},writable:!1},getB:{value:function(){return a.b},writable:!1},getA:{value:function(){return a.a},writable:!1}})}; sabre.SSAOverrideColor=function(b,d,e,f){var c=null,a=null,h=null,k=null;"number"===typeof b&&(c=b);"number"===typeof d&&(a=d);"number"===typeof e&&(h=e);"number"===typeof f&&(k=f);return Object.create(Object,{toJSON:{value:function(){return[c,a,h,k]},writable:!1},clone:{value:function(){return new sabre.SSAOverrideColor(c,a,h,k)},writable:!1},applyOverride:{value:function(g){var l=g.getR(),m=g.getG(),n=g.getB();g=g.getA();null!==c&&(l=c);null!==a&&(m=a);null!==h&&(n=h);null!==k&&(g=k);return new sabre.SSAColor(l, m,n,g)}},getR:{value:function(){return c},writable:!1},setR:{value:function(g){return c="number"===typeof g?g:null},writable:!1},getG:{value:function(){return a},writable:!1},setG:{value:function(g){return a="number"===typeof g?g:null},writable:!1},getB:{value:function(){return h},writable:!1},setB:{value:function(g){return h="number"===typeof g?g:null},writable:!1},getA:{value:function(){return k},writable:!1},setA:{value:function(g){return k="number"===typeof g?g:null},writable:!1}})};}if(++sabre.$===19){external.$=null;sabre.$=null}})(((function(){try{return globalThis||self||window;}catch(e){try{return self;}catch(f){return window;}}})()),((function(){try{return globalThis||global||self||window;}catch(e){try{return self;}catch(f){return window;}}})()).sabre=(((function(){try{return globalThis||global||self||window;}catch(e){try{return self;}catch(f){return window;}}})()).sabre||{$:{$:0}})); //# sourceMappingURL=color.map