ranuts 0.4.1-alpha.2 → 0.5.0
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/CLAUDE.md +23 -16
- package/README.de.md +62 -0
- package/README.es.md +62 -0
- package/README.fa.md +62 -0
- package/README.ja.md +62 -0
- package/README.ko.md +62 -0
- package/README.md +35 -92
- package/README.pt.md +62 -0
- package/README.zh-CN.md +35 -91
- package/dist/iife/index.iife.js +4 -0
- package/dist/iife/utils.iife.js +4 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +306 -1
- package/dist/src/_virtual/_rolldown/runtime/index.js +12 -0
- package/dist/src/conversation/engine.d.ts +1 -1
- package/dist/src/conversation/engine.js +101 -0
- package/dist/src/conversation/index.d.ts +3 -3
- package/dist/src/conversation/index.js +4 -1
- package/dist/src/stream/accumulator.d.ts +1 -1
- package/dist/src/stream/accumulator.js +79 -0
- package/dist/src/stream/budget.d.ts +1 -1
- package/dist/src/stream/budget.js +45 -0
- package/dist/src/stream/index.d.ts +7 -7
- package/dist/src/stream/index.js +11 -1
- package/dist/src/stream/sse.d.ts +1 -1
- package/dist/src/stream/sse.js +61 -0
- package/dist/src/sw/index.js +52 -1
- package/dist/src/utils/async.js +49 -0
- package/dist/src/utils/audioRecorder.js +1121 -0
- package/dist/src/utils/behavior.js +9 -0
- package/dist/src/utils/binary.js +89 -0
- package/dist/src/utils/bom.d.ts +31 -9
- package/dist/src/utils/bom.js +165 -0
- package/dist/src/utils/bridge.js +310 -0
- package/dist/src/utils/canvas.js +103 -0
- package/dist/src/utils/chain.js +76 -0
- package/dist/src/utils/color.d.ts +0 -1
- package/dist/src/utils/color.js +312 -0
- package/dist/src/utils/compose.js +22 -0
- package/dist/src/utils/console.js +22 -0
- package/dist/src/utils/debounce.js +18 -0
- package/dist/src/utils/device.d.ts +0 -9
- package/dist/src/utils/device.js +31 -0
- package/dist/src/utils/diff.js +110 -0
- package/dist/src/utils/dom.d.ts +1 -1
- package/dist/src/utils/dom.js +89 -0
- package/dist/src/utils/error.js +11 -0
- package/dist/src/utils/event.d.ts +3 -3
- package/dist/src/utils/event.js +39 -0
- package/dist/src/utils/file.js +14 -0
- package/dist/src/utils/func.js +4 -0
- package/dist/src/utils/i18n/index.js +79 -1
- package/dist/src/utils/idb.js +177 -0
- package/dist/src/utils/img.d.ts +1 -1
- package/dist/src/utils/img.js +68 -0
- package/dist/src/utils/index.d.ts +80 -80
- package/dist/src/utils/index.js +306 -1
- package/dist/src/utils/lang.d.ts +23 -6
- package/dist/src/utils/lang.js +42 -0
- package/dist/src/utils/localePath.js +48 -0
- package/dist/src/utils/memoize.d.ts +1 -7
- package/dist/src/utils/memoize.js +16 -0
- package/dist/src/utils/mimeType.js +841 -0
- package/dist/src/utils/monitor.js +84 -0
- package/dist/src/utils/network.js +117 -0
- package/dist/src/utils/noop.js +5 -0
- package/dist/src/utils/number.js +185 -0
- package/dist/src/utils/obj.d.ts +2 -2
- package/dist/src/utils/obj.js +140 -0
- package/dist/src/utils/paginate.js +93 -0
- package/dist/src/utils/performance.js +26 -0
- package/dist/src/utils/placement.js +37 -0
- package/dist/src/utils/prefetch.js +69 -0
- package/dist/src/utils/queue.js +46 -0
- package/dist/src/utils/report.js +44 -0
- package/dist/src/utils/request.js +35 -0
- package/dist/src/utils/script.d.ts +1 -1
- package/dist/src/utils/script.js +46 -0
- package/dist/src/utils/scroll.js +62 -0
- package/dist/src/utils/secure.js +36 -0
- package/dist/src/utils/segment.js +43 -0
- package/dist/src/utils/signal.d.ts +1 -1
- package/dist/src/utils/signal.js +13 -0
- package/dist/src/utils/speech.js +59 -0
- package/dist/src/utils/storage.js +53 -0
- package/dist/src/utils/str.d.ts +0 -6
- package/dist/src/utils/str.js +395 -0
- package/dist/src/utils/style.js +29 -0
- package/dist/src/utils/subscribe.js +58 -0
- package/dist/src/utils/throttle.js +17 -0
- package/dist/src/utils/time.d.ts +0 -21
- package/dist/src/utils/time.js +97 -0
- package/dist/src/utils/totp/sha/common.d.ts +1 -1
- package/dist/src/utils/totp/sha/common.js +201 -0
- package/dist/src/utils/totp/sha/converters.d.ts +1 -1
- package/dist/src/utils/totp/sha/converters.js +188 -0
- package/dist/src/utils/totp/sha/primitives_32.js +55 -0
- package/dist/src/utils/totp/sha/primitives_64.js +85 -0
- package/dist/src/utils/totp/sha/sha.d.ts +1 -1
- package/dist/src/utils/totp/sha/sha.js +30 -0
- package/dist/src/utils/totp/sha/sha1.d.ts +2 -2
- package/dist/src/utils/totp/sha/sha1.js +51 -0
- package/dist/src/utils/totp/sha/sha256.d.ts +2 -2
- package/dist/src/utils/totp/sha/sha256.js +56 -0
- package/dist/src/utils/totp/sha/sha3.d.ts +3 -3
- package/dist/src/utils/totp/sha/sha3.js +253 -0
- package/dist/src/utils/totp/sha/sha512.d.ts +3 -3
- package/dist/src/utils/totp/sha/sha512.js +177 -0
- package/dist/src/utils/totp/totp.js +49 -0
- package/dist/src/utils/tween.js +59 -0
- package/dist/src/utils/visual/application.d.ts +4 -4
- package/dist/src/utils/visual/application.js +42 -0
- package/dist/src/utils/visual/enums.js +19 -0
- package/dist/src/utils/visual/event/boundary.d.ts +2 -2
- package/dist/src/utils/visual/event/boundary.js +93 -0
- package/dist/src/utils/visual/event/event.d.ts +1 -1
- package/dist/src/utils/visual/event/event.js +34 -0
- package/dist/src/utils/visual/event/index.d.ts +4 -4
- package/dist/src/utils/visual/event/types.d.ts +2 -2
- package/dist/src/utils/visual/event/types.js +23 -0
- package/dist/src/utils/visual/graphics/graphics.d.ts +8 -8
- package/dist/src/utils/visual/graphics/graphics.js +168 -0
- package/dist/src/utils/visual/graphics/graphicsData.d.ts +3 -3
- package/dist/src/utils/visual/graphics/graphicsData.js +12 -0
- package/dist/src/utils/visual/graphics/graphicsGeometry.d.ts +7 -7
- package/dist/src/utils/visual/graphics/graphicsGeometry.js +39 -0
- package/dist/src/utils/visual/graphics/index.d.ts +3 -3
- package/dist/src/utils/visual/index.d.ts +8 -8
- package/dist/src/utils/visual/index.js +20 -1
- package/dist/src/utils/visual/math/bezier.js +15 -0
- package/dist/src/utils/visual/math/enums.js +6 -0
- package/dist/src/utils/visual/math/index.d.ts +4 -4
- package/dist/src/utils/visual/math/matrix.d.ts +1 -1
- package/dist/src/utils/visual/math/matrix.js +59 -0
- package/dist/src/utils/visual/math/transform.d.ts +2 -2
- package/dist/src/utils/visual/math/transform.js +50 -0
- package/dist/src/utils/visual/render/batchRenderer.d.ts +4 -4
- package/dist/src/utils/visual/render/batchRenderer.js +59 -0
- package/dist/src/utils/visual/render/canvasRenderer.d.ts +3 -3
- package/dist/src/utils/visual/render/canvasRenderer.js +17 -0
- package/dist/src/utils/visual/render/filter.d.ts +1 -1
- package/dist/src/utils/visual/render/filter.js +92 -0
- package/dist/src/utils/visual/render/index.d.ts +2 -2
- package/dist/src/utils/visual/render/index.js +20 -0
- package/dist/src/utils/visual/render/render.d.ts +4 -4
- package/dist/src/utils/visual/render/render.js +19 -0
- package/dist/src/utils/visual/render/renderTarget.js +28 -0
- package/dist/src/utils/visual/render/utils/batch/index.d.ts +4 -4
- package/dist/src/utils/visual/render/utils/batch/index.js +88 -0
- package/dist/src/utils/visual/render/utils/earcut.js +328 -0
- package/dist/src/utils/visual/render/utils/float.js +65 -0
- package/dist/src/utils/visual/render/utils/index.js +50 -0
- package/dist/src/utils/visual/render/utils/verticy.d.ts +2 -2
- package/dist/src/utils/visual/render/utils/verticy.js +162 -0
- package/dist/src/utils/visual/render/utils/webgl/initShader.d.ts +1 -1
- package/dist/src/utils/visual/render/utils/webgl/initShader.js +31 -0
- package/dist/src/utils/visual/render/utils/webgl/shaders.js +22 -0
- package/dist/src/utils/visual/render/utils/webgpu/shaders.js +32 -0
- package/dist/src/utils/visual/render/webGPURenderer.d.ts +2 -2
- package/dist/src/utils/visual/render/webGPURenderer.js +185 -0
- package/dist/src/utils/visual/render/webGlRenderer.d.ts +2 -2
- package/dist/src/utils/visual/render/webGlRenderer.js +88 -0
- package/dist/src/utils/visual/shape/circle.d.ts +3 -3
- package/dist/src/utils/visual/shape/circle.js +17 -0
- package/dist/src/utils/visual/shape/ellipse.d.ts +3 -3
- package/dist/src/utils/visual/shape/ellipse.js +18 -0
- package/dist/src/utils/visual/shape/index.d.ts +6 -6
- package/dist/src/utils/visual/shape/polygon.d.ts +3 -3
- package/dist/src/utils/visual/shape/polygon.js +29 -0
- package/dist/src/utils/visual/shape/rectangle.d.ts +3 -3
- package/dist/src/utils/visual/shape/rectangle.js +18 -0
- package/dist/src/utils/visual/shape/roundedRectangle.d.ts +3 -3
- package/dist/src/utils/visual/shape/roundedRectangle.js +32 -0
- package/dist/src/utils/visual/shape/shape.d.ts +2 -2
- package/dist/src/utils/visual/shape/shape.js +5 -0
- package/dist/src/utils/visual/style/fill.js +18 -0
- package/dist/src/utils/visual/style/index.d.ts +2 -2
- package/dist/src/utils/visual/style/line.d.ts +2 -2
- package/dist/src/utils/visual/style/line.js +18 -0
- package/dist/src/utils/visual/types.d.ts +1 -1
- package/dist/src/utils/visual/vertex/container.d.ts +5 -5
- package/dist/src/utils/visual/vertex/container.js +54 -0
- package/dist/src/utils/visual/vertex/point.js +37 -0
- package/dist/src/utils/visual/vertex/vertex.d.ts +7 -7
- package/dist/src/utils/visual/vertex/vertex.js +76 -0
- package/dist/src/utils/worker.js +89 -0
- package/dist/src/utils/zip.js +161 -0
- package/dist/src/vnode/h.d.ts +1 -1
- package/dist/src/vnode/h.js +22 -0
- package/dist/src/vnode/hooks.d.ts +1 -1
- package/dist/src/vnode/htmlDomApi.js +94 -0
- package/dist/src/vnode/index.d.ts +16 -16
- package/dist/src/vnode/index.js +28 -1
- package/dist/src/vnode/init.d.ts +1 -1
- package/dist/src/vnode/init.js +104 -0
- package/dist/src/vnode/is.d.ts +1 -1
- package/dist/src/vnode/is.js +20 -0
- package/dist/src/vnode/modules/attributes.d.ts +1 -1
- package/dist/src/vnode/modules/attributes.js +21 -0
- package/dist/src/vnode/modules/class.d.ts +1 -1
- package/dist/src/vnode/modules/class.js +18 -0
- package/dist/src/vnode/modules/index.js +15 -0
- package/dist/src/vnode/modules/listeners.d.ts +1 -1
- package/dist/src/vnode/modules/listeners.js +36 -0
- package/dist/src/vnode/modules/props.d.ts +1 -1
- package/dist/src/vnode/modules/props.js +17 -0
- package/dist/src/vnode/modules/style.d.ts +1 -1
- package/dist/src/vnode/modules/style.js +52 -0
- package/dist/src/vnode/vnode.d.ts +6 -6
- package/dist/src/vnode/vnode.js +13 -0
- package/dist/third-party/jschardet/LICENSE.txt +504 -0
- package/dist/third-party/jschardet/NOTICE.txt +33 -0
- package/docs/API.md +8 -64
- package/package.json +12 -16
- package/dist/bin/generate-api-docs.d.ts +0 -1
- package/dist/build/build.es.d.ts +0 -2
- package/dist/build/build.umd.d.ts +0 -2
- package/dist/build/build.umd.node.d.ts +0 -2
- package/dist/build/build.umd.utils.d.ts +0 -2
- package/dist/chain-CTywmh_H.js +0 -1
- package/dist/color-BTvZUuf-.js +0 -1
- package/dist/enums-BAgbyGdH.js +0 -1
- package/dist/examples/clone-deep-example.d.ts +0 -1
- package/dist/examples/is-equal-example.d.ts +0 -1
- package/dist/i18n-DW21b_DJ.js +0 -1
- package/dist/plugins/vite-plugins-banner.d.ts +0 -2
- package/dist/rolldown-runtime-I3TIJKkN.js +0 -1
- package/dist/src/node/appendFile.d.ts +0 -7
- package/dist/src/node/body.d.ts +0 -9
- package/dist/src/node/color.d.ts +0 -7
- package/dist/src/node/command.d.ts +0 -8
- package/dist/src/node/ctx2req.d.ts +0 -5
- package/dist/src/node/fileInfo.d.ts +0 -7
- package/dist/src/node/fs.d.ts +0 -7
- package/dist/src/node/get.d.ts +0 -10
- package/dist/src/node/getIPAdress.d.ts +0 -1
- package/dist/src/node/index.d.ts +0 -25
- package/dist/src/node/index.js +0 -1
- package/dist/src/node/isColorSupported.d.ts +0 -2
- package/dist/src/node/paresUrl.d.ts +0 -19
- package/dist/src/node/readDir.d.ts +0 -6
- package/dist/src/node/readFile.d.ts +0 -9
- package/dist/src/node/router.d.ts +0 -42
- package/dist/src/node/send.d.ts +0 -7
- package/dist/src/node/server.d.ts +0 -18
- package/dist/src/node/startTask.d.ts +0 -2
- package/dist/src/node/stream.d.ts +0 -15
- package/dist/src/node/taskEnd.d.ts +0 -2
- package/dist/src/node/traverse.d.ts +0 -17
- package/dist/src/node/watchFile.d.ts +0 -8
- package/dist/src/node/writeFile.d.ts +0 -8
- package/dist/src/node/ws.d.ts +0 -8
- package/dist/src/utils/visual/render/utils/batch/index.test.d.ts +0 -1
- package/dist/src/utils/visual/render/utils/index.test.d.ts +0 -1
- package/dist/test/binary.test.d.ts +0 -1
- package/dist/test/bridge.test.d.ts +0 -1
- package/dist/test/budget.test.d.ts +0 -1
- package/dist/test/canvas.test.d.ts +0 -1
- package/dist/test/clearBr.test.d.ts +0 -1
- package/dist/test/cloneDeep.test.d.ts +0 -1
- package/dist/test/color.test.d.ts +0 -1
- package/dist/test/command.test.d.ts +0 -1
- package/dist/test/conversation.test.d.ts +0 -1
- package/dist/test/diff.test.d.ts +0 -1
- package/dist/test/encodeUrl.test.d.ts +0 -1
- package/dist/test/escapeHtml.test.d.ts +0 -1
- package/dist/test/formatBytes.test.d.ts +0 -1
- package/dist/test/is-equal.test.d.ts +0 -1
- package/dist/test/mimeType.test.d.ts +0 -1
- package/dist/test/package-exports.test.d.ts +0 -1
- package/dist/test/scroll.test.d.ts +0 -1
- package/dist/test/server.test.d.ts +0 -1
- package/dist/test/status.test.d.ts +0 -1
- package/dist/test/stream.test.d.ts +0 -1
- package/dist/test/sw.test.d.ts +0 -1
- package/dist/test/totp.test.d.ts +0 -1
- package/dist/test/tween.test.d.ts +0 -1
- package/dist/test/utils/async.test.d.ts +0 -1
- package/dist/test/utils/autosize.test.d.ts +0 -1
- package/dist/test/utils/color-grade.test.d.ts +0 -1
- package/dist/test/utils/compose.test.d.ts +0 -1
- package/dist/test/utils/event.test.d.ts +0 -1
- package/dist/test/utils/file-read.test.d.ts +0 -1
- package/dist/test/utils/format.test.d.ts +0 -1
- package/dist/test/utils/i18n.test.d.ts +0 -1
- package/dist/test/utils/idb-collection.test.d.ts +0 -1
- package/dist/test/utils/idb.test.d.ts +0 -1
- package/dist/test/utils/instrumentation.test.d.ts +0 -1
- package/dist/test/utils/interp.test.d.ts +0 -1
- package/dist/test/utils/lang.test.d.ts +0 -1
- package/dist/test/utils/locale-path.test.d.ts +0 -1
- package/dist/test/utils/media-query.test.d.ts +0 -1
- package/dist/test/utils/mergeObj.test.d.ts +0 -1
- package/dist/test/utils/number-parse.test.d.ts +0 -1
- package/dist/test/utils/paginate.test.d.ts +0 -1
- package/dist/test/utils/placement.test.d.ts +0 -1
- package/dist/test/utils/prefetch.test.d.ts +0 -1
- package/dist/test/utils/query-storage.test.d.ts +0 -1
- package/dist/test/utils/queue.test.d.ts +0 -1
- package/dist/test/utils/report-config.test.d.ts +0 -1
- package/dist/test/utils/report-image.test.d.ts +0 -1
- package/dist/test/utils/secure.test.d.ts +0 -1
- package/dist/test/utils/segment.test.d.ts +0 -1
- package/dist/test/utils/signal-once.test.d.ts +0 -1
- package/dist/test/utils/single-flight.test.d.ts +0 -1
- package/dist/test/utils/speech.test.d.ts +0 -1
- package/dist/test/utils/text-boundary.test.d.ts +0 -1
- package/dist/test/utils/time.test.d.ts +0 -1
- package/dist/test/utils/timing.test.d.ts +0 -1
- package/dist/test/utils/truncate.test.d.ts +0 -1
- package/dist/test/utils/visual/filter.test.d.ts +0 -1
- package/dist/test/utils/worker-client.test.d.ts +0 -1
- package/dist/test/utils/worker-serve.test.d.ts +0 -1
- package/dist/test/utils/zip.test.d.ts +0 -1
- package/dist/test/visual/math.test.d.ts +0 -1
- package/dist/test/visual-application.test.d.ts +0 -1
- package/dist/test/visual-batch.test.d.ts +0 -1
- package/dist/test/visual-math.test.d.ts +0 -1
- package/dist/test/vnode/index.d.ts +0 -1
- package/dist/test/vnode/server.d.ts +0 -2
- package/dist/test/vnode/vnode.d.ts +0 -1
- package/dist/test/vnode.test.d.ts +0 -1
- package/dist/test/websocket.test.d.ts +0 -1
- package/dist/test/writeFile.test.d.ts +0 -1
- package/dist/umd/index.umd.cjs +0 -1
- package/dist/umd/node/node.umd.cjs +0 -1
- package/dist/umd/utils/utils.umd.cjs +0 -1
- package/dist/utils-B4FnyUzW.js +0 -1
- package/dist/vite.config.d.ts +0 -8
- package/dist/vitest.config.d.ts +0 -2
|
@@ -1 +1,20 @@
|
|
|
1
|
-
import{i as t,n as e,r as s,t as r}from"../../../enums-BAgbyGdH.js";var i,n=/* @__PURE__ */function(t){return t.RECTANGLE="rectangle",t.POLYGON="polygon",t.CIRCLE="circle",t.ELLIPSE="ellipse",t.ROUNDED_RECTANGLE="rounded rectangle",t}({}),a=/* @__PURE__ */function(t){return t.BUTT="butt",t.ROUND="round",t.SQUARE="square",t}({}),h=/* @__PURE__ */function(t){return t.MITER="miter",t.BEVEL="bevel",t.ROUND="round",t}({}),o=/* @__PURE__ */function(t){return t.WEB_GL="webgl",t.CANVAS="canvas",t.WEB_GPU="webgpu",t}({}),l=65536,c=12,u=class{},f=class extends u{x;y;width;height;type=n.RECTANGLE;constructor(t=0,e=0,s=0,r=0){super(),this.x=t,this.y=e,this.width=s,this.height=r}contains(t){return t.x>this.x&&t.x<this.x+this.width&&t.y>this.y&&t.y<this.y+this.height}},p=class{canvasEle;screen=new f;filters=[];constructor(t){const{view:e}=t;this.canvasEle=e,this.screen.width=e.width,this.screen.height=e.height}resizeView(t,e){this.canvasEle.width=t,this.canvasEle.height=e}async init(){return Promise.resolve()}},d=class extends p{ctx;backgroundColor;backgroundAlpha;constructor(t){super(t),t.debug;const{backgroundColor:e,backgroundAlpha:s}=t;this.backgroundColor=e,this.backgroundAlpha=s,this.ctx=this.canvasEle.getContext("2d")}render(t){t.updateTransform(),this.ctx.save(),this.ctx.clearRect(0,0,this.screen.width,this.screen.height),this.backgroundAlpha&&(this.ctx.globalAlpha=this.backgroundAlpha),this.backgroundColor&&(this.ctx.fillStyle=this.backgroundColor),this.ctx.fillRect(0,0,this.screen.width,this.screen.height),t.renderCanvasRecursive(this),this.ctx.restore()}},g=(t,e)=>{if(e.worldAlpha<=0||!e.visible)return;e.buildBatches(t);const s=e.children;for(let r=0;r<s.length;r++)g(t,s[r])},x=(t,e)=>{if(e.worldAlpha<=0||!e.visible)return;e.updateBatches(t);const s=e.children;for(let r=0;r<s.length;r++)x(t,s[r])},v=class{vertexCount=0;indexCount=0;rgba=0;vertexStart=0;indexStart=0},y=class{style;vertexStart=0;indexStart=0;vertexCount=0;indexCount=0;constructor(t){this.style=t}start(t,e){this.vertexStart=t,this.indexStart=e}end(t,e){this.vertexCount=t,this.indexCount=e}},m=class{idx=0;reset(){this.idx=0}},b=class extends m{batches=[];constructor(){super()}getOne(){return this.batches[this.idx]||(this.batches[this.idx]=new w),this.batches[this.idx++]}},w=class extends v{vertexOffset=0;indexOffset=0;graphics;packVertices(t,e){const s=this.graphics.geometry.vertices.data,r=this.vertexOffset;for(let i=0;i<this.vertexCount;i++){const n=s[2*(r+i)],a=s[2*(r+i)+1],{a:h,b:o,c:l,d:c,tx:u,ty:f}=this.graphics.worldTransform,p=h*n+l*a+u,d=o*n+c*a+f,g=3*(this.vertexStart+i);t[g]=p,t[g+1]=d,e[g+2]=this.rgba}}packIndices(t){const e=this.graphics.geometry.indices.data,s=this.indexOffset;for(let r=0;r<this.indexCount;r++)t[this.indexStart+r]=e[r+s]+this.vertexStart}updateVertices(t){const e=this.graphics.geometry.vertices.data,s=this.vertexOffset,{a:r,b:i,c:n,d:a,tx:h,ty:o}=this.graphics.worldTransform;for(let l=0;l<this.vertexCount;l++){const c=e[2*(s+l)],u=e[2*(s+l)+1],f=3*(this.vertexStart+l);t[f]=r*c+n*u+h,t[f+1]=i*c+a*u+o}}},E=new class{batchesMap={graphics:new b};get(t){return this.batchesMap[t].getOne()}reset(){Object.values(this.batchesMap).forEach(t=>{t.reset()})}},_=class extends p{builtVersion=-1;vertexCount=0;indexCount=0;batches=[];batchesCount=0;vertFloatView;vertIntView;indexBuffer;curVertBufferLength=0;curIndexBufferLength=0;constructor(t){super(t);const e=/* @__PURE__ */new ArrayBuffer(3072);this.vertFloatView=new Float32Array(e),this.vertIntView=new Uint32Array(e),this.indexBuffer=/* @__PURE__ */new Uint32Array(256)}addBatch(t){t.vertexStart=this.vertexCount,t.indexStart=this.indexCount,this.vertexCount+=t.vertexCount,this.indexCount+=t.indexCount,this.batches[this.batchesCount]=t,this.batchesCount++}startBuild(){this.vertexCount=0,this.indexCount=0,this.batchesCount=0,E.reset()}buildEnd(){this.resizeBufferIfNeeded(),this.packData()}resizeBufferIfNeeded(){if(12*this.vertexCount>this.vertFloatView.byteLength){const t=new ArrayBuffer(12*this.vertexCount);this.vertFloatView=new Float32Array(t),this.vertIntView=new Uint32Array(t)}this.indexCount>this.indexBuffer.length&&(this.indexBuffer=new Uint32Array(this.indexCount))}packData(){for(let t=0;t<this.batchesCount;t++){const e=this.batches[t];this.batches[t]=void 0,e?.packVertices(this.vertFloatView,this.vertIntView),e?.packIndices(this.indexBuffer)}}updateChildrenTransform(t){t.sortChildren();const e=t.transform.shouldUpdateLocalTransform;if(t.transform.updateLocalTransform(),e){const{a:e,b:s,c:r,d:i,tx:n,ty:a}=t.transform.localTransform;this.setRootTransform(e,s,r,i,n,a)}t.worldAlpha=t.alpha;const s=t.children;for(let r=0;r<s.length;r++)s[r].updateTransform()}render(t){this.updateChildrenTransform(t),this.builtVersion!==t.structureVersion?(this.startBuild(),g(this,t),this.buildEnd(),this.builtVersion=t.structureVersion):x(this.vertFloatView,t),this.updateBuffer(),this.draw()}},M="\nprecision highp float;\nattribute vec2 a_position;\nattribute vec4 a_color;\nvarying vec4 v_color;\nuniform mat3 u_root_transform;\nuniform mat3 u_projection_matrix;\nvoid main(){\n v_color = a_color;\n gl_Position = vec4((u_projection_matrix * u_root_transform * vec3(a_position, 1.0)).xy, 0.0, 1.0);\n}\n".trim(),T="\nprecision mediump float;\nvarying vec4 v_color;\nvoid main(){\n gl_FragColor = v_color;\n}\n".trim(),P=(t,e,s)=>{const r=t.createShader(e);if(t.shaderSource(r,s),t.compileShader(r),t.getShaderParameter(r,t.COMPILE_STATUS))return r;{const e=t.getShaderInfoLog(r);throw t.deleteShader(r),console.error(`shader compilation failed: ${e}`),new Error(`shader compilation failed: ${e}`)}},A=(t,e)=>{const s=t.getAttribLocation(e,"a_position");t.vertexAttribPointer(s,2,t.FLOAT,!1,12,0),t.enableVertexAttribArray(s);const r=t.getAttribLocation(e,"a_color");t.vertexAttribPointer(r,4,t.UNSIGNED_BYTE,!0,12,8),t.enableVertexAttribArray(r)},B=t=>{const e=t.gl,s=((t,e,s)=>{const r=t.createProgram();if(!r)throw console.error("failed to create the program"),new Error("failed to create the program");if(t.attachShader(r,e),t.attachShader(r,s),t.linkProgram(r),!t.getProgramParameter(r,t.LINK_STATUS)){const i=t.getProgramInfoLog(r);throw console.error(`link failed: ${i}`),t.deleteProgram(r),t.deleteShader(e),t.deleteShader(s),new Error(`link failed: ${i}`)}return t.useProgram(r),r})(e,P(e,e.VERTEX_SHADER,M),P(e,e.FRAGMENT_SHADER,T));return e.enable(e.BLEND),e.blendFunc(e.ONE,e.ONE_MINUS_SRC_ALPHA),s},I=/* @__PURE__ */new Map,R=t=>{const e=I.get(t);if(e)return e;let s;if(/^#?[0-9a-fA-F]{3}$/.test(t)){const e=t.replace("#","");s=[parseInt(e[0]+e[0],16),parseInt(e[1]+e[1],16),parseInt(e[2]+e[2],16)]}else if(/^#?[0-9a-fA-F]{6}$/.test(t)){const e=parseInt(t.replace("#",""),16);s=[e>>16&255,e>>8&255,255&e]}else s=(t=>{if(void 0===i&&(i="undefined"!=typeof document?document.createElement("canvas").getContext("2d"):null),!i)return[0,0,0];i.fillStyle="#000",i.fillStyle=t,i.fillRect(0,0,1,1);const[e,s,r]=i.getImageData(0,0,1,1).data;return[e,s,r]})(t);return I.set(t,s),s},S=(t,e)=>{const[s,r,i]=R(t).map(t=>Math.round(t*e));let n=0;return n+=Math.round(255*e)<<24,n+=i<<16,n+=r<<8,n+=s,n},C=t=>{const[e,s,r]=R(t);return[e/255,s/255,r/255]},U=class{gl;framebuffer;texture;width=0;height=0;constructor(t){this.gl=t;const e=this.gl;this.texture=e.createTexture(),e.bindTexture(e.TEXTURE_2D,this.texture),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),this.framebuffer=e.createFramebuffer(),e.bindFramebuffer(e.FRAMEBUFFER,this.framebuffer),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,this.texture,0),e.bindFramebuffer(e.FRAMEBUFFER,null)}resize(t,e){if(t===this.width&&e===this.height)return;this.width=t,this.height=e;const s=this.gl;s.bindTexture(s.TEXTURE_2D,this.texture),s.texImage2D(s.TEXTURE_2D,0,s.RGBA,t,e,0,s.RGBA,s.UNSIGNED_BYTE,null)}bind(){const t=this.gl;t.bindFramebuffer(t.FRAMEBUFFER,this.framebuffer),t.viewport(0,0,this.width,this.height)}dispose(){this.gl.deleteFramebuffer(this.framebuffer),this.gl.deleteTexture(this.texture)}},L=class extends _{gl;program;glVertexBuffer;glIndexBuffer;unifLoc;targetA;targetB;quadBuffer;constructor(t){super(t),t.debug,this.gl=this.canvasEle.getContext("webgl",{antialias:!0}),this.gl.getExtension("OES_element_index_uint"),this.program=B(this),this.glVertexBuffer=this.gl.createBuffer(),this.glIndexBuffer=this.gl.createBuffer(),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.glVertexBuffer),this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER,this.glIndexBuffer),A(this.gl,this.program),this.unifLoc={u_root_transform:this.gl.getUniformLocation(this.program,"u_root_transform"),u_projection_matrix:this.gl.getUniformLocation(this.program,"u_projection_matrix")};const e=t.backgroundAlpha??0,[s,r,i]=C(t.backgroundColor??"");this.gl.clearColor(s*e,r*e,i*e,e),this.setRootTransform(1,0,0,1,0,0),this.setProjectionMatrix()}setProjectionMatrix(){const t=1/this.canvasEle.width*2,e=1/this.canvasEle.height*2;this.gl.uniformMatrix3fv(this.unifLoc.u_projection_matrix,!1,new Float32Array([t,0,0,0,-e,0,-1,1,1]))}setRootTransform(t,e,s,r,i,n){this.gl.uniformMatrix3fv(this.unifLoc.u_root_transform,!1,new Float32Array([t,e,0,s,r,0,i,n,1]))}updateBuffer(){const t=this.gl;t.bindBuffer(t.ARRAY_BUFFER,this.glVertexBuffer),t.bufferData(t.ARRAY_BUFFER,this.vertFloatView,t.DYNAMIC_DRAW),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,this.glIndexBuffer),t.bufferData(t.ELEMENT_ARRAY_BUFFER,this.indexBuffer,t.DYNAMIC_DRAW)}draw(){const t=this.gl,e=this.canvasEle.width,s=this.canvasEle.height;if(0===this.filters.length)return t.bindFramebuffer(t.FRAMEBUFFER,null),t.viewport(0,0,e,s),t.clear(t.COLOR_BUFFER_BIT),void t.drawElements(t.TRIANGLES,this.indexCount,t.UNSIGNED_INT,0);this.ensurePostResources(e,s);const r=this.targetA,i=this.targetB;r.bind(),t.clear(t.COLOR_BUFFER_BIT),t.drawElements(t.TRIANGLES,this.indexCount,t.UNSIGNED_INT,0);let n=r,a=i;for(let h=0;h<this.filters.length;h++){const r=h===this.filters.length-1;if(this.filters[h].apply(t,this.quadBuffer,n.texture,r?null:a,e,s),!r){const t=n;n=a,a=t}}t.useProgram(this.program),t.bindBuffer(t.ARRAY_BUFFER,this.glVertexBuffer),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,this.glIndexBuffer),A(t,this.program)}ensurePostResources(t,e){const s=this.gl;this.quadBuffer||(this.quadBuffer=s.createBuffer(),s.bindBuffer(s.ARRAY_BUFFER,this.quadBuffer),s.bufferData(s.ARRAY_BUFFER,new Float32Array([-1,-1,1,-1,-1,1,1,1]),s.STATIC_DRAW),this.targetA=new U(s),this.targetB=new U(s)),this.targetA?.resize(t,e),this.targetB?.resize(t,e)}},F=class extends _{gpu;device;pipeline;renderPassDescriptor;options;gpuVertexBuffer;gpuIndexBuffer;projectionMatBuffer;stageMatBuffer;uniformBindGroup;constructor(t){super(t),t.debug,this.options=t,this.gpu=this.canvasEle.getContext("webgpu"),this.curVertBufferLength=256,this.curIndexBufferLength=256}async init(){await this.initDevice(),this.initGpuBuffer(),this.initRenderPassDescriptor(),this.createPipeline(),this.initUniformBindGroup(),this.setRootTransform(1,0,0,1,0,0),this.setProjectionMatrix()}draw(){const{device:t,renderPassDescriptor:e,gpuVertexBuffer:s,gpuIndexBuffer:r,gpu:i,uniformBindGroup:n,indexCount:a,pipeline:h}=this,o=t.createCommandEncoder(),l=[...e.colorAttachments];l?.[0]?.view&&(l[0].view=i.getCurrentTexture().createView());const c=o.beginRenderPass(e);c.setPipeline(h),c.setVertexBuffer(0,s),c.setIndexBuffer(r,"uint32"),c.setBindGroup(0,n),c.drawIndexed(a),c.end();const u=o.finish();t.queue.submit([u])}initUniformBindGroup(){const t=this.device;this.stageMatBuffer=t.createBuffer({label:"stage-matrix-uniform-buffer",size:12*Float32Array.BYTES_PER_ELEMENT,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST}),this.projectionMatBuffer=t.createBuffer({label:"projection-matrix-uniform-buffer",size:12*Float32Array.BYTES_PER_ELEMENT,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST}),this.uniformBindGroup=this.device.createBindGroup({label:"my-uniform-bind-group",layout:this.pipeline.getBindGroupLayout(0),entries:[{binding:0,resource:{buffer:this.stageMatBuffer}},{binding:1,resource:{buffer:this.projectionMatBuffer}}]})}initGpuBuffer(){const t=this.device;this.gpuVertexBuffer=t.createBuffer({label:"my-gpu-vertex-buffer",size:12*this.curVertBufferLength,usage:GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_DST}),this.gpuIndexBuffer=t.createBuffer({label:"my-gpu-index-buffer",size:this.curIndexBufferLength*Uint32Array.BYTES_PER_ELEMENT,usage:GPUBufferUsage.INDEX|GPUBufferUsage.COPY_DST})}updateBuffer(){const t=this.device;this.vertexCount>this.curVertBufferLength&&(this.gpuVertexBuffer.destroy(),this.gpuVertexBuffer=t.createBuffer({label:"my-gpu-vertex-buffer",size:12*this.vertexCount,usage:GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_DST}),this.curVertBufferLength=this.vertexCount),t.queue.writeBuffer(this.gpuVertexBuffer,0,this.vertFloatView.buffer),this.indexCount>this.curIndexBufferLength&&(this.gpuIndexBuffer.destroy(),this.gpuIndexBuffer=t.createBuffer({label:"my-gpu-index-buffer",size:this.indexCount*Uint32Array.BYTES_PER_ELEMENT,usage:GPUBufferUsage.INDEX|GPUBufferUsage.COPY_DST}),this.curIndexBufferLength=this.indexCount),t.queue.writeBuffer(this.gpuIndexBuffer,0,this.indexBuffer.buffer)}setRootTransform(t,e,s,r,i,n){this.device.queue.writeBuffer(this.stageMatBuffer,0,new Float32Array([t,e,0,0,s,r,0,0,i,n,1,0]))}setProjectionMatrix(){const t=1/this.canvasEle.width*2,e=1/this.canvasEle.height*2;this.device.queue.writeBuffer(this.projectionMatBuffer,0,new Float32Array([t,0,0,0,0,-e,0,0,-1,1,1,0]))}createPipeline(){this.pipeline=this.device.createRenderPipeline({layout:"auto",label:"my-render-pipeline",vertex:{module:this.device.createShaderModule({code:"\n@group(0) @binding(0) var<uniform> u_root_transform: mat3x3<f32>;\n@group(0) @binding(1) var<uniform> u_projection_matrix: mat3x3<f32>;\n\nstruct VertOutput {\n @builtin(position) v_position: vec4<f32>,\n @location(0) v_color : vec4<f32>,\n};\n\n@vertex\nfn main(\n @location(0) a_position: vec2<f32>,\n @location(1) a_color: vec4<f32>,\n) -> VertOutput {\n let v_position = vec4<f32>((u_projection_matrix * u_root_transform * vec3<f32>(a_position, 1.0)).xy, 0.0, 1.0);\n\n let v_color = a_color;\n\n return VertOutput(v_position, v_color);\n}\n",label:"my-vert-shader-module"}),entryPoint:"main",buffers:[{arrayStride:12,attributes:[{shaderLocation:0,format:"float32x2",offset:0},{shaderLocation:1,format:"unorm8x4",offset:2*Float32Array.BYTES_PER_ELEMENT}]}]},fragment:{module:this.device.createShaderModule({code:"\n@fragment\nfn main(\n @location(0) v_color : vec4<f32>,\n) -> @location(0) vec4<f32> {\n return v_color;\n}\n",label:"my-frag-shader-module"}),entryPoint:"main",targets:[{format:navigator.gpu.getPreferredCanvasFormat(),blend:{alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"}}}]},primitive:{topology:"triangle-list"}})}async initDevice(){const t=await((await navigator.gpu.requestAdapter())?.requestDevice());t&&(this.gpu.configure({device:t,format:navigator.gpu.getPreferredCanvasFormat(),alphaMode:"premultiplied"}),this.device=t)}initRenderPassDescriptor(){const{backgroundColor:t="",backgroundAlpha:e=1}=this.options,s=e,[r,i,n]=C(t).map(t=>t*s);this.renderPassDescriptor={label:"my-render-pass-descriptor",colorAttachments:[{view:this.gpu.getCurrentTexture().createView(),storeOp:"store",loadOp:"clear",clearValue:[r,i,n,s]}]}}},D=class t{x;y;constructor(t=0,e=0){this.x=t,this.y=e}set(t=0,e=t){this.x=t,this.y=e}clone=()=>new t(this.x,this.y)},N=class{_x;_y;cb;constructor(t,e=0,s=0){this._x=e,this._y=s,this.cb=t}set(t=0,e=t){this._x=t,this._y=e,this.cb(this._x,this._y)}get x(){return this._x}set x(t){this._x!==t&&(this._x=t,this.cb(this._x,this._y))}get y(){return this._y}set y(t){this._y!==t&&(this._y=t,this.cb(this._x,this._y))}},V=class t{a;b;c;d;tx;ty;array=null;constructor(t=1,e=0,s=0,r=1,i=0,n=0){this.a=t,this.b=e,this.c=s,this.d=r,this.tx=i,this.ty=n}set=(t,e,s,r,i,n)=>(this.a=t,this.b=e,this.c=s,this.d=r,this.tx=i,this.ty=n,this);append=t=>{const{a:e,b:s,c:r,d:i,tx:n,ty:a}=this,{a:h,b:o,c:l,d:c,tx:u,ty:f}=t;return this.a=e*h+r*o,this.b=s*h+i*o,this.c=e*l+r*c,this.d=s*l+i*c,this.tx=e*u+r*f+n,this.ty=s*u+i*f+a,this};fromArray=t=>{this.a=t[0],this.b=t[1],this.c=t[3],this.d=t[4],this.tx=t[2],this.ty=t[5]};translate=(t,e)=>(this.tx+=t,this.ty+=e,this);scale=(t,e)=>(this.a*=t,this.d*=e,this.c*=t,this.b*=e,this.tx*=t,this.ty*=e,this);setTransform=(t,e,s,r,i,n,a,h,o)=>(this.a=Math.cos(a+o)*i,this.b=Math.sin(a+o)*i,this.c=-Math.sin(a-h)*n,this.d=Math.cos(a-h)*n,this.tx=t-(s*this.a+r*this.c),this.ty=e-(s*this.b+r*this.d),this);rotate=t=>{const e=Math.cos(t),s=Math.sin(t),r=this.a,i=this.c,n=this.tx;return this.a=r*e-this.b*s,this.b=r*s+this.b*e,this.c=i*e-this.d*s,this.d=i*s+this.d*e,this.tx=n*e-this.ty*s,this.ty=n*s+this.ty*e,this};equals=t=>t.a===this.a&&t.b===this.b&&t.c===this.c&&t.d===this.d&&t.tx===this.tx&&t.ty===this.ty;identity=()=>(this.a=1,this.b=0,this.c=0,this.d=1,this.tx=0,this.ty=0,this);decompose=t=>{const s=this.a,r=this.b,i=this.c,n=this.d,a=t.pivot,h=-Math.atan2(-i,n),o=Math.atan2(r,s),l=Math.abs(h+o);return l<1e-5||Math.abs(e-l)<1e-5?(t.rotation=o,t.skew.x=t.skew.y=0):(t.rotation=0,t.skew.x=h,t.skew.y=o),t.scale.x=Math.sqrt(s*s+r*r),t.scale.y=Math.sqrt(i*i+n*n),t.position.x=this.tx+(a.x*s+a.y*i),t.position.y=this.ty+(a.x*r+a.y*n),t};apply=t=>{const e=new D,s=t.x,r=t.y;return e.x=this.a*s+this.c*r+this.tx,e.y=this.b*s+this.d*r+this.ty,e};applyInverse=t=>{const e=new D,s=1/(this.a*this.d+this.c*-this.b),r=t.x,i=t.y;return e.x=this.d*s*r+-this.c*s*i+(this.ty*this.c-this.tx*this.d)*s,e.y=this.a*s*i+-this.b*s*r+(-this.ty*this.a+this.tx*this.b)*s,e};prepend=t=>{const{a:e,b:s,c:r,d:i,tx:n,ty:a}=t,{a:h,b:o,c:l,d:c,tx:u,ty:f}=this;return this.a=e*h+r*o,this.b=s*h+i*o,this.c=e*l+r*c,this.d=s*l+i*c,this.tx=e*u+r*f+n,this.ty=s*u+i*f+a,this};clone=()=>{const e=new t;return e.a=this.a,e.b=this.b,e.c=this.c,e.d=this.d,e.tx=this.tx,e.ty=this.ty,e};toArray=(t,e)=>{this.array||(this.array=/* @__PURE__ */new Float32Array(9));const s=e||this.array;return t?(s[0]=this.a,s[1]=this.b,s[2]=0,s[3]=this.c,s[4]=this.d,s[5]=0,s[6]=this.tx,s[7]=this.ty,s[8]=1):(s[0]=this.a,s[1]=this.c,s[2]=this.tx,s[3]=this.b,s[4]=this.d,s[5]=this.ty,s[6]=0,s[7]=0,s[8]=1),s}},O=class{localTransform=new V;worldTransform=new V;position;scale;pivot;skew;_rotation=0;rotateMatrix=new V;skewMatrix=new V;scaleMatrix=new V;localMatrix=new V;shouldUpdateLocalTransform=!1;worldId=0;parentId=0;constructor(){this.position=new N(this.onChange),this.scale=new N(this.onScaleChange,1,1),this.pivot=new N(this.onChange),this.skew=new N(this.onSkewChange)}get rotation(){return this._rotation}set rotation(t){this._rotation=t,this.rotateMatrix.set(Math.cos(this.rotation),Math.sin(this.rotation),-Math.sin(this.rotation),Math.cos(this.rotation),0,0),this.shouldUpdateLocalTransform=!0}onSkewChange=(t,e)=>{this.skewMatrix.set(Math.cos(e),Math.sin(e),Math.sin(t),Math.cos(t),0,0),this.shouldUpdateLocalTransform=!0};onScaleChange=(t,e)=>{this.scaleMatrix.set(t,0,0,e,0,0),this.shouldUpdateLocalTransform=!0};onChange=()=>{this.shouldUpdateLocalTransform=!0};updateLocalTransform(){if(!this.shouldUpdateLocalTransform)return;const{a:t,b:e,c:s,d:r}=this.localMatrix.set(1,0,0,1,0,0).append(this.rotateMatrix).append(this.skewMatrix).append(this.scaleMatrix),i=t*this.pivot.x+s*this.pivot.y,n=e*this.pivot.x+r*this.pivot.y,a=this.position.x-i,h=this.position.y-n;this.localTransform.set(t,e,s,r,a,h),this.shouldUpdateLocalTransform=!1,this.parentId=-1}updateTransform(t){if(this.updateLocalTransform(),this.parentId!==t.worldId){const{a:e,b:s,c:r,d:i,tx:n,ty:a}=t.worldTransform,{a:h,b:o,c:l,d:c,tx:u,ty:f}=this.localTransform;this.worldTransform.set(e*h+r*o,s*h+i*o,e*l+r*c,s*l+i*c,e*u+r*f+n,s*u+i*f+a),this.parentId=t.worldId,this.worldId++}}},G=class extends t{_zIndex=0;parent=void 0;visible=!0;transform=new O;alpha=1;worldAlpha=1;hitArea=null;cursor="auto";get zIndex(){return this._zIndex}set zIndex(t){this._zIndex=t,this.parent&&(this.parent.isSort=!0)}get position(){return this.transform.position}get localTransform(){return this.transform.localTransform}get worldTransform(){return this.transform.worldTransform}get x(){return this.position.x}set x(t){this.transform.position.x=t}get y(){return this.position.y}set y(t){this.transform.position.y=t}get scale(){return this.transform.scale}get pivot(){return this.transform.pivot}get skew(){return this.transform.skew}get rotation(){return this.transform.rotation}set rotation(t){this.transform.rotation=t}get angle(){return this.transform.rotation*s}set angle(t){this.transform.rotation=t*r}updateTransform(){const t=this.parent?.transform||new O;this.transform.updateTransform(t),this.worldAlpha=this.alpha*(this.parent?.worldAlpha||1)}addEventListener=(t,e,s)=>{const r="boolean"==typeof s&&s||"object"==typeof s&&s.capture?`${t}capture`:t;"object"==typeof s&&s.once?this.once(r,e):this.tap(r,e)};removeEventListener=(t,e,s)=>{const r=s?`${t}capture`:t;this.off(r,e)}},k=class extends G{isSort=!1;type="container";children=[];worldId=0;batches=[];batchCount=0;structureVersion=0;constructor(){super()}markStructureDirty=()=>{let t=this.parent??this;for(;t.parent;)t=t.parent;t.structureVersion++};addChild=t=>{t.parent?.removeChild(t),this.children.push(t),t.parent=this,this.isSort=!0,this.markStructureDirty()};removeChild=t=>{for(let e=0;e<this.children.length;e++)if(this.children[e]===t)return this.children.splice(e,1),t.parent=void 0,void this.markStructureDirty()};sortChildren=()=>{this.isSort&&(this.children.sort((t,e)=>t.zIndex-e.zIndex),this.isSort=!1)};renderCanvas(t){}renderCanvasRecursive=t=>{if(!(this.worldAlpha<=0)&&this.visible){this.renderCanvas(t);for(let e=0;e<this.children.length;e++)this.children[e].renderCanvasRecursive(t)}};updateTransform=()=>{this.sortChildren();const t=this.parent?.transform||new O;if(this.transform.updateTransform(t),this.worldAlpha=(this.parent?.worldAlpha||1)*this.alpha,!(this.worldAlpha<=0)&&this.visible)for(let e=0;e<this.children.length;e++)this.children[e].updateTransform()};containsPoint=t=>!!this.hitArea&&this.hitArea.contains(t);buildBatches(t){}updateBatches(t){}},Y=/* @__PURE__ */function(t){return t[t.NONE=0]="NONE",t[t.CAPTURING=1]="CAPTURING",t[t.AT_TARGET=2]="AT_TARGET",t[t.BUBBLING=3]="BUBBLING",t}({}),z=class{isTrusted=!0;timeStamp=0;type="mousemove";button=0;buttons=0;global=new D;propagationStopped=!1;eventPhase=0;target=new k;currentTarget=new k;stopPropagation(){this.propagationStopped=!0}},q=class{rootContainer;hasFoundTarget=!1;hitTarget=null;cursor="auto";eventHandlerMap={};pressTargetsMap={};overTargets=[];constructor(t){this.rootContainer=t,this.eventHandlerMap.mousemove=this.fireMouseMove,this.eventHandlerMap.mousedown=this.fireMouseDown,this.eventHandlerMap.mouseup=this.fireMouseUp}hitTestRecursive=(t,e)=>{if(!t.visible)return;if(this.hasFoundTarget)return;for(let r=t.children.length-1;r>=0;r--){const s=t.children[r];this.hitTestRecursive(s,e)}if(this.hasFoundTarget)return;const s=t.worldTransform.applyInverse(e);t.containsPoint(s)&&(this.hitTarget=t,this.hasFoundTarget=!0)};hitTest=t=>(this.hasFoundTarget=!1,this.hitTarget=null,this.hitTestRecursive(this.rootContainer,t),this.hitTarget);fireEvent=t=>{this.eventHandlerMap[t.type]?.(t)};fireMouseMove=t=>{const e=this.hitTest(t.global),s=this.overTargets.length>0?this.overTargets[this.overTargets.length-1]:null;if(s&&s!==e&&(t.target=s,t.type="mouseout",this.dispatchEvent(t),!e||!this.composePath(e).includes(s)))if(t.type="mouseleave",t.eventPhase=Y.AT_TARGET,e){let r=s;for(;r&&!this.composePath(e).includes(r);)t.target=r,t.currentTarget=t.target,t.target.call(`${t.type}capture`,t),t.target.call(t.type,t),r=r.parent}else for(let r=this.overTargets.length-1;r>=0;r--)t.target=this.overTargets[r],t.currentTarget=t.target,t.target.call(`${t.type}capture`,t),t.target.call(t.type,t);if(e&&s!==e){t.target=e,t.type="mouseover",this.dispatchEvent(t);const r=this.composePath(e);if(t.type="mouseenter",t.eventPhase=Y.AT_TARGET,s){let e=r.length-1;for(;e>=0&&!this.composePath(s).includes(r[e]);e--);for(let s=e+1;s<r.length;s++)t.target=r[s],t.currentTarget=t.target,t.target.call(`${t.type}capture`,t),t.target.call(t.type,t)}else for(let e=0;e<r.length;e++)t.target=r[e],t.currentTarget=t.target,t.target.call(`${t.type}capture`,t),t.target.call(t.type,t)}e&&(t.target=e,t.type="mousemove",this.dispatchEvent(t)),this.overTargets=e?this.composePath(e):[],this.cursor=e?e.cursor:"auto"};fireMouseDown=t=>{const e=this.hitTest(t.global);e&&(t.target=e,this.dispatchEvent(t),this.pressTargetsMap[t.button]=this.composePath(e))};fireMouseUp=t=>{const e=this.hitTest(t.global);if(!e)return;t.target=e,this.dispatchEvent(t);const s=this.pressTargetsMap[t.button];if(!s)return;let r=s[s.length-1];const i=this.composePath(e);for(;r&&!i.includes(r);)r.parent&&(r=r.parent);t.type="click",t.target=r,this.dispatchEvent(t),delete this.pressTargetsMap[t.button]};notifyTarget=t=>{t.eventPhase===Y.CAPTURING?t.currentTarget.call(`${t.type}capture`,t):t.currentTarget.call(t.type,t)};propagate=t=>{const e=this.composePath(t.target);t.eventPhase=Y.CAPTURING;for(let s=0;s<e.length-1;s++)if(t.currentTarget=e[s],this.notifyTarget(t),t.propagationStopped)return;if(t.eventPhase=Y.AT_TARGET,t.currentTarget=t.target,t.currentTarget.call(`${t.type}capture`,t),!t.propagationStopped&&(t.currentTarget.call(t.type,t),!t.propagationStopped)){t.eventPhase=Y.BUBBLING;for(let s=e.length-2;s>=0;s--)if(t.currentTarget=e[s],this.notifyTarget(t),t.propagationStopped)return}};dispatchEvent=t=>{t.propagationStopped=!1,this.propagate(t)};composePath=t=>{const e=[];let s=t;for(;s;)e.unshift(s),s=s.parent;return e}},j=class{canvasEle;eventBoundary;rootEvent=new z;constructor(t,e){this.canvasEle=t,this.eventBoundary=new q(e),this.addEvents()}addEvents=()=>{this.canvasEle.addEventListener("pointermove",this.onPointerMove,!0),this.canvasEle.addEventListener("pointerleave",this.onPointerLeave,!0),this.canvasEle.addEventListener("pointerdown",this.onPointerDown,!0),this.canvasEle.addEventListener("pointerup",this.onPointerup,!0)};onPointerMove=t=>{this.bootstrapEvent(t),this.eventBoundary.fireEvent(this.rootEvent),this.setCursor()};onPointerLeave=()=>{this.eventBoundary.overTargets=[]};onPointerDown=t=>{this.bootstrapEvent(t),this.eventBoundary.fireEvent(this.rootEvent)};onPointerup=t=>{this.bootstrapEvent(t),this.eventBoundary.fireEvent(this.rootEvent)};bootstrapEvent=t=>{this.rootEvent.isTrusted=t.isTrusted,this.rootEvent.timeStamp=performance.now(),this.rootEvent.type=t.type.replace("pointer","mouse"),this.rootEvent.button=t.button,this.rootEvent.buttons=t.buttons,this.rootEvent.global.x=t.offsetX,this.rootEvent.global.y=t.offsetY};setCursor=()=>{this.canvasEle.style.cursor=this.eventBoundary.cursor}},X=class t{renderer;stage;view;animationFrameId;eventSystem;constructor(t){const{view:e=document.createElement("canvas")}=t;this.view=e,this.renderer=(t=>{const{prefer:e}=t;switch(e){case o.CANVAS:return new d(t);case o.WEB_GL:return new L(t);case o.WEB_GPU:return new F(t);default:return new d(t)}})({...t,view:e}),this.stage=new k,this.eventSystem=new j(this.view,this.stage)}static async create(e){const s=new t(e);return await s.renderer.init(),s}get filters(){return this.renderer.filters}set filters(t){this.renderer.filters=t}render(){this.renderer.render(this.stage)}start(){const t=()=>{this.render(),this.animationFrameId=requestAnimationFrame(t)};t()}stop(){this.animationFrameId&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=void 0)}},Z=class extends u{points=[];closeStroke=!1;type=n.POLYGON;constructor(t=[]){super(),this.points=t}isIntersect(t,e,s,r,i,n){if(r>e&&n>e)return!1;if(r<e&&n<e)return!1;if(s<t&&i<t)return!1;if(s>t&&i>t)return!0;return i-(i-s)/(r-n)*(e-n)>t}contains(t){const e=this.points.length;let s=0;for(let h=2;h<=e-2;h+=2){const e=this.points[h-2],r=this.points[h-1],i=this.points[h],n=this.points[h+1];this.isIntersect(t.x,t.y,e,r,i,n)&&s++}const r=this.points[0],i=this.points[1],n=this.points[e-2],a=this.points[e-1];return this.isIntersect(t.x,t.y,r,i,n,a)&&s++,s%2!=0}},$=class t{color="#ffffff";alpha=1;visible=!1;constructor(){this.reset()}clone(){const e=new t;return e.color=this.color,e.alpha=this.alpha,e.visible=this.visible,e}reset(){this.color="#ffffff",this.alpha=1,this.visible=!1}},H=class t extends ${width=0;cap=a.BUTT;join=h.MITER;miterLimit=10;clone(){const e=new t;return e.color=this.color,e.alpha=this.alpha,e.visible=this.visible,e.width=this.width,e.cap=this.cap,e.join=this.join,e.miterLimit=this.miterLimit,e}reset(){super.reset(),this.color="#ffffff",this.width=0,this.cap=a.BUTT,this.join=h.MITER,this.miterLimit=10}},W=class{shape;lineStyle;fillStyle;vertices=[];constructor(t,e,s){this.shape=t,this.lineStyle=s,this.fillStyle=e}},Q=class{_oldLength=-1;_length=0;curMaxLen=16;float32=new Float32Array(16);_data;get length(){return this._length}concat(t){const e=this._length+t.length;for(;e>this.curMaxLen;)this.expandCapacity();for(let s=0;s<t.length;s++)this.float32[this._length]=t[s],this._length++}push(t){this._length>=this.curMaxLen&&this.expandCapacity(),this.float32[this._length]=t,this._length++}expandCapacity(){this.curMaxLen*=2;const t=new Float32Array(this.curMaxLen);t.set(this.float32),this.float32=t}get data(){return this._oldLength!==this._length&&(this._data=new Float32Array(this.float32.buffer,0,this._length),this._oldLength=this._length),this._data}clear(){this._length=0}},K=class{_oldLength=-1;_length=0;curMaxLen=8;int32=/* @__PURE__ */new Uint32Array(8);_data;get length(){return this._length}concat(t){const e=this.length+t.length;for(;e>this.curMaxLen;)this.expandCapacity();for(let s=0;s<t.length;s++)this.int32[this._length]=t[s],this._length++}concatUInt16(t){const e=this.length+t.length;for(;e>this.curMaxLen;)this.expandCapacity();this.int32.set(t,this._length),this._length=e}expandCapacity(){this.curMaxLen*=2;const t=new Uint32Array(this.curMaxLen);t.set(this.int32),this.int32=t}get data(){return this._oldLength!==this._length&&(this._data=new Uint32Array(this.int32.buffer,0,this._length),this._oldLength=this._length),this._data}clear(){this._length=0}},J=/* @__PURE__ */new Set,tt=!1;function et(t,e,s=2){const r=e&&e.length,i=r?e[0]*s:t.length;J.size&&J.clear();let n=st(t,0,i,s,!0);const a=[];if(!n||n.next===n.prev)return a;let h=0,o=0,l=0;if(r&&(n=function(t,e,s,r){const i=[];for(let n=0,a=e.length;n<a;n++){const s=st(t,e[n]*r,n<a-1?e[n+1]*r:t.length,r,!1);s===s.next&&J.add(s),i.push(Bt(s))}i.sort(ct),function(t,e){const s=Math.ceil((t+2*e)/ft)+e+2;pt.length<4*s&&(pt=new Float64Array(4*s));dt=0}(t.length/r,e.length),vt(s,s),lt=!0;for(let n=0;n<i.length;n++)s=ut(i[n],s);return lt=!1,rt(s)}(t,e,n,s)),t.length>80*s){h=t[0],o=t[1];let e=h,r=o;for(let n=s;n<i;n+=s){const s=t[n],i=t[n+1];s<h&&(h=s),i<o&&(o=i),s>e&&(e=s),i>r&&(r=i)}l=Math.max(e-h,r-o),l=0!==l?32767/l:0}return it(n,a,h,o,l),a}function st(t,e,s,r,i){let n=null;if(i===function(t,e,s,r){let i=0;for(let n=e,a=s-r;n<s;n+=r)i+=(t[a]-t[n])*(t[n+1]+t[a+1]),a=n;return i}(t,e,s,r)>0)for(let a=e;a<s;a+=r)n=Nt(a/r|0,t[a],t[a+1],n);else for(let a=s-r;a>=e;a-=r)n=Nt(a/r|0,t[a],t[a+1],n);return n&&Ct(n,n.next)&&(Vt(n),n=n.next),n}function rt(t,e=t){const s=e===t;let r,i=t;do{r=!1,i===i.next||0!==J.size&&J.has(i)||!Ct(i,i.next)&&0!==St(i.prev,i,i.next)?(s||i!==e)&&(i=i.next,r=!s):((s||i===e)&&(e=i.prev),tt=!0,Vt(i),i=i.prev,r=!0)}while(r||i!==e);return e}function it(t,e,s,r,i){i&&function(t,e,s,r){let i=t,n=0;do{i.z=At(i.x,i.y,e,s,r),wt[n++]=i,i=i.next}while(i!==t);!function(t){if(t<=32){for(let e=1;e<t;e++){const t=wt[e],s=t.z;let r=e-1;for(;r>=0&&wt[r].z>s;)wt[r+1]=wt[r],r--;wt[r+1]=t}return}_t.length<t&&(_t=new Uint32Array(t),Mt=new Uint32Array(t),Et=Array.from({length:t}));for(let e=0;e<t;e++)_t[e]=wt[e].z;Pt(t,wt,_t,Et,Mt,0),Pt(t,Et,Mt,wt,_t,8),Pt(t,wt,_t,Et,Mt,16),Pt(t,Et,Mt,wt,_t,24)}(n);let a=null;for(let h=0;h<n;h++){const t=wt[h];t.prevZ=a,a&&(a.nextZ=t),a=t}a.nextZ=null}(t,s,r,i);let n=t,a=!1;for(;t.prev!==t.next;){const h=t.prev,o=t.next;if(St(h,t,o)<0&&(i?at(t,s,r,i):nt(t)))e.push(h.i,t.i,o.i),Vt(t),t=o,n=o;else if((t=o)===n){if(tt=!1,t=rt(t),tt){n=t;continue}if(!a){n=t=ht(t,e),a=!0;continue}ot(t,e,s,r,i);break}}}function nt(t){const e=t.prev,s=t,r=t.next,i=e.x,n=s.x,a=r.x,h=e.y,o=s.y,l=r.y,c=Math.min(i,n,a),u=Math.min(h,o,l),f=Math.max(i,n,a),p=Math.max(h,o,l);let d=r.next;for(;d!==e;){if(d.x>=c&&d.x<=f&&d.y>=u&&d.y<=p&&(i!==d.x||h!==d.y)&&It(i,h,n,o,a,l,d.x,d.y)&&St(d.prev,d,d.next)>=0)return!1;d=d.next}return!0}function at(t,e,s,r){const i=t.prev,n=t,a=t.next,h=i.x,o=n.x,l=a.x,c=i.y,u=n.y,f=a.y,p=Math.min(h,o,l),d=Math.min(c,u,f),g=Math.max(h,o,l),x=Math.max(c,u,f),v=At(p,d,e,s,r),y=At(g,x,e,s,r);let m=t.prevZ;for(;m&&m.z>=v;){if(m.x>=p&&m.x<=g&&m.y>=d&&m.y<=x&&m!==a&&(h!==m.x||c!==m.y)&&It(h,c,o,u,l,f,m.x,m.y)&&St(m.prev,m,m.next)>=0)return!1;m=m.prevZ}let b=t.nextZ;for(;b&&b.z<=y;){if(b.x>=p&&b.x<=g&&b.y>=d&&b.y<=x&&b!==a&&(h!==b.x||c!==b.y)&&It(h,c,o,u,l,f,b.x,b.y)&&St(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function ht(t,e){let s=t,r=!1;do{const i=s.prev,n=s.next.next;Ut(i,s,s.next,n,!1)&&Ft(i,n)&&Ft(n,i)&&(e.push(i.i,s.i,n.i),Vt(s),Vt(s.next),s=t=n,r=!0),s=s.next}while(s!==t);return r?rt(s):s}function ot(t,e,s,r,i){let n=t;do{let t=n.next.next;for(;t!==n.prev;){if(n.i!==t.i&&Rt(n,t)){let a=Dt(n,t);return n=rt(n,n.next),a=rt(a,a.next),it(n,e,s,r,i),void it(a,e,s,r,i)}t=t.next}n=n.next}while(n!==t)}var lt=!1;function ct(t,e){return t.x-e.x||t.y-e.y||(t.next.y-t.y)/(t.next.x-t.x)-(e.next.y-e.y)/(e.next.x-e.x)}function ut(t,e){const s=function(t,e){let s=e;const r=t.x,i=t.y;let n,a=-1/0;if(Ct(t,s))return s;for(let f=0,p=0;f<dt;f++,p+=4){if(i<pt[p+1]||i>pt[p+3]||pt[p]>r||pt[p+2]<=a)continue;const e=yt(f);s=mt(f);do{if(s.prev.next===s){if(Ct(t,s.next))return s.next;if(i<=s.y&&i>=s.next.y&&s.next.y!==s.y){const t=s.x+(i-s.y)*(s.next.x-s.x)/(s.next.y-s.y);if(t<=r&&t>a&&(a=t,n=s.x<s.next.x?s:s.next,t===r))return n}}s=s.next}while(s!==e)}if(!n)return null;const h=n.x,o=n.y,l=Math.min(i,o),c=Math.max(i,o);let u=1/0;for(let f=0,p=0;f<dt;f++,p+=4){if(pt[p+2]<h||pt[p]>r||pt[p+3]<l||pt[p+1]>c)continue;const e=yt(f);s=mt(f);do{if(s.prev.next===s&&r>=s.x&&s.x>=h&&r!==s.x&&It(i<o?r:a,i,h,o,i<o?a:r,i,s.x,s.y)){const e=Math.abs(i-s.y)/(r-s.x);(Ft(s,t)||s.y===i&&s.next.y===i&&s.next.x>r)&&(e<u||e===u&&(s.x>n.x||s.x===n.x&&bt(n,s)))&&(n=s,u=e)}s=s.next}while(s!==e)}return n}(t,e);if(!s)return e;const r=Dt(s,t);return vt(s,r.next.next),rt(r,r.next),rt(s,s.next)}var ft=16,pt=/* @__PURE__ */new Float64Array(0),dt=0,gt=[],xt=[];function vt(t,e){let s=t;do{const t=dt++;gt[t]=s;let r=1/0,i=1/0,n=-1/0,a=-1/0,h=0;do{const e=s.next;s.z=t,s.x<r&&(r=s.x),s.x>n&&(n=s.x),s.y<i&&(i=s.y),s.y>a&&(a=s.y),e.x<r&&(r=e.x),e.x>n&&(n=e.x),e.y<i&&(i=e.y),e.y>a&&(a=e.y),s=e}while(++h<ft&&s!==e);xt[t]=s;const o=4*t;pt[o]=r,pt[o+1]=i,pt[o+2]=n,pt[o+3]=a}while(s!==e)}function yt(t){let e=xt[t];for(;e.prev.next!==e;)e=e.next;return xt[t]=e,e}function mt(t){let e=gt[t];for(;e.prev.next!==e;)e=e.next;return gt[t]=e,e}function bt(t,e){return St(t.prev,t,e.prev)<0&&St(e.next,t,t.next)<0}var wt=[],Et=[],_t=/* @__PURE__ */new Uint32Array(0),Mt=/* @__PURE__ */new Uint32Array(0),Tt=/* @__PURE__ */new Uint32Array(256);function Pt(t,e,s,r,i,n){Tt.fill(0);for(let h=0;h<t;h++)Tt[s[h]>>>n&255]++;let a=0;for(let h=0;h<256;h++){const t=Tt[h];Tt[h]=a,a+=t}for(let h=0;h<t;h++){const t=s[h],a=Tt[t>>>n&255]++;r[a]=e[h],i[a]=t}}function At(t,e,s,r,i){let n=(t-s)*i|0,a=(e-r)*i|0;return n=16711935&(n|n<<8),n=252645135&(n|n<<4),n=858993459&(n|n<<2),n=1431655765&(n|n<<1),a=16711935&(a|a<<8),a=252645135&(a|a<<4),a=858993459&(a|a<<2),a=1431655765&(a|a<<1),n|a<<1}function Bt(t){let e=t,s=t;do{(e.x<s.x||e.x===s.x&&e.y<s.y)&&(s=e),e=e.next}while(e!==t);return s}function It(t,e,s,r,i,n,a,h){return(i-a)*(e-h)>=(t-a)*(n-h)&&(t-a)*(r-h)>=(s-a)*(e-h)&&(s-a)*(n-h)>=(i-a)*(r-h)}function Rt(t,e){const s=Ct(t,e)&&St(t.prev,t,t.next)>0&&St(e.prev,e,e.next)>0;return t.next.i!==e.i&&(s||Ft(t,e)&&Ft(e,t)&&(0!==St(t.prev,t,e.prev)||0!==St(t,e.prev,e)))&&!function(t,e){const s=Math.min(t.x,e.x),r=Math.max(t.x,e.x),i=Math.min(t.y,e.y),n=Math.max(t.y,e.y);let a=t;do{const h=a.next;if(a.x>r&&h.x>r||a.x<s&&h.x<s||a.y>n&&h.y>n||a.y<i&&h.y<i)a=h;else{if(a.i!==t.i&&h.i!==t.i&&a.i!==e.i&&h.i!==e.i&&Ut(a,h,t,e))return!0;a=h}}while(a!==t);return!1}(t,e)&&(s||function(t,e){let s=t,r=!1;const i=(t.x+e.x)/2,n=(t.y+e.y)/2;do{const t=s.next;s.y>n!=t.y>n&&i<(t.x-s.x)*(n-s.y)/(t.y-s.y)+s.x&&(r=!r),s=t}while(s!==t);return r}(t,e))}function St(t,e,s){return(e.y-t.y)*(s.x-e.x)-(e.x-t.x)*(s.y-e.y)}function Ct(t,e){return t.x===e.x&&t.y===e.y}function Ut(t,e,s,r,i=!0){const n=St(t,e,s),a=St(t,e,r),h=St(s,r,t),o=St(s,r,e);return(n>0&&a<0||n<0&&a>0)&&(h>0&&o<0||h<0&&o>0)||!!i&&(!(0!==n||!Lt(t,s,e))||(!(0!==a||!Lt(t,r,e))||(!(0!==h||!Lt(s,t,r))||!(0!==o||!Lt(s,e,r)))))}function Lt(t,e,s){return e.x<=Math.max(t.x,s.x)&&e.x>=Math.min(t.x,s.x)&&e.y<=Math.max(t.y,s.y)&&e.y>=Math.min(t.y,s.y)}function Ft(t,e){return St(t.prev,t,t.next)<0?St(t,e,t.next)>=0&&St(t,t.prev,e)>=0:St(t,e,t.prev)<0||St(t,t.next,e)<0}function Dt(t,e){const s=Ot(t.i,t.x,t.y),r=Ot(e.i,e.x,e.y),i=t.next,n=e.prev;return t.next=e,e.prev=t,s.next=i,i.prev=s,r.next=s,s.prev=r,n.next=r,r.prev=n,r}function Nt(t,e,s,r){const i=Ot(t,e,s);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function Vt(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ),lt&&function(t,e){const s=4*t.z;e.x<pt[s]&&(pt[s]=e.x),e.y<pt[s+1]&&(pt[s+1]=e.y),e.x>pt[s+2]&&(pt[s+2]=e.x),e.y>pt[s+3]&&(pt[s+3]=e.y)}(t.prev,t.next)}function Ot(t,e,s){return{i:t,x:e,y:s,prev:null,next:null,z:0,prevZ:null,nextZ:null}}var Gt=class extends u{x;y;radius;type=n.CIRCLE;constructor(t=0,e=0,s=0){super(),this.x=t,this.y=e,this.radius=s}contains(t){return(t.x-this.x)*(t.x-this.x)+(t.y-this.y)*(t.y-this.y)<this.radius*this.radius}},kt=class extends u{x;y;radiusX;radiusY;type=n.ELLIPSE;constructor(t=0,e=0,s=0,r=0){super(),this.x=t,this.y=e,this.radiusX=s,this.radiusY=r}contains(t){return(t.x-this.x)*(t.x-this.x)/(this.radiusX*this.radiusX)+(t.y-this.y)*(t.y-this.y)/(this.radiusY*this.radiusY)<1}},Yt=class extends u{x;y;width;height;radius;type=n.ROUNDED_RECTANGLE;constructor(t=0,e=0,s=0,r=0,i=20){super(),this.x=t,this.y=e,this.width=s,this.height=r;const n=Math.min(s,r)/2;this.radius=i>n?n:i}contains(t){if(!(t.x>this.x&&t.x<this.x+this.width&&t.y>this.y&&t.y<this.y+this.height))return!1;const e=this.x+this.radius,s=this.y+this.radius;if(t.x<e&&t.y<s)return(t.x-e)*(t.x-e)+(t.y-s)*(t.y-s)<this.radius*this.radius;const r=this.x+this.radius,i=this.y+this.height-this.radius;if(t.x<r&&t.y>i)return(t.x-r)*(t.x-r)+(t.y-i)*(t.y-i)<this.radius*this.radius;const n=this.x+this.width-this.radius,a=this.y+this.radius;if(t.x>n&&t.y<a)return(t.x-n)*(t.x-n)+(t.y-a)*(t.y-a)<this.radius*this.radius;const h=this.x+this.width-this.radius,o=this.y+this.height-this.radius;return!(t.x>h&&t.y<o)||(t.x-h)*(t.x-h)+(t.y-o)*(t.y-o)<this.radius*this.radius}},zt=t=>{const{shape:e,vertices:s}=t;if(e instanceof f){const{x:t,y:r,width:i,height:n}=e;s.push(t,r,t+i,r,t+i,r+n,t,r+n)}e instanceof Gt&&((t,e)=>{const{x:s,y:r,radius:i}=t,n=2*Math.PI*i,a=Math.min(Math.ceil(n/5),2048);for(let h=0;h<a;h++){const t=h/a*Math.PI*2,n=s+i*Math.cos(t),o=r+i*Math.sin(t);e.vertices.push(n,o)}})(e,t),e instanceof Yt&&((t,e)=>{const{x:s,y:r,width:i,height:n,radius:a}=t,h=2*Math.PI*a/4,o=Math.min(Math.ceil(h/4),2048);for(let l=0;l<o;l++){const t=l/o*Math.PI*.5,h=a*Math.cos(t),c=a*Math.sin(t);e.vertices.push(s+i-a+h,r+n-a+c)}for(let l=0;l<o;l++){const t=l/o*Math.PI*.5+Math.PI/2,i=a*Math.cos(t),h=a*Math.sin(t);e.vertices.push(s+a+i,r+n-a+h)}for(let l=0;l<o;l++){const t=l/o*Math.PI*.5+Math.PI,i=a*Math.cos(t),n=a*Math.sin(t);e.vertices.push(s+a+i,r+a+n)}for(let l=0;l<o;l++){const t=l/o*Math.PI*.5+1.5*Math.PI,n=a*Math.cos(t),h=a*Math.sin(t);e.vertices.push(s+i-a+n,r+a+h)}})(e,t),e instanceof kt&&((t,e)=>{const{x:s,y:r,radiusX:i,radiusY:n}=t,a=Math.PI*Math.sqrt(2*(i*i+n*n)),h=Math.min(Math.ceil(a/5),2048);for(let o=0;o<h;o++){const t=o/h*Math.PI*2,a=s+i*Math.cos(t),l=r+n*Math.sin(t);e.vertices.push(a,l)}})(e,t),e instanceof Z&&(t.vertices=e.points)},qt=t=>{const e=[],s=t.length/2+1;for(let r=1;r<s-1;r++)e.push(0,r,r+1);return e.push(0,s-1,1),e},jt=(t,e)=>{const{shape:s,vertices:r,fillStyle:i}=t,n=new y(i);if(e.batchParts.push(n),n.start(e.vertices.length/2,e.indices.length),s instanceof f&&(e.vertices.concat(r),e.indices.concat([0,1,2,0,2,3]),n.end(4,6)),s instanceof Gt){const{x:t,y:i}=s;e.vertices.push(t),e.vertices.push(i),e.vertices.concat(r);const a=qt(r);e.indices.concat(a),n.end(r.length/2+1,a.length)}if(s instanceof Yt){const{x:t,y:i,width:a,height:h}=s;e.vertices.push(t+a/2),e.vertices.push(i+h/2),e.vertices.concat(r);const o=qt(r);e.indices.concat(o),n.end(r.length/2+1,o.length)}if(s instanceof kt){const{x:t,y:i}=s;e.vertices.push(t),e.vertices.push(i),e.vertices.concat(r);const a=qt(r);e.indices.concat(a),n.end(r.length/2+1,a.length)}if(s instanceof Z){e.vertices.concat(r);const t=et(r);e.indices.concat(t),n.end(r.length/2,t.length)}},Xt=(t,e,s,r,i,n,a,h)=>{let o=0,l=0,c=0,u=0,f=0,p=0;if(Math.abs(s-t)<=Number.EPSILON)o=1,l=0,f=s;else{const i=(r-e)/(s-t);o=i,l=-1,f=-(r-i*s)}if(Math.abs(a-i)<=Number.EPSILON)c=1,u=0,p=a;else{const t=(h-n)/(a-i);c=t,u=-1,p=-(h-t*a)}return[(f*u-l*p)/(o*u-l*c),(o*p-f*c)/(o*u-l*c)]},Zt=(t,e,s)=>{const r=e,i=-t,n=s/2/Math.sqrt(t*t+e*e);return[r*n,i*n]},$t=(t,e,s,r,i,n,a,h)=>{const o=s-t,l=r-e,c=i-t,u=n-e;let f=0;f=0===o?l>0?.5*Math.PI:1.5*Math.PI:0===l?o>0?0:Math.PI:o>=0&&l>=0?Math.atan(l/o):o<=0&&l>=0?Math.atan(-o/l)+.5*Math.PI:o<=0&&l<=0?Math.atan(l/o)+Math.PI:Math.atan(o/-l)+1.5*Math.PI;let p=0;p=0===c?u>0?.5*Math.PI:1.5*Math.PI:0===u?c>0?0:Math.PI:c>=0&&u>=0?Math.atan(u/c):c<=0&&u>=0?Math.atan(-c/u)+.5*Math.PI:c<=0&&u<=0?Math.atan(u/c)+Math.PI:Math.atan(c/-u)+1.5*Math.PI,f>p&&(f-=2*Math.PI);const d=Math.sqrt((s-t)*(s-t)+(r-e)*(r-e)),g=2*Math.PI*d/3,x=a.length/2;a.push(t,e,s,r);for(let v=1;v<g;v++){const s=f+v/g*(p-f),r=t+d*Math.cos(s),i=e+d*Math.sin(s);a.push(r,i)}a.push(i,n);for(let v=1;v<a.length/2-x-1;v++)h.push(0+x,v+x,v+1+x)},Ht=(t,e)=>{const{vertices:s,shape:r,lineStyle:i}=t,{width:n,cap:o,join:l,miterLimit:c}=i;let u=0,f=!1;if(r instanceof Z?r.closeStroke&&(f=!0):f=!0,f){const t=s[0],e=s[1],r=s[s.length-2],i=s[s.length-1];Math.abs(t-r)<1e-4&&Math.abs(e-i)<1e-4&&(s.pop(),s.pop());const n=(t+s[s.length-2])/2,a=(e+s[s.length-1])/2;s.unshift(n,a),s.push(n,a)}const p=new y(i);e.batchParts.push(p),p.start(e.vertices.length/2,e.indices.length);const d=[],g=[],x=s[0],v=s[1],m=s[2],b=s[3],[w,E]=Zt(m-x,b-v,n);if(!f){if(o===a.SQUARE){const t=E,e=-w;d.push(x+w,v+E,x+w+t,v+E+e,x-w+t,v-E+e,x-w,v-E),g.push(0,1,2,0,2,3)}o===a.ROUND&&$t(x,v,x-w,v-E,x+w,v+E,d,g),a.BUTT}u=d.length/2,d.push(x-w,v-E,x+w,v+E);for(let a=2;a<s.length-2;a+=2){const t=s[a-2],e=s[a-1],r=s[a],i=s[a+1],o=s[a+2],f=s[a+3],[p,x]=Zt(r-t,i-e,n),[v,y]=Zt(o-r,f-i,n),m=r-t,b=i-e,w=o-r,E=f-i,_=w*b-m*E,M=m*w+b*E;if(Math.abs(_)<.001*Math.abs(M)){d.push(r+p,i+x,r-p,i-x),g.push(0+u,1+u,2+u,0+u,2+u,3+u),u=d.length/2,M>0?d.push(r-p,i-x,r+p,i+x):(l===h.ROUND&&($t(r,i,r+p,i+x,r-p,i-x,d,g),u=d.length/2),l===h.BEVEL||h.MITER,d.push(r+p,i+x,r-p,i-x));continue}const[T,P]=Xt(t+p,e+x,r+p,i+x,r+v,i+y,o+v,f+y),[A,B]=Xt(t-p,e-x,r-p,i-x,r-v,i-y,o-v,f-y);let I=l;l===h.MITER&&(((A-T)**2+(B-P)**2)/n**2<=c**2||(I=h.BEVEL));const R=m*m+b*b+(n/2)**2,S=w*w+E*E+(n/2)**2;(A-r)**2+(B-i)**2<Math.min(R,S)?(I===h.BEVEL&&(_>0?(d.push(T,P,r-p,i-x),g.push(0+u,1+u,2+u,0+u,2+u,3+u),u=d.length/2,d.push(T,P,r-p,i-x,r-v,i-y),g.push(0+u,1+u,2+u),u=d.length/2,d.push(r-v,i-y,T,P)):(d.push(r+p,i+x,A,B),g.push(0+u,1+u,2+u,0+u,2+u,3+u),u=d.length/2,d.push(A,B,r+p,i+x,r+v,i+y),g.push(0+u,1+u,2+u),u=d.length/2,d.push(A,B,r+v,i+y))),I===h.MITER&&(d.push(T,P,A,B),g.push(0+u,1+u,2+u,0+u,2+u,3+u),u=d.length/2,d.push(A,B,T,P)),I===h.ROUND&&(_<0?(d.push(r+p,i+x,A,B),g.push(0+u,1+u,2+u,0+u,2+u,3+u),u=d.length/2,d.push(A,B,r+p,i+x,r,i),g.push(0+u,1+u,2+u),u=d.length/2,d.push(A,B,r+v,i+y,r,i),g.push(0+u,1+u,2+u),u=d.length/2,$t(r,i,r+p,i+x,r+v,i+y,d,g),u=d.length/2,d.push(A,B,r+v,i+y)):(d.push(T,P,r-p,i-x),g.push(0+u,1+u,2+u,0+u,2+u,3+u),u=d.length/2,d.push(T,P,r-p,i-x,r,i),g.push(0+u,1+u,2+u),u=d.length/2,d.push(T,P,r-v,i-y,r,i),g.push(0+u,1+u,2+u),u=d.length/2,$t(r,i,r-v,i-y,r-p,i-x,d,g),u=d.length/2,d.push(r-v,i-y,T,P)))):(d.push(r+p,i+x,r-p,i-x),g.push(0+u,1+u,2+u,0+u,2+u,3+u),u=d.length/2,I===h.BEVEL&&(_>0?(d.push(r,i,r-p,i-x,r-v,i-y),g.push(0+u,1+u,2+u)):(d.push(r,i,r+p,i+x,r+v,i+y),g.push(0+u,1+u,2+u))),I===h.MITER&&(_>0?(d.push(r,i,r-p,i-x,A,B,r-v,i-y),g.push(0+u,1+u,2+u,0+u,2+u,3+u)):(d.push(r,i,r+p,i+x,T,P,r+v,i+y),g.push(0+u,1+u,2+u,0+u,2+u,3+u))),I===h.ROUND&&(_>0?$t(r,i,r-v,i-y,r-p,i-x,d,g):$t(r,i,r+p,i+x,r+v,i+y,d,g)),u=d.length/2,d.push(r-v,i-y,r+v,i+y))}const _=s[s.length-2],M=s[s.length-1],T=s[s.length-4],P=s[s.length-3],[A,B]=Zt(_-T,M-P,n);if(d.push(_+A,M+B,_-A,M-B),g.push(0+u,1+u,2+u,0+u,2+u,3+u),u=d.length/2,!f){const t=s[s.length-2],e=s[s.length-1],r=s[s.length-4],i=s[s.length-3],[h,l]=Zt(t-r,e-i,n);if(o===a.SQUARE){const s=-l,r=h;d.push(t+h,e+l,t+h+s,e+l+r,t-h+s,e-l+r,t-h,e-l),g.push(0+u,1+u,2+u,0+u,2+u,3+u)}o===a.ROUND&&$t(t,e,t+h,e+l,t-h,e-l,d,g)}e.vertices.concat(d),e.indices.concat(g),p.end(d.length/2,g.length)},Wt=class{graphicsData=[];dirty=!1;shapeIndex=0;batchParts=[];vertices=new Q;indices=new K;drawShape(t,e,s){const r=new W(t,e,s);this.graphicsData.push(r),this.dirty=!0}containsPoint(t){for(let e=0;e<this.graphicsData.length;e++){const{shape:s,fillStyle:r}=this.graphicsData[e];if(r.visible&&s.contains(t))return!0}return!1}buildVerticesAndTriangulate(){if(this.dirty){this.dirty=!1;for(let t=this.shapeIndex;t<this.graphicsData.length;t++){const e=this.graphicsData[t];zt(e),e.fillStyle.visible&&jt(e,this),e.lineStyle.visible&&Ht(e,this)}this.shapeIndex=this.graphicsData.length}}clear(){this.graphicsData=[],this.vertices.clear(),this.indices.clear(),this.batchParts=[],this.shapeIndex=0,this.dirty=!1}},Qt=class extends k{_lineStyle=new H;_fillStyle=new $;geometry=new Wt;currentPath=new Z;type;constructor(){super(),this.type="graphics"}lineStyle(t,e="#000000",s=1){if(this.startPoly(),"object"==typeof t)Object.assign(this._lineStyle,t);else{const r={width:t,color:e,alpha:s};Object.assign(this._lineStyle,r)}return this._lineStyle.visible=!0,this}resetLineStyle=()=>{this._lineStyle.reset()};drawShape=t=>(this.geometry.drawShape(t,this._fillStyle.clone(),this._lineStyle.clone()),this.markStructureDirty(),this);startPoly=()=>{this.currentPath.points.length>2&&this.drawShape(this.currentPath),this.currentPath=new Z};beginFill=(t="#000000",e=1)=>(this.startPoly(),this._fillStyle.color=t,this._fillStyle.alpha=e,this._fillStyle.alpha>0&&(this._fillStyle.visible=!0),this);endFill=()=>(this.startPoly(),this._fillStyle.reset(),this);drawRect=(t,e,s,r)=>this.drawShape(new f(t,e,s,r));drawCircle=(t,e,s)=>this.drawShape(new Gt(t,e,s));drawRoundedRect=(t,e,s,r,i)=>this.drawShape(new Yt(t,e,s,r,i));drawEllipse=(t,e,s,r)=>this.drawShape(new kt(t,e,s,r));drawPolygon=t=>{const e=new Z(t);return e.closeStroke=!0,this.drawShape(e)};moveTo=(t,e)=>(this.startPoly(),this.currentPath.points[0]=t,this.currentPath.points[1]=e,this);lineTo=(t,e)=>{if(0===this.currentPath.points.length)return this.moveTo(t,e),this;const s=this.currentPath.points,r=s[s.length-2],i=s[s.length-1];return r===t&&i===e||s.push(t,e),this};closePath=()=>(this.currentPath.closeStroke=!0,this.startPoly(),this);containsPoint=t=>this.hitArea?this.hitArea.contains(t):this.geometry.containsPoint(t);quadraticCurveTo=(t,e,s,r)=>{const i=this.currentPath.points.length;0===i&&(this.currentPath.points=[0,0]);const n=this.currentPath.points[i-2],a=this.currentPath.points[i-1],h=t,o=e,l=s,c=r,u=((t,e,s,r,i,n)=>{const a=2*(t-2*s+i),h=-2*(t-s),o=2*(e-2*r+n),l=-2*(e-r),c=a*a+o*o,u=2*(a*h+o*l),f=h*h+l*l,p=Math.sqrt((4*c*f-u*u)/4),d=(c/2+u/4)*Math.sqrt((c+u/2)*(c+u/2)+p*p)+p*p/2*Math.log(Math.abs(c+u/2+Math.sqrt((c+u/2)*(c+u/2)+p*p))),g=u/4*Math.sqrt(u*u/4+p*p)+p*p/2*Math.log(u/2+Math.sqrt(u*u/4+p*p));return 1/(Math.sqrt(c)*c)*(d-g)})(n,a,h,o,l,c);let f=Math.ceil(u/10);f>2048&&(f=2048),f<8&&(f=8);for(let p=1;p<=f;p++){const t=p/f,e=(1-t)*(1-t)*n+2*t*(1-t)*h+t*t*l,s=(1-t)*(1-t)*a+2*t*(1-t)*o+t*t*c;this.currentPath.points.push(e,s)}return this};bezierCurveTo=(t,e,s,r,i,n)=>{const a=this.currentPath.points.length;0===a&&(this.currentPath.points=[0,0]);const h=this.currentPath.points[a-2],o=this.currentPath.points[a-1],l=t,c=e,u=s,f=r,p=i,d=n,g=((t,e,s,r,i,n,a,h)=>{let o=t,l=e,c=0;for(let u=1;u<=10;u++){const f=u/10,p=(1-f)*(1-f)*(1-f)*t+3*f*(1-f)*(1-f)*s+3*f*f*(1-f)*i+f*f*f*a,d=(1-f)*(1-f)*(1-f)*e+3*f*(1-f)*(1-f)*r+3*f*f*(1-f)*n+f*f*f*h,g=p-o,x=d-l;c+=Math.sqrt(g*g+x*x),o=p,l=d}return c})(h,o,l,c,u,f,p,d);let x=Math.ceil(g/10);x>2048&&(x=2048),x<8&&(x=8);for(let v=1;v<=x;v++){const t=v/x,e=(1-t)*(1-t)*(1-t)*h+3*t*(1-t)*(1-t)*l+3*t*t*(1-t)*u+t*t*t*p,s=(1-t)*(1-t)*(1-t)*o+3*t*(1-t)*(1-t)*c+3*t*t*(1-t)*f+t*t*t*d;this.currentPath.points.push(e,s)}return this};arc=(t,e,s,r,i,n=!1)=>{if(!n){for(;i<r;)i+=2*Math.PI;i-r>2*Math.PI&&(i=r+2*Math.PI)}if(n){for(;i>r;)r+=2*Math.PI;r-i>2*Math.PI&&(i=r-2*Math.PI)}const a=i-r;if(0===a)return this;const h=t+Math.cos(r)*s,o=e+Math.sin(r)*s;this.lineTo(h,o);const l=Math.abs(a)*s;let c=Math.ceil(l/10);c>2048&&(c=2048),c<8&&(c=8);for(let u=1;u<=c;u++){const i=r+a*(u/c),n=t+Math.cos(i)*s,h=e+Math.sin(i)*s;this.lineTo(n,h)}return this};arcTo=(t,e,s,r,i)=>{if(!this.currentPath)return this;const n=this.currentPath.points.length;if(0===n||0===i)return this.lineTo(t,e),this;const a=this.currentPath.points[n-1]-e,h=this.currentPath.points[n-2]-t,o=r-e,l=s-t,c=a*l-h*o,u=Math.abs(c);if(u<1e-8)return this.lineTo(t,e),this;const f=a*a+h*h,p=o*o+l*l,d=a*o+h*l,g=i*Math.sqrt(f)/u,x=i*Math.sqrt(p)/u,v=g*d/f,y=x*d/p,m=g*l+x*h,b=g*o+x*a,w=h*(x+v),E=a*(x+v),_=l*(g+y),M=o*(g+y),T=Math.atan2(E-b,w-m),P=Math.atan2(M-b,_-m),A=h*o>l*a;return this.arc(m+t,b+e,i,T,P,A)};clear=()=>(this.geometry.clear(),this._lineStyle.reset(),this._fillStyle.reset(),this.currentPath=new Z,this.batches=[],this.batchCount=0,this.markStructureDirty(),this);renderCanvas=t=>{this.startPoly();const e=t.ctx,{a:s,b:r,c:i,d:n,tx:a,ty:h}=this.transform.worldTransform;e.setTransform(s,r,i,n,a,h);const o=this.geometry.graphicsData;for(let l=0;l<o.length;l++){const{lineStyle:t,fillStyle:s,shape:r}=o[l];if(s.visible&&(e.fillStyle=s.color),t.visible&&(e.lineWidth=t.width,e.lineCap=t.cap,e.lineJoin=t.join,e.strokeStyle=t.color),e.beginPath(),r instanceof f){const{x:i,y:n,width:a,height:h}=r;s.visible&&(e.globalAlpha=s.alpha*this.worldAlpha,e.fillRect(i,n,a,h)),t.visible&&(e.globalAlpha=t.alpha*this.worldAlpha,e.strokeRect(i,n,a,h))}if(r instanceof Gt){const{x:i,y:n,radius:a}=r;e.arc(i,n,a,0,2*Math.PI),s.visible&&(e.globalAlpha=s.alpha*this.worldAlpha,e.fill()),t.visible&&(e.globalAlpha=t.alpha*this.worldAlpha,e.stroke())}if(r instanceof Yt){const{x:i,y:n,width:a,height:h,radius:o}=r;e.moveTo(i+o,n),e.arc(i+o,n+o,o,1.5*Math.PI,Math.PI,!0),e.lineTo(i,n+h-o),e.arc(i+o,n+h-o,o,Math.PI,Math.PI/2,!0),e.lineTo(i+a-o,n+h),e.arc(i+a-o,n+h-o,o,Math.PI/2,0,!0),e.lineTo(i+a,n+o),e.arc(i+a-o,n+o,o,0,1.5*Math.PI,!0),e.closePath(),s.visible&&(e.globalAlpha=s.alpha*this.worldAlpha,e.fill()),t.visible&&(e.globalAlpha=t.alpha*this.worldAlpha,e.stroke())}if(r instanceof kt){const{x:i,y:n,radiusX:a,radiusY:h}=r;e.ellipse(i,n,a,h,0,0,2*Math.PI),s.visible&&(e.globalAlpha=s.alpha*this.worldAlpha,e.fill()),t.visible&&(e.globalAlpha=t.alpha*this.worldAlpha,e.stroke())}if(r instanceof Z){const{points:i,closeStroke:n}=r;e.moveTo(i[0],i[1]);for(let t=2;t<i.length;t+=2)e.lineTo(i[t],i[t+1]);n&&e.closePath(),s.visible&&(e.globalAlpha=s.alpha*this.worldAlpha,e.fill()),t.visible&&(e.globalAlpha=t.alpha*this.worldAlpha,e.stroke())}}};buildBatches=t=>{this.startPoly(),this.worldId=this.transform.worldId,this.geometry.buildVerticesAndTriangulate();const e=this.geometry.batchParts;for(let s=0;s<e.length;s++){const{style:r,vertexStart:i,vertexCount:n,indexStart:a,indexCount:h}=e[s],{color:o,alpha:l}=r,c=S(o,l*this.worldAlpha),u=E.get(this.type);u.vertexCount=n,u.indexCount=h,u.rgba=c,u.vertexOffset=i,u.indexOffset=a,u.graphics=this,this.batches[s]=u,t.addBatch(this.batches[s])}this.batchCount=e.length};updateBatches=t=>{if(this.worldId!==this.transform.worldId){this.worldId=this.transform.worldId;for(let e=0;e<this.batchCount;e++)this.batches[e].updateVertices(t)}}};function Kt(t,e,s){const r=t.createShader(s);if(t.shaderSource(r,e),t.compileShader(r),!t.getShaderParameter(r,t.COMPILE_STATUS)){const e=t.getShaderInfoLog(r);throw t.deleteShader(r),new Error(`Filter shader compile failed: ${e}`)}return r}var Jt=class{uniforms;fragmentSource;program=null;aPos=-1;locs=/* @__PURE__ */new Map;constructor(t="\nprecision mediump float;\nuniform sampler2D u_texture;\nvarying vec2 v_uv;\nvoid main() {\n gl_FragColor = texture2D(u_texture, v_uv);\n}",e={}){this.fragmentSource=t,this.uniforms=e}ensureProgram(t){if(this.program)return this.program;const e=t.createProgram();if(t.attachShader(e,Kt(t,"\nattribute vec2 a_pos;\nvarying vec2 v_uv;\nvoid main() {\n v_uv = a_pos * 0.5 + 0.5;\n gl_Position = vec4(a_pos, 0.0, 1.0);\n}",t.VERTEX_SHADER)),t.attachShader(e,Kt(t,this.fragmentSource,t.FRAGMENT_SHADER)),t.linkProgram(e),!t.getProgramParameter(e,t.LINK_STATUS))throw new Error(`Filter program link failed: ${t.getProgramInfoLog(e)}`);return this.program=e,this.aPos=t.getAttribLocation(e,"a_pos"),e}loc(t,e){return this.locs.has(e)||this.locs.set(e,t.getUniformLocation(this.program,e)),this.locs.get(e)??null}apply(t,e,s,r,i,n){const a=this.ensureProgram(t);r?r.bind():(t.bindFramebuffer(t.FRAMEBUFFER,null),t.viewport(0,0,i,n)),t.useProgram(a),t.bindBuffer(t.ARRAY_BUFFER,e),t.enableVertexAttribArray(this.aPos),t.vertexAttribPointer(this.aPos,2,t.FLOAT,!1,0,0),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,s);const h=this.loc(t,"u_texture");h&&t.uniform1i(h,0);const o=this.loc(t,"u_resolution");o&&t.uniform2f(o,i,n);for(const l in this.uniforms){const e=this.loc(t,l);if(!e)continue;const s=this.uniforms[l];"number"==typeof s?t.uniform1f(e,s):2===s.length?t.uniform2fv(e,s):3===s.length?t.uniform3fv(e,s):4===s.length&&t.uniform4fv(e,s)}t.clear(t.COLOR_BUFFER_BIT),t.drawArrays(t.TRIANGLE_STRIP,0,4)}dispose(t){this.program&&t.deleteProgram(this.program),this.program=null,this.locs.clear()}},te=class extends Jt{constructor(t={}){super("\nprecision mediump float;\nuniform sampler2D u_texture;\nuniform float u_brightness;\nuniform float u_contrast;\nuniform float u_saturation;\nvarying vec2 v_uv;\nvoid main() {\n vec4 c = texture2D(u_texture, v_uv);\n vec3 rgb = (c.rgb - 0.5) * u_contrast + 0.5 + u_brightness;\n float grey = dot(rgb, vec3(0.2125, 0.7154, 0.0721));\n rgb = mix(vec3(grey), rgb, u_saturation);\n gl_FragColor = vec4(clamp(rgb, 0.0, 1.0), c.a);\n}",{u_brightness:t.brightness??0,u_contrast:t.contrast??1,u_saturation:t.saturation??1})}set brightness(t){this.uniforms.u_brightness=t}set contrast(t){this.uniforms.u_contrast=t}set saturation(t){this.uniforms.u_saturation=t}};export{X as Application,c as BYTES_PER_VERTEX,te as ColorAdjustFilter,k as Container,Jt as Filter,Qt as Graphics,a as LINE_CAP,h as LINE_JOIN,l as MAX_VERTEX_COUNT,o as RENDERER_TYPE,n as SHAPE_TYPE,U as WebGLRenderTarget};
|
|
1
|
+
import { BYTES_PER_VERTEX as o, LINE_CAP as E, LINE_JOIN as t, MAX_VERTEX_COUNT as i, RENDERER_TYPE as m, SHAPE_TYPE as p } from "./enums.js";
|
|
2
|
+
import { WebGLRenderTarget as _ } from "./render/renderTarget.js";
|
|
3
|
+
import { Container as T } from "./vertex/container.js";
|
|
4
|
+
import { Application as A } from "./application.js";
|
|
5
|
+
import { Graphics as P } from "./graphics/graphics.js";
|
|
6
|
+
import { ColorAdjustFilter as l, Filter as n } from "./render/filter.js";
|
|
7
|
+
export {
|
|
8
|
+
A as Application,
|
|
9
|
+
o as BYTES_PER_VERTEX,
|
|
10
|
+
l as ColorAdjustFilter,
|
|
11
|
+
T as Container,
|
|
12
|
+
n as Filter,
|
|
13
|
+
P as Graphics,
|
|
14
|
+
E as LINE_CAP,
|
|
15
|
+
t as LINE_JOIN,
|
|
16
|
+
i as MAX_VERTEX_COUNT,
|
|
17
|
+
m as RENDERER_TYPE,
|
|
18
|
+
p as SHAPE_TYPE,
|
|
19
|
+
_ as WebGLRenderTarget
|
|
20
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
var u = (a, e, M, g, i, y, r, c) => {
|
|
2
|
+
let o = a, s = e, n = 0;
|
|
3
|
+
for (let h = 1; h <= 10; h++) {
|
|
4
|
+
const t = h / 10, q = (1 - t) * (1 - t) * (1 - t) * a + 3 * t * (1 - t) * (1 - t) * M + 3 * t * t * (1 - t) * i + t * t * t * r, x = (1 - t) * (1 - t) * (1 - t) * e + 3 * t * (1 - t) * (1 - t) * g + 3 * t * t * (1 - t) * y + t * t * t * c, b = q - o, d = x - s;
|
|
5
|
+
n += Math.sqrt(b * b + d * d), o = q, s = x;
|
|
6
|
+
}
|
|
7
|
+
return n;
|
|
8
|
+
}, B = (a, e, M, g, i, y) => {
|
|
9
|
+
const r = 2 * (a - 2 * M + i), c = -2 * (a - M), l = 2 * (e - 2 * g + y), o = -2 * (e - g), s = r * r + l * l, n = 2 * (r * c + l * o), h = c * c + o * o, t = Math.sqrt((4 * s * h - n * n) / 4), q = (s / 2 + n / 4) * Math.sqrt((s + n / 2) * (s + n / 2) + t * t) + t * t / 2 * Math.log(Math.abs(s + n / 2 + Math.sqrt((s + n / 2) * (s + n / 2) + t * t))), x = n / 4 * Math.sqrt(n * n / 4 + t * t) + t * t / 2 * Math.log(n / 2 + Math.sqrt(n * n / 4 + t * t));
|
|
10
|
+
return 1 / (Math.sqrt(s) * s) * (q - x);
|
|
11
|
+
};
|
|
12
|
+
export {
|
|
13
|
+
u as getBezierLength,
|
|
14
|
+
B as getQuadraticBezierLength
|
|
15
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { getBezierLength, getQuadraticBezierLength } from
|
|
2
|
-
import { DEG_TO_RAD, PI_2, RAD_TO_DEG } from
|
|
3
|
-
import { Matrix } from
|
|
4
|
-
import { Transform } from
|
|
1
|
+
import { getBezierLength, getQuadraticBezierLength } from "./bezier.js";
|
|
2
|
+
import { DEG_TO_RAD, PI_2, RAD_TO_DEG } from "./enums.js";
|
|
3
|
+
import { Matrix } from "./matrix.js";
|
|
4
|
+
import { Transform } from "./transform.js";
|
|
5
5
|
export { getBezierLength, getQuadraticBezierLength, DEG_TO_RAD, PI_2, RAD_TO_DEG, Matrix, Transform };
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { PI_2 as M } from "./enums.js";
|
|
2
|
+
import { Point as r } from "../vertex/point.js";
|
|
3
|
+
var w = class u {
|
|
4
|
+
a;
|
|
5
|
+
b;
|
|
6
|
+
c;
|
|
7
|
+
d;
|
|
8
|
+
tx;
|
|
9
|
+
ty;
|
|
10
|
+
array = null;
|
|
11
|
+
constructor(t = 1, i = 0, s = 0, h = 1, c = 0, a = 0) {
|
|
12
|
+
this.a = t, this.b = i, this.c = s, this.d = h, this.tx = c, this.ty = a;
|
|
13
|
+
}
|
|
14
|
+
set = (t, i, s, h, c, a) => (this.a = t, this.b = i, this.c = s, this.d = h, this.tx = c, this.ty = a, this);
|
|
15
|
+
append = (t) => {
|
|
16
|
+
const { a: i, b: s, c: h, d: c, tx: a, ty: y } = this, { a: n, b: e, c: x, d, tx: o, ty: b } = t;
|
|
17
|
+
return this.a = i * n + h * e, this.b = s * n + c * e, this.c = i * x + h * d, this.d = s * x + c * d, this.tx = i * o + h * b + a, this.ty = s * o + c * b + y, this;
|
|
18
|
+
};
|
|
19
|
+
fromArray = (t) => {
|
|
20
|
+
this.a = t[0], this.b = t[1], this.c = t[3], this.d = t[4], this.tx = t[2], this.ty = t[5];
|
|
21
|
+
};
|
|
22
|
+
translate = (t, i) => (this.tx += t, this.ty += i, this);
|
|
23
|
+
scale = (t, i) => (this.a *= t, this.d *= i, this.c *= t, this.b *= i, this.tx *= t, this.ty *= i, this);
|
|
24
|
+
setTransform = (t, i, s, h, c, a, y, n, e) => (this.a = Math.cos(y + e) * c, this.b = Math.sin(y + e) * c, this.c = -Math.sin(y - n) * a, this.d = Math.cos(y - n) * a, this.tx = t - (s * this.a + h * this.c), this.ty = i - (s * this.b + h * this.d), this);
|
|
25
|
+
rotate = (t) => {
|
|
26
|
+
const i = Math.cos(t), s = Math.sin(t), h = this.a, c = this.c, a = this.tx;
|
|
27
|
+
return this.a = h * i - this.b * s, this.b = h * s + this.b * i, this.c = c * i - this.d * s, this.d = c * s + this.d * i, this.tx = a * i - this.ty * s, this.ty = a * s + this.ty * i, this;
|
|
28
|
+
};
|
|
29
|
+
equals = (t) => t.a === this.a && t.b === this.b && t.c === this.c && t.d === this.d && t.tx === this.tx && t.ty === this.ty;
|
|
30
|
+
identity = () => (this.a = 1, this.b = 0, this.c = 0, this.d = 1, this.tx = 0, this.ty = 0, this);
|
|
31
|
+
decompose = (t) => {
|
|
32
|
+
const i = this.a, s = this.b, h = this.c, c = this.d, a = t.pivot, y = -Math.atan2(-h, c), n = Math.atan2(s, i), e = Math.abs(y + n);
|
|
33
|
+
return e < 1e-5 || Math.abs(M - e) < 1e-5 ? (t.rotation = n, t.skew.x = t.skew.y = 0) : (t.rotation = 0, t.skew.x = y, t.skew.y = n), t.scale.x = Math.sqrt(i * i + s * s), t.scale.y = Math.sqrt(h * h + c * c), t.position.x = this.tx + (a.x * i + a.y * h), t.position.y = this.ty + (a.x * s + a.y * c), t;
|
|
34
|
+
};
|
|
35
|
+
apply = (t) => {
|
|
36
|
+
const i = new r(), s = t.x, h = t.y;
|
|
37
|
+
return i.x = this.a * s + this.c * h + this.tx, i.y = this.b * s + this.d * h + this.ty, i;
|
|
38
|
+
};
|
|
39
|
+
applyInverse = (t) => {
|
|
40
|
+
const i = new r(), s = 1 / (this.a * this.d + this.c * -this.b), h = t.x, c = t.y;
|
|
41
|
+
return i.x = this.d * s * h + -this.c * s * c + (this.ty * this.c - this.tx * this.d) * s, i.y = this.a * s * c + -this.b * s * h + (-this.ty * this.a + this.tx * this.b) * s, i;
|
|
42
|
+
};
|
|
43
|
+
prepend = (t) => {
|
|
44
|
+
const { a: i, b: s, c: h, d: c, tx: a, ty: y } = t, { a: n, b: e, c: x, d, tx: o, ty: b } = this;
|
|
45
|
+
return this.a = i * n + h * e, this.b = s * n + c * e, this.c = i * x + h * d, this.d = s * x + c * d, this.tx = i * o + h * b + a, this.ty = s * o + c * b + y, this;
|
|
46
|
+
};
|
|
47
|
+
clone = () => {
|
|
48
|
+
const t = new u();
|
|
49
|
+
return t.a = this.a, t.b = this.b, t.c = this.c, t.d = this.d, t.tx = this.tx, t.ty = this.ty, t;
|
|
50
|
+
};
|
|
51
|
+
toArray = (t, i) => {
|
|
52
|
+
this.array || (this.array = /* @__PURE__ */ new Float32Array(9));
|
|
53
|
+
const s = i || this.array;
|
|
54
|
+
return t ? (s[0] = this.a, s[1] = this.b, s[2] = 0, s[3] = this.c, s[4] = this.d, s[5] = 0, s[6] = this.tx, s[7] = this.ty, s[8] = 1) : (s[0] = this.a, s[1] = this.c, s[2] = this.tx, s[3] = this.b, s[4] = this.d, s[5] = this.ty, s[6] = 0, s[7] = 0, s[8] = 1), s;
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
export {
|
|
58
|
+
w as Matrix
|
|
59
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Matrix } from
|
|
2
|
-
import { ObservablePoint } from
|
|
1
|
+
import { Matrix } from "./matrix.js";
|
|
2
|
+
import { ObservablePoint } from "../vertex/point.js";
|
|
3
3
|
export declare class Transform {
|
|
4
4
|
localTransform: Matrix;
|
|
5
5
|
worldTransform: Matrix;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { ObservablePoint as e } from "../vertex/point.js";
|
|
2
|
+
import { Matrix as i } from "./matrix.js";
|
|
3
|
+
var m = class {
|
|
4
|
+
localTransform = new i();
|
|
5
|
+
worldTransform = new i();
|
|
6
|
+
position;
|
|
7
|
+
scale;
|
|
8
|
+
pivot;
|
|
9
|
+
skew;
|
|
10
|
+
_rotation = 0;
|
|
11
|
+
rotateMatrix = new i();
|
|
12
|
+
skewMatrix = new i();
|
|
13
|
+
scaleMatrix = new i();
|
|
14
|
+
localMatrix = new i();
|
|
15
|
+
shouldUpdateLocalTransform = !1;
|
|
16
|
+
worldId = 0;
|
|
17
|
+
parentId = 0;
|
|
18
|
+
constructor() {
|
|
19
|
+
this.position = new e(this.onChange), this.scale = new e(this.onScaleChange, 1, 1), this.pivot = new e(this.onChange), this.skew = new e(this.onSkewChange);
|
|
20
|
+
}
|
|
21
|
+
get rotation() {
|
|
22
|
+
return this._rotation;
|
|
23
|
+
}
|
|
24
|
+
set rotation(t) {
|
|
25
|
+
this._rotation = t, this.rotateMatrix.set(Math.cos(this.rotation), Math.sin(this.rotation), -Math.sin(this.rotation), Math.cos(this.rotation), 0, 0), this.shouldUpdateLocalTransform = !0;
|
|
26
|
+
}
|
|
27
|
+
onSkewChange = (t, o) => {
|
|
28
|
+
this.skewMatrix.set(Math.cos(o), Math.sin(o), Math.sin(t), Math.cos(t), 0, 0), this.shouldUpdateLocalTransform = !0;
|
|
29
|
+
};
|
|
30
|
+
onScaleChange = (t, o) => {
|
|
31
|
+
this.scaleMatrix.set(t, 0, 0, o, 0, 0), this.shouldUpdateLocalTransform = !0;
|
|
32
|
+
};
|
|
33
|
+
onChange = () => {
|
|
34
|
+
this.shouldUpdateLocalTransform = !0;
|
|
35
|
+
};
|
|
36
|
+
updateLocalTransform() {
|
|
37
|
+
if (!this.shouldUpdateLocalTransform) return;
|
|
38
|
+
const { a: t, b: o, c: s, d: a } = this.localMatrix.set(1, 0, 0, 1, 0, 0).append(this.rotateMatrix).append(this.skewMatrix).append(this.scaleMatrix), r = t * this.pivot.x + s * this.pivot.y, h = o * this.pivot.x + a * this.pivot.y, l = this.position.x - r, n = this.position.y - h;
|
|
39
|
+
this.localTransform.set(t, o, s, a, l, n), this.shouldUpdateLocalTransform = !1, this.parentId = -1;
|
|
40
|
+
}
|
|
41
|
+
updateTransform(t) {
|
|
42
|
+
if (this.updateLocalTransform(), this.parentId !== t.worldId) {
|
|
43
|
+
const { a: o, b: s, c: a, d: r, tx: h, ty: l } = t.worldTransform, { a: n, b: c, c: d, d: p, tx: w, ty: f } = this.localTransform;
|
|
44
|
+
this.worldTransform.set(o * n + a * c, s * n + r * c, o * d + a * p, s * d + r * p, o * w + a * f + h, s * w + r * f + l), this.parentId = t.worldId, this.worldId++;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
export {
|
|
49
|
+
m as Transform
|
|
50
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Renderer } from
|
|
2
|
-
import type { Container } from
|
|
3
|
-
import type { Batch } from
|
|
4
|
-
import type { IApplicationOptions } from
|
|
1
|
+
import { Renderer } from "./render.js";
|
|
2
|
+
import type { Container } from "../vertex/container.js";
|
|
3
|
+
import type { Batch } from "./utils/batch/index.js";
|
|
4
|
+
import type { IApplicationOptions } from "../types.js";
|
|
5
5
|
export declare abstract class BatchRenderer extends Renderer {
|
|
6
6
|
/**
|
|
7
7
|
* The scene structure version at the last rebuild, held per renderer instance. When it
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import "../enums.js";
|
|
2
|
+
import { Renderer as d } from "./render.js";
|
|
3
|
+
import { batchPool as f, buildArray as o, updateArray as l } from "./utils/batch/index.js";
|
|
4
|
+
var B = class extends d {
|
|
5
|
+
builtVersion = -1;
|
|
6
|
+
vertexCount = 0;
|
|
7
|
+
indexCount = 0;
|
|
8
|
+
batches = [];
|
|
9
|
+
batchesCount = 0;
|
|
10
|
+
vertFloatView;
|
|
11
|
+
vertIntView;
|
|
12
|
+
indexBuffer;
|
|
13
|
+
curVertBufferLength = 0;
|
|
14
|
+
curIndexBufferLength = 0;
|
|
15
|
+
constructor(t) {
|
|
16
|
+
super(t);
|
|
17
|
+
const e = /* @__PURE__ */ new ArrayBuffer(256 * 12);
|
|
18
|
+
this.vertFloatView = new Float32Array(e), this.vertIntView = new Uint32Array(e), this.indexBuffer = /* @__PURE__ */ new Uint32Array(256);
|
|
19
|
+
}
|
|
20
|
+
addBatch(t) {
|
|
21
|
+
t.vertexStart = this.vertexCount, t.indexStart = this.indexCount, this.vertexCount += t.vertexCount, this.indexCount += t.indexCount, this.batches[this.batchesCount] = t, this.batchesCount++;
|
|
22
|
+
}
|
|
23
|
+
startBuild() {
|
|
24
|
+
this.vertexCount = 0, this.indexCount = 0, this.batchesCount = 0, f.reset();
|
|
25
|
+
}
|
|
26
|
+
buildEnd() {
|
|
27
|
+
this.resizeBufferIfNeeded(), this.packData();
|
|
28
|
+
}
|
|
29
|
+
resizeBufferIfNeeded() {
|
|
30
|
+
if (this.vertexCount * 12 > this.vertFloatView.byteLength) {
|
|
31
|
+
const t = new ArrayBuffer(this.vertexCount * 12);
|
|
32
|
+
this.vertFloatView = new Float32Array(t), this.vertIntView = new Uint32Array(t);
|
|
33
|
+
}
|
|
34
|
+
this.indexCount > this.indexBuffer.length && (this.indexBuffer = new Uint32Array(this.indexCount));
|
|
35
|
+
}
|
|
36
|
+
packData() {
|
|
37
|
+
for (let t = 0; t < this.batchesCount; t++) {
|
|
38
|
+
const e = this.batches[t];
|
|
39
|
+
this.batches[t] = void 0, e?.packVertices(this.vertFloatView, this.vertIntView), e?.packIndices(this.indexBuffer);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
updateChildrenTransform(t) {
|
|
43
|
+
t.sortChildren();
|
|
44
|
+
const e = t.transform.shouldUpdateLocalTransform;
|
|
45
|
+
if (t.transform.updateLocalTransform(), e) {
|
|
46
|
+
const { a: r, b: s, c: n, d: h, tx: a, ty: u } = t.transform.localTransform;
|
|
47
|
+
this.setRootTransform(r, s, n, h, a, u);
|
|
48
|
+
}
|
|
49
|
+
t.worldAlpha = t.alpha;
|
|
50
|
+
const i = t.children;
|
|
51
|
+
for (let r = 0; r < i.length; r++) i[r].updateTransform();
|
|
52
|
+
}
|
|
53
|
+
render(t) {
|
|
54
|
+
this.updateChildrenTransform(t), this.builtVersion !== t.structureVersion ? (this.startBuild(), o(this, t), this.buildEnd(), this.builtVersion = t.structureVersion) : l(this.vertFloatView, t), this.updateBuffer(), this.draw();
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
export {
|
|
58
|
+
B as BatchRenderer
|
|
59
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Renderer } from
|
|
2
|
-
import type { IApplicationOptions } from
|
|
3
|
-
import type { Container } from
|
|
1
|
+
import { Renderer } from "./render.js";
|
|
2
|
+
import type { IApplicationOptions } from "../types.js";
|
|
3
|
+
import type { Container } from "../vertex/container.js";
|
|
4
4
|
export declare class CanvasRenderer extends Renderer {
|
|
5
5
|
ctx: CanvasRenderingContext2D;
|
|
6
6
|
private backgroundColor;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Renderer as s } from "./render.js";
|
|
2
|
+
var c = class extends s {
|
|
3
|
+
ctx;
|
|
4
|
+
backgroundColor;
|
|
5
|
+
backgroundAlpha;
|
|
6
|
+
constructor(t) {
|
|
7
|
+
super(t), t.debug;
|
|
8
|
+
const { backgroundColor: r, backgroundAlpha: e } = t;
|
|
9
|
+
this.backgroundColor = r, this.backgroundAlpha = e, this.ctx = this.canvasEle.getContext("2d");
|
|
10
|
+
}
|
|
11
|
+
render(t) {
|
|
12
|
+
t.updateTransform(), this.ctx.save(), this.ctx.clearRect(0, 0, this.screen.width, this.screen.height), this.backgroundAlpha && (this.ctx.globalAlpha = this.backgroundAlpha), this.backgroundColor && (this.ctx.fillStyle = this.backgroundColor), this.ctx.fillRect(0, 0, this.screen.width, this.screen.height), t.renderCanvasRecursive(this), this.ctx.restore();
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
export {
|
|
16
|
+
c as CanvasRenderer
|
|
17
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { WebGLRenderTarget } from
|
|
1
|
+
import type { WebGLRenderTarget } from "./renderTarget.js";
|
|
2
2
|
type UniformValue = number | number[];
|
|
3
3
|
/**
|
|
4
4
|
* A full-screen post-processing pass. Sample the previous pass through `u_texture` (and
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
var _ = `
|
|
2
|
+
attribute vec2 a_pos;
|
|
3
|
+
varying vec2 v_uv;
|
|
4
|
+
void main() {
|
|
5
|
+
v_uv = a_pos * 0.5 + 0.5;
|
|
6
|
+
gl_Position = vec4(a_pos, 0.0, 1.0);
|
|
7
|
+
}`, v = `
|
|
8
|
+
precision mediump float;
|
|
9
|
+
uniform sampler2D u_texture;
|
|
10
|
+
varying vec2 v_uv;
|
|
11
|
+
void main() {
|
|
12
|
+
gl_FragColor = texture2D(u_texture, v_uv);
|
|
13
|
+
}`;
|
|
14
|
+
function m(r, t, a) {
|
|
15
|
+
const e = r.createShader(a);
|
|
16
|
+
if (r.shaderSource(e, t), r.compileShader(e), !r.getShaderParameter(e, r.COMPILE_STATUS)) {
|
|
17
|
+
const s = r.getShaderInfoLog(e);
|
|
18
|
+
throw r.deleteShader(e), new Error(`Filter shader compile failed: ${s}`);
|
|
19
|
+
}
|
|
20
|
+
return e;
|
|
21
|
+
}
|
|
22
|
+
var p = class {
|
|
23
|
+
uniforms;
|
|
24
|
+
fragmentSource;
|
|
25
|
+
program = null;
|
|
26
|
+
aPos = -1;
|
|
27
|
+
locs = /* @__PURE__ */ new Map();
|
|
28
|
+
constructor(r = v, t = {}) {
|
|
29
|
+
this.fragmentSource = r, this.uniforms = t;
|
|
30
|
+
}
|
|
31
|
+
ensureProgram(r) {
|
|
32
|
+
if (this.program) return this.program;
|
|
33
|
+
const t = r.createProgram();
|
|
34
|
+
if (r.attachShader(t, m(r, _, r.VERTEX_SHADER)), r.attachShader(t, m(r, this.fragmentSource, r.FRAGMENT_SHADER)), r.linkProgram(t), !r.getProgramParameter(t, r.LINK_STATUS)) throw new Error(`Filter program link failed: ${r.getProgramInfoLog(t)}`);
|
|
35
|
+
return this.program = t, this.aPos = r.getAttribLocation(t, "a_pos"), t;
|
|
36
|
+
}
|
|
37
|
+
loc(r, t) {
|
|
38
|
+
return this.locs.has(t) || this.locs.set(t, r.getUniformLocation(this.program, t)), this.locs.get(t) ?? null;
|
|
39
|
+
}
|
|
40
|
+
apply(r, t, a, e, s, n) {
|
|
41
|
+
const h = this.ensureProgram(r);
|
|
42
|
+
e ? e.bind() : (r.bindFramebuffer(r.FRAMEBUFFER, null), r.viewport(0, 0, s, n)), r.useProgram(h), r.bindBuffer(r.ARRAY_BUFFER, t), r.enableVertexAttribArray(this.aPos), r.vertexAttribPointer(this.aPos, 2, r.FLOAT, !1, 0, 0), r.activeTexture(r.TEXTURE0), r.bindTexture(r.TEXTURE_2D, a);
|
|
43
|
+
const u = this.loc(r, "u_texture");
|
|
44
|
+
u && r.uniform1i(u, 0);
|
|
45
|
+
const c = this.loc(r, "u_resolution");
|
|
46
|
+
c && r.uniform2f(c, s, n);
|
|
47
|
+
for (const f in this.uniforms) {
|
|
48
|
+
const i = this.loc(r, f);
|
|
49
|
+
if (!i) continue;
|
|
50
|
+
const o = this.uniforms[f];
|
|
51
|
+
typeof o == "number" ? r.uniform1f(i, o) : o.length === 2 ? r.uniform2fv(i, o) : o.length === 3 ? r.uniform3fv(i, o) : o.length === 4 && r.uniform4fv(i, o);
|
|
52
|
+
}
|
|
53
|
+
r.clear(r.COLOR_BUFFER_BIT), r.drawArrays(r.TRIANGLE_STRIP, 0, 4);
|
|
54
|
+
}
|
|
55
|
+
dispose(r) {
|
|
56
|
+
this.program && r.deleteProgram(this.program), this.program = null, this.locs.clear();
|
|
57
|
+
}
|
|
58
|
+
}, d = `
|
|
59
|
+
precision mediump float;
|
|
60
|
+
uniform sampler2D u_texture;
|
|
61
|
+
uniform float u_brightness;
|
|
62
|
+
uniform float u_contrast;
|
|
63
|
+
uniform float u_saturation;
|
|
64
|
+
varying vec2 v_uv;
|
|
65
|
+
void main() {
|
|
66
|
+
vec4 c = texture2D(u_texture, v_uv);
|
|
67
|
+
vec3 rgb = (c.rgb - 0.5) * u_contrast + 0.5 + u_brightness;
|
|
68
|
+
float grey = dot(rgb, vec3(0.2125, 0.7154, 0.0721));
|
|
69
|
+
rgb = mix(vec3(grey), rgb, u_saturation);
|
|
70
|
+
gl_FragColor = vec4(clamp(rgb, 0.0, 1.0), c.a);
|
|
71
|
+
}`, b = class extends p {
|
|
72
|
+
constructor(r = {}) {
|
|
73
|
+
super(d, {
|
|
74
|
+
u_brightness: r.brightness ?? 0,
|
|
75
|
+
u_contrast: r.contrast ?? 1,
|
|
76
|
+
u_saturation: r.saturation ?? 1
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
set brightness(r) {
|
|
80
|
+
this.uniforms.u_brightness = r;
|
|
81
|
+
}
|
|
82
|
+
set contrast(r) {
|
|
83
|
+
this.uniforms.u_contrast = r;
|
|
84
|
+
}
|
|
85
|
+
set saturation(r) {
|
|
86
|
+
this.uniforms.u_saturation = r;
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
export {
|
|
90
|
+
b as ColorAdjustFilter,
|
|
91
|
+
p as Filter
|
|
92
|
+
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { Renderer } from
|
|
2
|
-
import type { IApplicationOptions } from
|
|
1
|
+
import type { Renderer } from "./render.js";
|
|
2
|
+
import type { IApplicationOptions } from "../types.js";
|
|
3
3
|
export declare const getRenderer: (options: IApplicationOptions) => Renderer;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { RENDERER_TYPE as r } from "../enums.js";
|
|
2
|
+
import { CanvasRenderer as n } from "./canvasRenderer.js";
|
|
3
|
+
import { WebGLRenderer as m } from "./webGlRenderer.js";
|
|
4
|
+
import { WebGPURenderer as a } from "./webGPURenderer.js";
|
|
5
|
+
var c = (e) => {
|
|
6
|
+
const { prefer: t } = e;
|
|
7
|
+
switch (t) {
|
|
8
|
+
case r.CANVAS:
|
|
9
|
+
return new n(e);
|
|
10
|
+
case r.WEB_GL:
|
|
11
|
+
return new m(e);
|
|
12
|
+
case r.WEB_GPU:
|
|
13
|
+
return new a(e);
|
|
14
|
+
default:
|
|
15
|
+
return new n(e);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
export {
|
|
19
|
+
c as getRenderer
|
|
20
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Rectangle } from
|
|
2
|
-
import type { Container } from
|
|
3
|
-
import type { Filter } from
|
|
4
|
-
import type { IApplicationOptions } from
|
|
1
|
+
import { Rectangle } from "../shape/rectangle.js";
|
|
2
|
+
import type { Container } from "../vertex/container.js";
|
|
3
|
+
import type { Filter } from "./filter.js";
|
|
4
|
+
import type { IApplicationOptions } from "../types.js";
|
|
5
5
|
export declare abstract class Renderer {
|
|
6
6
|
canvasEle: HTMLCanvasElement;
|
|
7
7
|
screen: Rectangle;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Rectangle as t } from "../shape/rectangle.js";
|
|
2
|
+
var r = class {
|
|
3
|
+
canvasEle;
|
|
4
|
+
screen = new t();
|
|
5
|
+
filters = [];
|
|
6
|
+
constructor(s) {
|
|
7
|
+
const { view: e } = s;
|
|
8
|
+
this.canvasEle = e, this.screen.width = e.width, this.screen.height = e.height;
|
|
9
|
+
}
|
|
10
|
+
resizeView(s, e) {
|
|
11
|
+
this.canvasEle.width = s, this.canvasEle.height = e;
|
|
12
|
+
}
|
|
13
|
+
async init() {
|
|
14
|
+
return Promise.resolve();
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
export {
|
|
18
|
+
r as Renderer
|
|
19
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
var E = class {
|
|
2
|
+
gl;
|
|
3
|
+
framebuffer;
|
|
4
|
+
texture;
|
|
5
|
+
width = 0;
|
|
6
|
+
height = 0;
|
|
7
|
+
constructor(t) {
|
|
8
|
+
this.gl = t;
|
|
9
|
+
const e = this.gl;
|
|
10
|
+
this.texture = e.createTexture(), e.bindTexture(e.TEXTURE_2D, this.texture), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_MIN_FILTER, e.LINEAR), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_MAG_FILTER, e.LINEAR), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_WRAP_S, e.CLAMP_TO_EDGE), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_WRAP_T, e.CLAMP_TO_EDGE), this.framebuffer = e.createFramebuffer(), e.bindFramebuffer(e.FRAMEBUFFER, this.framebuffer), e.framebufferTexture2D(e.FRAMEBUFFER, e.COLOR_ATTACHMENT0, e.TEXTURE_2D, this.texture, 0), e.bindFramebuffer(e.FRAMEBUFFER, null);
|
|
11
|
+
}
|
|
12
|
+
resize(t, e) {
|
|
13
|
+
if (t === this.width && e === this.height) return;
|
|
14
|
+
this.width = t, this.height = e;
|
|
15
|
+
const r = this.gl;
|
|
16
|
+
r.bindTexture(r.TEXTURE_2D, this.texture), r.texImage2D(r.TEXTURE_2D, 0, r.RGBA, t, e, 0, r.RGBA, r.UNSIGNED_BYTE, null);
|
|
17
|
+
}
|
|
18
|
+
bind() {
|
|
19
|
+
const t = this.gl;
|
|
20
|
+
t.bindFramebuffer(t.FRAMEBUFFER, this.framebuffer), t.viewport(0, 0, this.width, this.height);
|
|
21
|
+
}
|
|
22
|
+
dispose() {
|
|
23
|
+
this.gl.deleteFramebuffer(this.framebuffer), this.gl.deleteTexture(this.texture);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
export {
|
|
27
|
+
E as WebGLRenderTarget
|
|
28
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { BatchRenderer } from
|
|
2
|
-
import type { Container } from
|
|
3
|
-
import type { Fill } from
|
|
4
|
-
import type { Graphics } from
|
|
1
|
+
import type { BatchRenderer } from "../../batchRenderer.js";
|
|
2
|
+
import type { Container } from "../../../vertex/container.js";
|
|
3
|
+
import type { Fill } from "../../../style/index.js";
|
|
4
|
+
import type { Graphics } from "../../../graphics/index.js";
|
|
5
5
|
/**
|
|
6
6
|
* Build the big array
|
|
7
7
|
*/
|