@rive-app/canvas-advanced 2.8.1 → 2.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/canvas_advanced.mjs +1 -1
- package/package.json +1 -1
package/canvas_advanced.mjs
CHANGED
|
@@ -11,7 +11,7 @@ function ca(){function b(m){const l=d;c=a=0;d=new Map;l.forEach(n=>{try{n(m)}cat
|
|
|
11
11
|
function da(b){console.assert(!0);const a=new Map;let c=-Infinity;this.push=function(d){d=d+((1<<b)-1)>>b;a.has(d)&&clearTimeout(a.get(d));a.set(d,setTimeout(function(){a.delete(d);0==a.length?c=-Infinity:d==c&&(c=Math.max(...a.keys()),console.assert(c<d))},1E3));c=Math.max(d,c);return c<<b}}
|
|
12
12
|
const ea="createConicGradient createImageData createLinearGradient createPattern createRadialGradient getContextAttributes getImageData getLineDash getTransform isContextLost isPointInPath isPointInStroke measureText".split(" "),fa=new function(){function b(){if(!a){var f=document.createElement("canvas"),r={alpha:1,depth:0,stencil:0,antialias:0,premultipliedAlpha:1,preserveDrawingBuffer:0,preferLowPowerToHighPerformance:0,failIfMajorPerformanceCaveat:0,enableExtensionsByDefault:1,explicitSwapControl:1,
|
|
13
13
|
renderViaOffscreenBackBuffer:1};let q=f.getContext("webgl2",r);if(q)c=2;else if(q=f.getContext("webgl",r))c=1;else return console.log("No WebGL support. Image mesh will not be drawn."),!1;q=new Proxy(q,{get(D,u){if(D.isContextLost()){if(n||(console.error("Cannot render the mesh because the GL Context was lost. Tried to invoke ",u),n=!0),"function"===typeof D[u])return function(){}}else return"function"===typeof D[u]?function(...I){return D[u].apply(D,I)}:D[u]},set(D,u,I){if(D.isContextLost())n||(console.error("Cannot render the mesh because the GL Context was lost. Tried to set property "+
|
|
14
|
-
u),n=!0);else return D[u]=I,!0}});d=Math.min(q.getParameter(q.MAX_RENDERBUFFER_SIZE),q.getParameter(q.MAX_TEXTURE_SIZE));function G(D,u,I){u=q.createShader(u);q.shaderSource(u,I);q.compileShader(u);I=q.getShaderInfoLog(u);if(0<I
|
|
14
|
+
u),n=!0);else return D[u]=I,!0}});d=Math.min(q.getParameter(q.MAX_RENDERBUFFER_SIZE),q.getParameter(q.MAX_TEXTURE_SIZE));function G(D,u,I){u=q.createShader(u);q.shaderSource(u,I);q.compileShader(u);I=q.getShaderInfoLog(u);if(0<(I||"").length)throw I;q.attachShader(D,u)}f=q.createProgram();G(f,q.VERTEX_SHADER,"attribute vec2 vertex;\n attribute vec2 uv;\n uniform vec4 mat;\n uniform vec2 translate;\n varying vec2 st;\n void main() {\n st = uv;\n gl_Position = vec4(mat2(mat) * vertex + translate, 0, 1);\n }");
|
|
15
15
|
G(f,q.FRAGMENT_SHADER,"precision highp float;\n uniform sampler2D image;\n varying vec2 st;\n void main() {\n gl_FragColor = texture2D(image, st);\n }");q.bindAttribLocation(f,0,"vertex");q.bindAttribLocation(f,1,"uv");q.linkProgram(f);r=q.getProgramInfoLog(f);if(0<(r||"").trim().length)throw r;e=q.getUniformLocation(f,"mat");g=q.getUniformLocation(f,"translate");q.useProgram(f);q.bindBuffer(q.ARRAY_BUFFER,q.createBuffer());
|
|
16
16
|
q.enableVertexAttribArray(0);q.enableVertexAttribArray(1);q.bindBuffer(q.ELEMENT_ARRAY_BUFFER,q.createBuffer());q.uniform1i(q.getUniformLocation(f,"image"),0);q.pixelStorei(q.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0);a=q}return!0}let a=null,c=0,d=0,e=null,g=null,m=0,l=0,n=!1;b();this.Mb=function(){b();return d};this.vb=function(f){if(!b())return null;const r=a.createTexture();if(!r)return null;a.bindTexture(a.TEXTURE_2D,r);a.texImage2D(a.TEXTURE_2D,0,a.RGBA,a.RGBA,a.UNSIGNED_BYTE,f);a.texParameteri(a.TEXTURE_2D,
|
|
17
17
|
a.TEXTURE_WRAP_S,a.CLAMP_TO_EDGE);a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_T,a.CLAMP_TO_EDGE);a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MAG_FILTER,a.LINEAR);2==c?(a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,a.LINEAR_MIPMAP_LINEAR),a.generateMipmap(a.TEXTURE_2D)):a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,a.LINEAR);return r};const k=new da(8),t=new da(8),v=new da(10),x=new da(10);this.Ab=function(f,r,q,G,D){if(b()){var u=k.push(f),I=t.push(r);if(a.canvas){if(a.canvas.width!=u||a.canvas.height!=
|