ranuts 0.1.0-alpha.9 → 0.2.0-alpha.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.
Files changed (179) hide show
  1. package/CLAUDE.md +164 -0
  2. package/README.md +116 -0
  3. package/{readme.md → README.zh-CN.md} +43 -12
  4. package/dist/bin/generate-api-docs.d.ts +1 -0
  5. package/dist/build/build.es.d.ts +2 -0
  6. package/dist/build/build.umd.d.ts +2 -0
  7. package/dist/build/build.umd.node.d.ts +2 -0
  8. package/dist/build/build.umd.utils.d.ts +2 -0
  9. package/dist/color-CRdlaDqQ.js +1 -0
  10. package/dist/examples/clone-deep-example.d.ts +1 -0
  11. package/dist/examples/is-equal-example.d.ts +1 -0
  12. package/dist/index.d.ts +5 -21
  13. package/dist/index.js +1 -2484
  14. package/dist/plugins/vite-plugins-banner.d.ts +2 -0
  15. package/dist/rolldown-runtime-I3TIJKkN.js +1 -0
  16. package/dist/src/node/appendFile.d.ts +7 -0
  17. package/dist/src/node/body.d.ts +9 -0
  18. package/dist/src/node/color.d.ts +7 -0
  19. package/dist/src/node/command.d.ts +8 -0
  20. package/dist/src/node/ctx2req.d.ts +5 -0
  21. package/dist/src/node/fileInfo.d.ts +7 -0
  22. package/dist/src/node/fs.d.ts +7 -0
  23. package/dist/src/node/get.d.ts +10 -0
  24. package/dist/src/node/getIPAdress.d.ts +1 -0
  25. package/dist/src/node/index.d.ts +25 -0
  26. package/dist/src/node/index.js +1 -0
  27. package/dist/src/node/isColorSupported.d.ts +2 -0
  28. package/dist/src/node/paresUrl.d.ts +19 -0
  29. package/dist/src/node/readDir.d.ts +6 -0
  30. package/dist/src/node/readFile.d.ts +9 -0
  31. package/dist/src/node/router.d.ts +42 -0
  32. package/dist/src/node/send.d.ts +7 -0
  33. package/dist/src/node/server.d.ts +18 -0
  34. package/dist/src/node/startTask.d.ts +2 -0
  35. package/dist/src/node/stream.d.ts +15 -0
  36. package/dist/src/node/taskEnd.d.ts +2 -0
  37. package/dist/src/node/traverse.d.ts +17 -0
  38. package/dist/src/node/watchFile.d.ts +8 -0
  39. package/dist/src/node/writeFile.d.ts +8 -0
  40. package/dist/src/node/ws.d.ts +8 -0
  41. package/dist/src/utils/audioRecorder.d.ts +16 -0
  42. package/dist/src/utils/behavior.d.ts +15 -0
  43. package/dist/src/utils/bom.d.ts +294 -0
  44. package/dist/src/utils/color.d.ts +71 -0
  45. package/dist/src/utils/compose.d.ts +10 -0
  46. package/dist/src/utils/console.d.ts +1 -0
  47. package/dist/src/utils/debounce.d.ts +7 -0
  48. package/dist/src/utils/device.d.ts +25 -0
  49. package/dist/src/utils/dom.d.ts +105 -0
  50. package/dist/src/utils/error.d.ts +1 -0
  51. package/dist/src/utils/func.d.ts +1 -0
  52. package/dist/src/utils/img.d.ts +16 -0
  53. package/dist/src/utils/index.d.ts +35 -0
  54. package/dist/src/utils/index.js +1 -0
  55. package/dist/src/utils/memoize.d.ts +7 -0
  56. package/dist/src/utils/mimeType.d.ts +9 -0
  57. package/dist/src/utils/monitor.d.ts +38 -0
  58. package/dist/src/utils/network.d.ts +39 -0
  59. package/dist/src/utils/noop.d.ts +2 -0
  60. package/dist/src/utils/number.d.ts +45 -0
  61. package/dist/src/utils/obj.d.ts +83 -0
  62. package/dist/src/utils/performance.d.ts +21 -0
  63. package/dist/src/utils/queue.d.ts +33 -0
  64. package/dist/src/utils/report.d.ts +8 -0
  65. package/dist/src/utils/request.d.ts +17 -0
  66. package/dist/src/utils/script.d.ts +7 -0
  67. package/dist/src/utils/signal.d.ts +6 -0
  68. package/dist/src/utils/storage.d.ts +2 -0
  69. package/dist/src/utils/str.d.ts +212 -0
  70. package/dist/src/utils/subscribe.d.ts +46 -0
  71. package/dist/src/utils/throttle.d.ts +15 -0
  72. package/dist/src/utils/time.d.ts +20 -0
  73. package/dist/src/utils/totp/sha/common.d.ts +151 -0
  74. package/dist/src/utils/totp/sha/converters.d.ts +88 -0
  75. package/dist/src/utils/totp/sha/custom_types.d.ts +60 -0
  76. package/dist/src/utils/totp/sha/primitives_32.d.ts +98 -0
  77. package/dist/src/utils/totp/sha/primitives_64.d.ts +116 -0
  78. package/dist/src/utils/totp/sha/sha.d.ts +103 -0
  79. package/dist/src/utils/totp/sha/sha1.d.ts +18 -0
  80. package/dist/src/utils/totp/sha/sha256.d.ts +20 -0
  81. package/dist/src/utils/totp/sha/sha3.d.ts +53 -0
  82. package/dist/src/utils/totp/sha/sha512.d.ts +21 -0
  83. package/dist/src/utils/totp/totp.d.ts +23 -0
  84. package/dist/src/utils/visual/application.d.ts +27 -0
  85. package/dist/src/utils/visual/enums.d.ts +27 -0
  86. package/dist/src/utils/visual/event/boundary.d.ts +22 -0
  87. package/dist/src/utils/visual/event/event.d.ts +14 -0
  88. package/dist/src/utils/visual/event/index.d.ts +6 -0
  89. package/dist/src/utils/visual/event/types.d.ts +32 -0
  90. package/dist/src/utils/visual/graphics/graphics.d.ts +81 -0
  91. package/dist/src/utils/visual/graphics/graphicsData.d.ts +13 -0
  92. package/dist/src/utils/visual/graphics/graphicsGeometry.d.ts +35 -0
  93. package/dist/src/utils/visual/graphics/index.d.ts +4 -0
  94. package/dist/src/utils/visual/index.d.ts +7 -0
  95. package/dist/src/utils/visual/index.js +1 -0
  96. package/dist/src/utils/visual/math/bezier.d.ts +2 -0
  97. package/dist/src/utils/visual/math/enums.d.ts +3 -0
  98. package/dist/src/utils/visual/math/index.d.ts +5 -0
  99. package/dist/src/utils/visual/math/matrix.d.ts +113 -0
  100. package/dist/src/utils/visual/math/transform.d.ts +29 -0
  101. package/dist/src/utils/visual/render/batchRenderer.d.ts +78 -0
  102. package/dist/src/utils/visual/render/canvasRenderer.d.ts +10 -0
  103. package/dist/src/utils/visual/render/index.d.ts +3 -0
  104. package/dist/src/utils/visual/render/render.d.ts +11 -0
  105. package/dist/src/utils/visual/render/utils/batch/index.d.ts +90 -0
  106. package/dist/src/utils/visual/render/utils/batch/index.test.d.ts +1 -0
  107. package/dist/src/utils/visual/render/utils/float.d.ts +63 -0
  108. package/dist/src/utils/visual/render/utils/index.d.ts +3 -0
  109. package/dist/src/utils/visual/render/utils/index.test.d.ts +1 -0
  110. package/dist/src/utils/visual/render/utils/verticy.d.ts +13 -0
  111. package/dist/src/utils/visual/render/utils/webgl/initShader.d.ts +7 -0
  112. package/dist/src/utils/visual/render/utils/webgl/shaders.d.ts +2 -0
  113. package/dist/src/utils/visual/render/utils/webgpu/shaders.d.ts +8 -0
  114. package/dist/src/utils/visual/render/webGPURenderer.d.ts +49 -0
  115. package/dist/src/utils/visual/render/webGlRenderer.d.ts +14 -0
  116. package/dist/src/utils/visual/shape/circle.d.ts +11 -0
  117. package/dist/src/utils/visual/shape/ellipse.d.ts +12 -0
  118. package/dist/src/utils/visual/shape/index.d.ts +7 -0
  119. package/dist/src/utils/visual/shape/polygon.d.ts +11 -0
  120. package/dist/src/utils/visual/shape/rectangle.d.ts +12 -0
  121. package/dist/src/utils/visual/shape/roundedRectangle.d.ts +13 -0
  122. package/dist/src/utils/visual/shape/shape.d.ts +6 -0
  123. package/dist/src/utils/visual/style/fill.d.ts +8 -0
  124. package/dist/src/utils/visual/style/index.d.ts +3 -0
  125. package/dist/src/utils/visual/style/line.d.ts +10 -0
  126. package/dist/src/utils/visual/types.d.ts +18 -0
  127. package/dist/src/utils/visual/vertex/container.d.ts +74 -0
  128. package/dist/src/utils/visual/vertex/point.d.ts +18 -0
  129. package/dist/src/utils/visual/vertex/vertex.d.ts +36 -0
  130. package/dist/src/vnode/chainDom.d.ts +47 -0
  131. package/dist/src/vnode/h.d.ts +6 -0
  132. package/dist/src/vnode/hooks.d.ts +23 -0
  133. package/dist/src/vnode/htmlDomApi.d.ts +33 -0
  134. package/dist/src/vnode/index.d.ts +18 -0
  135. package/dist/src/vnode/index.js +1 -0
  136. package/dist/src/vnode/init.d.ts +2 -0
  137. package/dist/src/vnode/is.d.ts +5 -0
  138. package/dist/src/vnode/modules/attributes.d.ts +8 -0
  139. package/dist/src/vnode/modules/class.d.ts +8 -0
  140. package/dist/src/vnode/modules/index.d.ts +3 -0
  141. package/dist/src/vnode/modules/listeners.d.ts +12 -0
  142. package/dist/src/vnode/modules/props.d.ts +8 -0
  143. package/dist/src/vnode/modules/style.d.ts +14 -0
  144. package/dist/src/vnode/vnode.d.ts +31 -0
  145. package/dist/subscribe-CINWsor3.js +1 -0
  146. package/dist/test/bridge.test.d.ts +1 -0
  147. package/dist/test/clearBr.test.d.ts +1 -0
  148. package/dist/test/cloneDeep.test.d.ts +1 -0
  149. package/dist/test/command.test.d.ts +1 -0
  150. package/dist/test/encodeUrl.test.d.ts +1 -0
  151. package/dist/test/escapeHtml.test.d.ts +1 -0
  152. package/dist/test/is-equal.test.d.ts +1 -0
  153. package/dist/test/mimeType.test.d.ts +1 -0
  154. package/dist/test/package-exports.test.d.ts +1 -0
  155. package/dist/test/server.test.d.ts +1 -0
  156. package/dist/test/status.test.d.ts +1 -0
  157. package/dist/test/totp.test.d.ts +1 -0
  158. package/dist/test/utils/compose.test.d.ts +1 -0
  159. package/dist/test/utils/mergeObj.test.d.ts +1 -0
  160. package/dist/test/visual/math.test.d.ts +1 -0
  161. package/dist/test/visual-application.test.d.ts +1 -0
  162. package/dist/test/visual-batch.test.d.ts +1 -0
  163. package/dist/test/visual-math.test.d.ts +1 -0
  164. package/dist/test/vnode/index.d.ts +1 -0
  165. package/dist/test/vnode/server.d.ts +2 -0
  166. package/dist/test/vnode/vnode.d.ts +1 -0
  167. package/dist/test/vnode.test.d.ts +1 -0
  168. package/dist/test/websocket.test.d.ts +1 -0
  169. package/dist/test/writeFile.test.d.ts +1 -0
  170. package/dist/umd/index.umd.cjs +1 -0
  171. package/dist/umd/node/node.umd.cjs +1 -0
  172. package/dist/umd/utils/utils.umd.cjs +1 -0
  173. package/dist/utils-_OxsVZmz.js +1 -0
  174. package/dist/vite.config.d.ts +8 -0
  175. package/dist/vitest.config.d.ts +2 -0
  176. package/docs/API.md +305 -0
  177. package/package.json +49 -12
  178. package/typings.d.ts +28 -0
  179. package/dist/index.umd.cjs +0 -1
@@ -0,0 +1 @@
1
+ import{t}from"../../../subscribe-CINWsor3.js";var e,s=/* @__PURE__ */function(t){return t.RECTANGLE="rectangle",t.POLYGON="polygon",t.CIRCLE="circle",t.ELLIPSE="ellipse",t.ROUNDED_RECTANGLE="rounded rectangle",t}({}),i=/* @__PURE__ */function(t){return t.BUTT="butt",t.ROUND="round",t.SQUARE="square",t}({}),r=/* @__PURE__ */function(t){return t.MITER="miter",t.BEVEL="bevel",t.ROUND="round",t}({}),n=/* @__PURE__ */function(t){return t.WEB_GL="webgl",t.CANVAS="canvas",t.WEB_GPU="webgpu",t}({}),a=65536,h=12,o=class{},c=class extends o{x;y;width;height;type=s.RECTANGLE;constructor(t=0,e=0,s=0,i=0){super(),this.x=t,this.y=e,this.width=s,this.height=i}contains(t){return t.x>this.x&&t.x<this.x+this.width&&t.y>this.y&&t.y<this.y+this.height}},l=class{canvasEle;screen=new c;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()}},u=class extends l{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()}},p=(t,e)=>{if(e.worldAlpha<=0||!e.visible)return;e.buildBatches(t);const s=e.children;for(let i=0;i<s.length;i++)p(t,s[i])},f=(t,e)=>{if(e.worldAlpha<=0||!e.visible)return;e.updateBatches(t);const s=e.children;for(let i=0;i<s.length;i++)f(t,s[i])},d=class{vertexCount=0;indexCount=0;rgba=0;vertexStart=0;indexStart=0},x=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}},g=class{idx=0;reset(){this.idx=0}},y=class extends g{batches=[];constructor(){super()}getOne(){return this.batches[this.idx]||(this.batches[this.idx]=new v),this.batches[this.idx++]}},v=class extends d{vertexOffset=0;indexOffset=0;graphics;packVertices(t,e){const s=this.graphics.geometry.vertices.data,i=this.vertexOffset;for(let r=0;r<this.vertexCount;r++){const n=s[2*(i+r)],a=s[2*(i+r)+1],{a:h,b:o,c:c,d:l,tx:u,ty:p}=this.graphics.worldTransform,f=h*n+c*a+u,d=o*n+l*a+p,x=3*(this.vertexStart+r);t[x]=f,t[x+1]=d,e[x+2]=this.rgba}}packIndices(t){const e=this.graphics.geometry.indices.data,s=this.indexOffset;for(let i=0;i<this.indexCount;i++)t[this.indexStart+i]=e[i+s]+this.vertexStart}updateVertices(t){const e=this.graphics.geometry.vertices.data,s=this.vertexOffset,{a:i,b:r,c:n,d:a,tx:h,ty:o}=this.graphics.worldTransform;for(let c=0;c<this.vertexCount;c++){const l=e[2*(s+c)],u=e[2*(s+c)+1],p=3*(this.vertexStart+c);t[p]=i*l+n*u+h,t[p+1]=r*l+a*u+o}}},m=new class{batchesMap={graphics:new y};get(t){return this.batchesMap[t].getOne()}reset(){Object.values(this.batchesMap).forEach(t=>{t.reset()})}},b=class extends l{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,m.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:i,d:r,tx:n,ty:a}=t.transform.localTransform;this.setRootTransform(e,s,i,r,n,a)}t.worldAlpha=t.alpha;const s=t.children;for(let i=0;i<s.length;i++)s[i].updateTransform()}render(t){this.updateChildrenTransform(t),this.builtVersion!==t.structureVersion?(this.startBuild(),p(this,t),this.buildEnd(),this.builtVersion=t.structureVersion):f(this.vertFloatView,t),this.updateBuffer(),this.draw()}},w="\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(),M="\nprecision mediump float;\nvarying vec4 v_color;\nvoid main(){\n gl_FragColor = v_color;\n}\n".trim(),P=(t,e,s)=>{const i=t.createShader(e);if(t.shaderSource(i,s),t.compileShader(i),t.getShaderParameter(i,t.COMPILE_STATUS))return i;{const e=t.getShaderInfoLog(i);throw t.deleteShader(i),console.error(`编译 shader 错误:${e}`),new Error(`编译 shader 错误:${e}`)}},T=t=>{const e=t.gl,s=((t,e,s)=>{const i=t.createProgram();if(!i)throw console.error("创建 program 失败"),new Error("创建 program 失败");if(t.attachShader(i,e),t.attachShader(i,s),t.linkProgram(i),!t.getProgramParameter(i,t.LINK_STATUS)){const r=t.getProgramInfoLog(i);throw console.error(`link 出错:${r}`),t.deleteProgram(i),t.deleteShader(e),t.deleteShader(s),new Error(`link 出错:${r}`)}return t.useProgram(i),i})(e,P(e,e.VERTEX_SHADER,w),P(e,e.FRAGMENT_SHADER,M));return e.enable(e.BLEND),e.blendFunc(e.ONE,e.ONE_MINUS_SRC_ALPHA),s},_=/* @__PURE__ */new Map,E=t=>{const s=_.get(t);if(s)return s;let i;if(/^#?[0-9a-fA-F]{3}$/.test(t)){const e=t.replace("#","");i=[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);i=[e>>16&255,e>>8&255,255&e]}else i=(t=>{if(void 0===e&&(e="undefined"!=typeof document?document.createElement("canvas").getContext("2d"):null),!e)return[0,0,0];e.fillStyle="#000",e.fillStyle=t,e.fillRect(0,0,1,1);const[s,i,r]=e.getImageData(0,0,1,1).data;return[s,i,r]})(t);return _.set(t,i),i},B=(t,e)=>{const[s,i,r]=E(t).map(t=>Math.round(t*e));let n=0;return n+=Math.round(255*e)<<24,n+=r<<16,n+=i<<8,n+=s,n},I=t=>{const[e,s,i]=E(t);return[e/255,s/255,i/255]},A=class extends b{gl;program;glVertexBuffer;glIndexBuffer;unifLoc;constructor(t){super(t),t.debug,this.gl=this.canvasEle.getContext("webgl",{antialias:!0}),this.gl.getExtension("OES_element_index_uint"),this.program=T(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),((t,e)=>{const s=t.getAttribLocation(e,"a_position");t.vertexAttribPointer(s,2,t.FLOAT,!1,12,0),t.enableVertexAttribArray(s);const i=t.getAttribLocation(e,"a_color");t.vertexAttribPointer(i,4,t.UNSIGNED_BYTE,!0,12,8),t.enableVertexAttribArray(i)})(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,i,r]=I(t.backgroundColor??"");this.gl.clearColor(s*e,i*e,r*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,i,r,n){this.gl.uniformMatrix3fv(this.unifLoc.u_root_transform,!1,new Float32Array([t,e,0,s,i,0,r,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;t.clear(t.COLOR_BUFFER_BIT),t.drawElements(t.TRIANGLES,this.indexCount,t.UNSIGNED_INT,0)}},S=class extends b{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:i,gpu:r,uniformBindGroup:n,indexCount:a,pipeline:h}=this,o=t.createCommandEncoder(),c=[...e.colorAttachments];c?.[0]?.view&&(c[0].view=r.getCurrentTexture().createView());const l=o.beginRenderPass(e);l.setPipeline(h),l.setVertexBuffer(0,s),l.setIndexBuffer(i,"uint32"),l.setBindGroup(0,n),l.drawIndexed(a),l.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,i,r,n){this.device.queue.writeBuffer(this.stageMatBuffer,0,new Float32Array([t,e,0,0,s,i,0,0,r,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,[i,r,n]=I(t).map(t=>t*s);this.renderPassDescriptor={label:"my-render-pass-descriptor",colorAttachments:[{view:this.gpu.getCurrentTexture().createView(),storeOp:"store",loadOp:"clear",clearValue:[i,r,n,s]}]}}},C=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)},L=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))}},R=Math.PI/180,U=180/Math.PI,F=2*Math.PI,N=class t{a;b;c;d;tx;ty;array=null;constructor(t=1,e=0,s=0,i=1,r=0,n=0){this.a=t,this.b=e,this.c=s,this.d=i,this.tx=r,this.ty=n}set=(t,e,s,i,r,n)=>(this.a=t,this.b=e,this.c=s,this.d=i,this.tx=r,this.ty=n,this);append=t=>{const{a:e,b:s,c:i,d:r,tx:n,ty:a}=this,{a:h,b:o,c:c,d:l,tx:u,ty:p}=t;return this.a=e*h+i*o,this.b=s*h+r*o,this.c=e*c+i*l,this.d=s*c+r*l,this.tx=e*u+i*p+n,this.ty=s*u+r*p+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,i,r,n,a,h,o)=>(this.a=Math.cos(a+o)*r,this.b=Math.sin(a+o)*r,this.c=-Math.sin(a-h)*n,this.d=Math.cos(a-h)*n,this.tx=t-(s*this.a+i*this.c),this.ty=e-(s*this.b+i*this.d),this);rotate=t=>{const e=Math.cos(t),s=Math.sin(t),i=this.a,r=this.c,n=this.tx;return this.a=i*e-this.b*s,this.b=i*s+this.b*e,this.c=r*e-this.d*s,this.d=r*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 e=this.a,s=this.b,i=this.c,r=this.d,n=t.pivot,a=-Math.atan2(-i,r),h=Math.atan2(s,e),o=Math.abs(a+h);return o<1e-5||Math.abs(F-o)<1e-5?(t.rotation=h,t.skew.x=t.skew.y=0):(t.rotation=0,t.skew.x=a,t.skew.y=h),t.scale.x=Math.sqrt(e*e+s*s),t.scale.y=Math.sqrt(i*i+r*r),t.position.x=this.tx+(n.x*e+n.y*i),t.position.y=this.ty+(n.x*s+n.y*r),t};apply=t=>{const e=new C,s=t.x,i=t.y;return e.x=this.a*s+this.c*i+this.tx,e.y=this.b*s+this.d*i+this.ty,e};applyInverse=t=>{const e=new C,s=1/(this.a*this.d+this.c*-this.b),i=t.x,r=t.y;return e.x=this.d*s*i+-this.c*s*r+(this.ty*this.c-this.tx*this.d)*s,e.y=this.a*s*r+-this.b*s*i+(-this.ty*this.a+this.tx*this.b)*s,e};prepend=t=>{const{a:e,b:s,c:i,d:r,tx:n,ty:a}=t,{a:h,b:o,c:c,d:l,tx:u,ty:p}=this;return this.a=e*h+i*o,this.b=s*h+r*o,this.c=e*c+i*l,this.d=s*c+r*l,this.tx=e*u+i*p+n,this.ty=s*u+r*p+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}},V=class{localTransform=new N;worldTransform=new N;position;scale;pivot;skew;_rotation=0;rotateMatrix=new N;skewMatrix=new N;scaleMatrix=new N;localMatrix=new N;shouldUpdateLocalTransform=!1;worldId=0;parentId=0;constructor(){this.position=new L(this.onChange),this.scale=new L(this.onScaleChange,1,1),this.pivot=new L(this.onChange),this.skew=new L(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:i}=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,n=e*this.pivot.x+i*this.pivot.y,a=this.position.x-r,h=this.position.y-n;this.localTransform.set(t,e,s,i,a,h),this.shouldUpdateLocalTransform=!1,this.parentId=-1}updateTransform(t){if(this.updateLocalTransform(),this.parentId!==t.worldId){const{a:e,b:s,c:i,d:r,tx:n,ty:a}=t.worldTransform,{a:h,b:o,c:c,d:l,tx:u,ty:p}=this.localTransform;this.worldTransform.set(e*h+i*o,s*h+r*o,e*c+i*l,s*c+r*l,e*u+i*p+n,s*u+r*p+a),this.parentId=t.worldId,this.worldId++}}},D=class extends t{_zIndex=0;parent=void 0;visible=!0;transform=new V;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*U}set angle(t){this.transform.rotation=t*R}updateTransform(){const t=this.parent?.transform||new V;this.transform.updateTransform(t),this.worldAlpha=this.alpha*(this.parent?.worldAlpha||1)}addEventListener=(t,e,s)=>{const i="boolean"==typeof s&&s||"object"==typeof s&&s.capture?`${t}capture`:t;"object"==typeof s&&s.once?this.once(i,e):this.tap(i,e)};removeEventListener=(t,e,s)=>{const i=s?`${t}capture`:t;this.off(i,e)}},k=class extends D{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 V;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){}},O=/* @__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}({}),G=class{isTrusted=!0;timeStamp=0;type="mousemove";button=0;buttons=0;global=new C;propagationStopped=!1;eventPhase=0;target=new k;currentTarget=new k;stopPropagation(){this.propagationStopped=!0}},j=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 i=t.children.length-1;i>=0;i--){const s=t.children[i];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=O.AT_TARGET,e){let i=s;for(;i&&!this.composePath(e).includes(i);)t.target=i,t.currentTarget=t.target,t.target.call(`${t.type}capture`,t),t.target.call(t.type,t),i=i.parent}else for(let i=this.overTargets.length-1;i>=0;i--)t.target=this.overTargets[i],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 i=this.composePath(e);if(t.type="mouseenter",t.eventPhase=O.AT_TARGET,s){let e=i.length-1;for(;e>=0&&!this.composePath(s).includes(i[e]);e--);for(let s=e+1;s<i.length;s++)t.target=i[s],t.currentTarget=t.target,t.target.call(`${t.type}capture`,t),t.target.call(t.type,t)}else for(let e=0;e<i.length;e++)t.target=i[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 i=s[s.length-1];const r=this.composePath(e);for(;i&&!r.includes(i);)i.parent&&(i=i.parent);t.type="click",t.target=i,this.dispatchEvent(t),delete this.pressTargetsMap[t.button]};notifyTarget=t=>{t.eventPhase===O.CAPTURING?t.currentTarget.call(`${t.type}capture`,t):t.currentTarget.call(t.type,t)};propagate=t=>{const e=this.composePath(t.target);t.eventPhase=O.CAPTURING;for(let s=0;s<e.length-1;s++)if(t.currentTarget=e[s],this.notifyTarget(t),t.propagationStopped)return;if(t.eventPhase=O.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=O.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}},Y=class{canvasEle;eventBoundary;rootEvent=new G;constructor(t,e){this.canvasEle=t,this.eventBoundary=new j(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}},z=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 n.CANVAS:return new u(t);case n.WEB_GL:return new A(t);case n.WEB_GPU:return new S(t);default:return new u(t)}})({...t,view:e}),this.stage=new k,this.eventSystem=new Y(this.view,this.stage)}static async create(e){const s=new t(e);return await s.renderer.init(),s}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)}},q=class extends o{points=[];closeStroke=!1;type=s.POLYGON;constructor(t=[]){super(),this.points=t}isIntersect(t,e,s,i,r,n){if(i>e&&n>e)return!1;if(i<e&&n<e)return!1;if(s<t&&r<t)return!1;if(s>t&&r>t)return!0;return r-(r-s)/(i-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],i=this.points[h-1],r=this.points[h],n=this.points[h+1];this.isIntersect(t.x,t.y,e,i,r,n)&&s++}const i=this.points[0],r=this.points[1],n=this.points[e-2],a=this.points[e-1];return this.isIntersect(t.x,t.y,i,r,n,a)&&s++,s%2!=0}},Z=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}},$=class t extends Z{width=0;cap=i.BUTT;join=r.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=i.BUTT,this.join=r.MITER,this.miterLimit=10}},X=class{shape;lineStyle;fillStyle;vertices=[];constructor(t,e,s){this.shape=t,this.lineStyle=s,this.fillStyle=e}},H=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}},W=class{_oldLength=-1;_length=0;curMaxLen=8;int32=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}},Q=/* @__PURE__ */new Set,J=!1;function K(t,e,s=2){const i=e&&e.length,r=i?e[0]*s:t.length;Q.size&&Q.clear();let n=tt(t,0,r,s,!0);const a=[];if(!n||n.next===n.prev)return a;let h=0,o=0,c=0;if(i&&(n=function(t,e,s,i){const r=[];for(let n=0,a=e.length;n<a;n++){const s=tt(t,e[n]*i,n<a-1?e[n+1]*i:t.length,i,!1);s===s.next&&Q.add(s),r.push(Et(s))}r.sort(ot),function(t,e){const s=Math.ceil((t+2*e)/lt)+e+2;ut.length<4*s&&(ut=new Float64Array(4*s));pt=0}(t.length/i,e.length),xt(s,s),ht=!0;for(let n=0;n<r.length;n++)s=ct(r[n],s);return ht=!1,et(s)}(t,e,n,s)),t.length>80*s){h=t[0],o=t[1];let e=h,i=o;for(let n=s;n<r;n+=s){const s=t[n],r=t[n+1];s<h&&(h=s),r<o&&(o=r),s>e&&(e=s),r>i&&(i=r)}c=Math.max(e-h,i-o),c=0!==c?32767/c:0}return st(n,a,h,o,c),a}function tt(t,e,s,i,r){let n=null;if(r===function(t,e,s,i){let r=0;for(let n=e,a=s-i;n<s;n+=i)r+=(t[a]-t[n])*(t[n+1]+t[a+1]),a=n;return r}(t,e,s,i)>0)for(let a=e;a<s;a+=i)n=Ft(a/i|0,t[a],t[a+1],n);else for(let a=s-i;a>=e;a-=i)n=Ft(a/i|0,t[a],t[a+1],n);return n&&St(n,n.next)&&(Nt(n),n=n.next),n}function et(t,e=t){const s=e===t;let i,r=t;do{i=!1,r===r.next||0!==Q.size&&Q.has(r)||!St(r,r.next)&&0!==At(r.prev,r,r.next)?(s||r!==e)&&(r=r.next,i=!s):((s||r===e)&&(e=r.prev),J=!0,Nt(r),r=r.prev,i=!0)}while(i||r!==e);return e}function st(t,e,s,i,r){r&&function(t,e,s,i){let r=t,n=0;do{r.z=_t(r.x,r.y,e,s,i),mt[n++]=r,r=r.next}while(r!==t);!function(t){if(t<=32){for(let e=1;e<t;e++){const t=mt[e],s=t.z;let i=e-1;for(;i>=0&&mt[i].z>s;)mt[i+1]=mt[i],i--;mt[i+1]=t}return}wt.length<t&&(wt=new Uint32Array(t),Mt=new Uint32Array(t),bt=new Array(t));for(let e=0;e<t;e++)wt[e]=mt[e].z;Tt(t,mt,wt,bt,Mt,0),Tt(t,bt,Mt,mt,wt,8),Tt(t,mt,wt,bt,Mt,16),Tt(t,bt,Mt,mt,wt,24)}(n);let a=null;for(let h=0;h<n;h++){const t=mt[h];t.prevZ=a,a&&(a.nextZ=t),a=t}a.nextZ=null}(t,s,i,r);let n=t,a=!1;for(;t.prev!==t.next;){const h=t.prev,o=t.next;if(At(h,t,o)<0&&(r?rt(t,s,i,r):it(t)))e.push(h.i,t.i,o.i),Nt(t),t=o,n=o;else if((t=o)===n){if(J=!1,t=et(t),J){n=t;continue}if(!a){n=t=nt(t,e),a=!0;continue}at(t,e,s,i,r);break}}}function it(t){const e=t.prev,s=t,i=t.next,r=e.x,n=s.x,a=i.x,h=e.y,o=s.y,c=i.y,l=Math.min(r,n,a),u=Math.min(h,o,c),p=Math.max(r,n,a),f=Math.max(h,o,c);let d=i.next;for(;d!==e;){if(d.x>=l&&d.x<=p&&d.y>=u&&d.y<=f&&(r!==d.x||h!==d.y)&&Bt(r,h,n,o,a,c,d.x,d.y)&&At(d.prev,d,d.next)>=0)return!1;d=d.next}return!0}function rt(t,e,s,i){const r=t.prev,n=t,a=t.next,h=r.x,o=n.x,c=a.x,l=r.y,u=n.y,p=a.y,f=Math.min(h,o,c),d=Math.min(l,u,p),x=Math.max(h,o,c),g=Math.max(l,u,p),y=_t(f,d,e,s,i),v=_t(x,g,e,s,i);let m=t.prevZ;for(;m&&m.z>=y;){if(m.x>=f&&m.x<=x&&m.y>=d&&m.y<=g&&m!==a&&(h!==m.x||l!==m.y)&&Bt(h,l,o,u,c,p,m.x,m.y)&&At(m.prev,m,m.next)>=0)return!1;m=m.prevZ}let b=t.nextZ;for(;b&&b.z<=v;){if(b.x>=f&&b.x<=x&&b.y>=d&&b.y<=g&&b!==a&&(h!==b.x||l!==b.y)&&Bt(h,l,o,u,c,p,b.x,b.y)&&At(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function nt(t,e){let s=t,i=!1;do{const r=s.prev,n=s.next.next;Ct(r,s,s.next,n,!1)&&Rt(r,n)&&Rt(n,r)&&(e.push(r.i,s.i,n.i),Nt(s),Nt(s.next),s=t=n,i=!0),s=s.next}while(s!==t);return i?et(s):s}function at(t,e,s,i,r){let n=t;do{let t=n.next.next;for(;t!==n.prev;){if(n.i!==t.i&&It(n,t)){let a=Ut(n,t);return n=et(n,n.next),a=et(a,a.next),st(n,e,s,i,r),void st(a,e,s,i,r)}t=t.next}n=n.next}while(n!==t)}var ht=!1;function ot(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 ct(t,e){const s=function(t,e){let s=e;const i=t.x,r=t.y;let n,a=-1/0;if(St(t,s))return s;for(let p=0,f=0;p<pt;p++,f+=4){if(r<ut[f+1]||r>ut[f+3]||ut[f]>i||ut[f+2]<=a)continue;const e=gt(p);s=yt(p);do{if(s.prev.next===s){if(St(t,s.next))return s.next;if(r<=s.y&&r>=s.next.y&&s.next.y!==s.y){const t=s.x+(r-s.y)*(s.next.x-s.x)/(s.next.y-s.y);if(t<=i&&t>a&&(a=t,n=s.x<s.next.x?s:s.next,t===i))return n}}s=s.next}while(s!==e)}if(!n)return null;const h=n.x,o=n.y,c=Math.min(r,o),l=Math.max(r,o);let u=1/0;for(let p=0,f=0;p<pt;p++,f+=4){if(ut[f+2]<h||ut[f]>i||ut[f+3]<c||ut[f+1]>l)continue;const e=gt(p);s=yt(p);do{if(s.prev.next===s&&i>=s.x&&s.x>=h&&i!==s.x&&Bt(r<o?i:a,r,h,o,r<o?a:i,r,s.x,s.y)){const e=Math.abs(r-s.y)/(i-s.x);(Rt(s,t)||s.y===r&&s.next.y===r&&s.next.x>i)&&(e<u||e===u&&(s.x>n.x||s.x===n.x&&vt(n,s)))&&(n=s,u=e)}s=s.next}while(s!==e)}return n}(t,e);if(!s)return e;const i=Ut(s,t);return xt(s,i.next.next),et(i,i.next),et(s,s.next)}var lt=16,ut=/* @__PURE__ */new Float64Array(0),pt=0,ft=[],dt=[];function xt(t,e){let s=t;do{const t=pt++;ft[t]=s;let i=1/0,r=1/0,n=-1/0,a=-1/0,h=0;do{const e=s.next;s.z=t,s.x<i&&(i=s.x),s.x>n&&(n=s.x),s.y<r&&(r=s.y),s.y>a&&(a=s.y),e.x<i&&(i=e.x),e.x>n&&(n=e.x),e.y<r&&(r=e.y),e.y>a&&(a=e.y),s=e}while(++h<lt&&s!==e);dt[t]=s;const o=4*t;ut[o]=i,ut[o+1]=r,ut[o+2]=n,ut[o+3]=a}while(s!==e)}function gt(t){let e=dt[t];for(;e.prev.next!==e;)e=e.next;return dt[t]=e,e}function yt(t){let e=ft[t];for(;e.prev.next!==e;)e=e.next;return ft[t]=e,e}function vt(t,e){return At(t.prev,t,e.prev)<0&&At(e.next,t,t.next)<0}var mt=[],bt=[],wt=/* @__PURE__ */new Uint32Array(0),Mt=/* @__PURE__ */new Uint32Array(0),Pt=/* @__PURE__ */new Uint32Array(256);function Tt(t,e,s,i,r,n){Pt.fill(0);for(let h=0;h<t;h++)Pt[s[h]>>>n&255]++;let a=0;for(let h=0;h<256;h++){const t=Pt[h];Pt[h]=a,a+=t}for(let h=0;h<t;h++){const t=s[h],a=Pt[t>>>n&255]++;i[a]=e[h],r[a]=t}}function _t(t,e,s,i,r){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-s)*r|0)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-i)*r|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function Et(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 Bt(t,e,s,i,r,n,a,h){return(r-a)*(e-h)>=(t-a)*(n-h)&&(t-a)*(i-h)>=(s-a)*(e-h)&&(s-a)*(n-h)>=(r-a)*(i-h)}function It(t,e){const s=St(t,e)&&At(t.prev,t,t.next)>0&&At(e.prev,e,e.next)>0;return t.next.i!==e.i&&(s||Rt(t,e)&&Rt(e,t)&&(0!==At(t.prev,t,e.prev)||0!==At(t,e.prev,e)))&&!function(t,e){const s=Math.min(t.x,e.x),i=Math.max(t.x,e.x),r=Math.min(t.y,e.y),n=Math.max(t.y,e.y);let a=t;do{const h=a.next;if(a.x>i&&h.x>i||a.x<s&&h.x<s||a.y>n&&h.y>n||a.y<r&&h.y<r)a=h;else{if(a.i!==t.i&&h.i!==t.i&&a.i!==e.i&&h.i!==e.i&&Ct(a,h,t,e))return!0;a=h}}while(a!==t);return!1}(t,e)&&(s||function(t,e){let s=t,i=!1;const r=(t.x+e.x)/2,n=(t.y+e.y)/2;do{const t=s.next;s.y>n!=t.y>n&&r<(t.x-s.x)*(n-s.y)/(t.y-s.y)+s.x&&(i=!i),s=t}while(s!==t);return i}(t,e))}function At(t,e,s){return(e.y-t.y)*(s.x-e.x)-(e.x-t.x)*(s.y-e.y)}function St(t,e){return t.x===e.x&&t.y===e.y}function Ct(t,e,s,i,r=!0){const n=At(t,e,s),a=At(t,e,i),h=At(s,i,t),o=At(s,i,e);return(n>0&&a<0||n<0&&a>0)&&(h>0&&o<0||h<0&&o>0)||!!r&&(!(0!==n||!Lt(t,s,e))||(!(0!==a||!Lt(t,i,e))||(!(0!==h||!Lt(s,t,i))||!(0!==o||!Lt(s,e,i)))))}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 Rt(t,e){return At(t.prev,t,t.next)<0?At(t,e,t.next)>=0&&At(t,t.prev,e)>=0:At(t,e,t.prev)<0||At(t,t.next,e)<0}function Ut(t,e){const s=Vt(t.i,t.x,t.y),i=Vt(e.i,e.x,e.y),r=t.next,n=e.prev;return t.next=e,e.prev=t,s.next=r,r.prev=s,i.next=s,s.prev=i,n.next=i,i.prev=n,i}function Ft(t,e,s,i){const r=Vt(t,e,s);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function Nt(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),ht&&function(t,e){const s=4*t.z;e.x<ut[s]&&(ut[s]=e.x),e.y<ut[s+1]&&(ut[s+1]=e.y),e.x>ut[s+2]&&(ut[s+2]=e.x),e.y>ut[s+3]&&(ut[s+3]=e.y)}(t.prev,t.next)}function Vt(t,e,s){return{i:t,x:e,y:s,prev:null,next:null,z:0,prevZ:null,nextZ:null}}var Dt=class extends o{x;y;radius;type=s.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 o{x;y;radiusX;radiusY;type=s.ELLIPSE;constructor(t=0,e=0,s=0,i=0){super(),this.x=t,this.y=e,this.radiusX=s,this.radiusY=i}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}},Ot=class extends o{x;y;width;height;radius;type=s.ROUNDED_RECTANGLE;constructor(t=0,e=0,s=0,i=0,r=20){super(),this.x=t,this.y=e,this.width=s,this.height=i;const n=Math.min(s,i)/2;this.radius=r>n?n:r}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 i=this.x+this.radius,r=this.y+this.height-this.radius;if(t.x<i&&t.y>r)return(t.x-i)*(t.x-i)+(t.y-r)*(t.y-r)<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}},Gt=t=>{const{shape:e,vertices:s}=t;if(e instanceof c){const{x:t,y:i,width:r,height:n}=e;s.push(t,i,t+r,i,t+r,i+n,t,i+n)}e instanceof Dt&&((t,e)=>{const{x:s,y:i,radius:r}=t,n=2*Math.PI*r,a=Math.min(Math.ceil(n/5),2048);for(let h=0;h<a;h++){const t=h/a*Math.PI*2,n=s+r*Math.cos(t),o=i+r*Math.sin(t);e.vertices.push(n,o)}})(e,t),e instanceof Ot&&((t,e)=>{const{x:s,y:i,width:r,height:n,radius:a}=t,h=2*Math.PI*a/4,o=Math.min(Math.ceil(h/4),2048);for(let c=0;c<o;c++){const t=c/o*Math.PI*.5,h=a*Math.cos(t),l=a*Math.sin(t);e.vertices.push(s+r-a+h,i+n-a+l)}for(let c=0;c<o;c++){const t=c/o*Math.PI*.5+Math.PI/2,r=a*Math.cos(t),h=a*Math.sin(t);e.vertices.push(s+a+r,i+n-a+h)}for(let c=0;c<o;c++){const t=c/o*Math.PI*.5+Math.PI,r=a*Math.cos(t),n=a*Math.sin(t);e.vertices.push(s+a+r,i+a+n)}for(let c=0;c<o;c++){const t=c/o*Math.PI*.5+1.5*Math.PI,n=a*Math.cos(t),h=a*Math.sin(t);e.vertices.push(s+r-a+n,i+a+h)}})(e,t),e instanceof kt&&((t,e)=>{const{x:s,y:i,radiusX:r,radiusY:n}=t,a=Math.PI*Math.sqrt(2*(r*r+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+r*Math.cos(t),c=i+n*Math.sin(t);e.vertices.push(a,c)}})(e,t),e instanceof q&&(t.vertices=e.points)},jt=t=>{const e=[],s=t.length/2+1;for(let i=1;i<s-1;i++)e.push(0,i,i+1);return e.push(0,s-1,1),e},Yt=(t,e)=>{const{shape:s,vertices:i,fillStyle:r}=t,n=new x(r);if(e.batchParts.push(n),n.start(e.vertices.length/2,e.indices.length),s instanceof c&&(e.vertices.concat(i),e.indices.concat([0,1,2,0,2,3]),n.end(4,6)),s instanceof Dt){const{x:t,y:r}=s;e.vertices.push(t),e.vertices.push(r),e.vertices.concat(i);const a=jt(i);e.indices.concat(a),n.end(i.length/2+1,a.length)}if(s instanceof Ot){const{x:t,y:r,width:a,height:h}=s;e.vertices.push(t+a/2),e.vertices.push(r+h/2),e.vertices.concat(i);const o=jt(i);e.indices.concat(o),n.end(i.length/2+1,o.length)}if(s instanceof kt){const{x:t,y:r}=s;e.vertices.push(t),e.vertices.push(r),e.vertices.concat(i);const a=jt(i);e.indices.concat(a),n.end(i.length/2+1,a.length)}if(s instanceof q){e.vertices.concat(i);const t=K(i);e.indices.concat(t),n.end(i.length/2,t.length)}},zt=(t,e,s,i,r,n,a,h)=>{let o=0,c=0,l=0,u=0,p=0,f=0;if(Math.abs(s-t)<=Number.EPSILON)o=1,c=0,p=s;else{const r=(i-e)/(s-t);o=r,c=-1,p=-(i-r*s)}if(Math.abs(a-r)<=Number.EPSILON)l=1,u=0,f=a;else{const t=(h-n)/(a-r);l=t,u=-1,f=-(h-t*a)}return[(p*u-c*f)/(o*u-c*l),(o*f-p*l)/(o*u-c*l)]},qt=(t,e,s)=>{const i=e,r=-t,n=s/2/Math.sqrt(t*t+e*e);return[i*n,r*n]},Zt=(t,e,s,i,r,n,a,h)=>{const o=s-t,c=i-e,l=r-t,u=n-e;let p=0;p=0===o?c>0?.5*Math.PI:1.5*Math.PI:0===c?o>0?0:Math.PI:o>=0&&c>=0?Math.atan(c/o):o<=0&&c>=0?Math.atan(-o/c)+.5*Math.PI:o<=0&&c<=0?Math.atan(c/o)+Math.PI:Math.atan(o/-c)+1.5*Math.PI;let f=0;f=0===l?u>0?.5*Math.PI:1.5*Math.PI:0===u?l>0?0:Math.PI:l>=0&&u>=0?Math.atan(u/l):l<=0&&u>=0?Math.atan(-l/u)+.5*Math.PI:l<=0&&u<=0?Math.atan(u/l)+Math.PI:Math.atan(l/-u)+1.5*Math.PI,p>f&&(p-=2*Math.PI);const d=Math.sqrt((s-t)*(s-t)+(i-e)*(i-e)),x=2*Math.PI*d/3,g=a.length/2;a.push(t,e,s,i);for(let y=1;y<x;y++){const s=p+y/x*(f-p),i=t+d*Math.cos(s),r=e+d*Math.sin(s);a.push(i,r)}a.push(r,n);for(let y=1;y<a.length/2-g-1;y++)h.push(0+g,y+g,y+1+g)},$t=(t,e)=>{const{vertices:s,shape:n,lineStyle:a}=t,{width:h,cap:o,join:c,miterLimit:l}=a;let u=0,p=!1;if(n instanceof q?n.closeStroke&&(p=!0):p=!0,p){const t=s[0],e=s[1],i=s[s.length-2],r=s[s.length-1];Math.abs(t-i)<1e-4&&Math.abs(e-r)<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 f=new x(a);e.batchParts.push(f),f.start(e.vertices.length/2,e.indices.length);const d=[],g=[],y=s[0],v=s[1],m=s[2],b=s[3],[w,M]=qt(m-y,b-v,h);if(!p){if(o===i.SQUARE){const t=M,e=-w;d.push(y+w,v+M,y+w+t,v+M+e,y-w+t,v-M+e,y-w,v-M),g.push(0,1,2,0,2,3)}o===i.ROUND&&Zt(y,v,y-w,v-M,y+w,v+M,d,g),i.BUTT}u=d.length/2,d.push(y-w,v-M,y+w,v+M);for(let i=2;i<s.length-2;i+=2){const t=s[i-2],e=s[i-1],n=s[i],a=s[i+1],o=s[i+2],p=s[i+3],[f,x]=qt(n-t,a-e,h),[y,v]=qt(o-n,p-a,h),m=n-t,b=a-e,w=o-n,M=p-a,P=w*b-m*M,T=m*w+b*M;if(Math.abs(P)<.001*Math.abs(T)){d.push(n+f,a+x,n-f,a-x),g.push(0+u,1+u,2+u,0+u,2+u,3+u),u=d.length/2,T>0?d.push(n-f,a-x,n+f,a+x):(c===r.ROUND&&(Zt(n,a,n+f,a+x,n-f,a-x,d,g),u=d.length/2),c===r.BEVEL||r.MITER,d.push(n+f,a+x,n-f,a-x));continue}const[_,E]=zt(t+f,e+x,n+f,a+x,n+y,a+v,o+y,p+v),[B,I]=zt(t-f,e-x,n-f,a-x,n-y,a-v,o-y,p-v);let A=c;c===r.MITER&&(((B-_)**2+(I-E)**2)/h**2<=l**2||(A=r.BEVEL));const S=m*m+b*b+(h/2)**2,C=w*w+M*M+(h/2)**2;(B-n)**2+(I-a)**2<Math.min(S,C)?(A===r.BEVEL&&(P>0?(d.push(_,E,n-f,a-x),g.push(0+u,1+u,2+u,0+u,2+u,3+u),u=d.length/2,d.push(_,E,n-f,a-x,n-y,a-v),g.push(0+u,1+u,2+u),u=d.length/2,d.push(n-y,a-v,_,E)):(d.push(n+f,a+x,B,I),g.push(0+u,1+u,2+u,0+u,2+u,3+u),u=d.length/2,d.push(B,I,n+f,a+x,n+y,a+v),g.push(0+u,1+u,2+u),u=d.length/2,d.push(B,I,n+y,a+v))),A===r.MITER&&(d.push(_,E,B,I),g.push(0+u,1+u,2+u,0+u,2+u,3+u),u=d.length/2,d.push(B,I,_,E)),A===r.ROUND&&(P<0?(d.push(n+f,a+x,B,I),g.push(0+u,1+u,2+u,0+u,2+u,3+u),u=d.length/2,d.push(B,I,n+f,a+x,n,a),g.push(0+u,1+u,2+u),u=d.length/2,d.push(B,I,n+y,a+v,n,a),g.push(0+u,1+u,2+u),u=d.length/2,Zt(n,a,n+f,a+x,n+y,a+v,d,g),u=d.length/2,d.push(B,I,n+y,a+v)):(d.push(_,E,n-f,a-x),g.push(0+u,1+u,2+u,0+u,2+u,3+u),u=d.length/2,d.push(_,E,n-f,a-x,n,a),g.push(0+u,1+u,2+u),u=d.length/2,d.push(_,E,n-y,a-v,n,a),g.push(0+u,1+u,2+u),u=d.length/2,Zt(n,a,n-y,a-v,n-f,a-x,d,g),u=d.length/2,d.push(n-y,a-v,_,E)))):(d.push(n+f,a+x,n-f,a-x),g.push(0+u,1+u,2+u,0+u,2+u,3+u),u=d.length/2,A===r.BEVEL&&(P>0?(d.push(n,a,n-f,a-x,n-y,a-v),g.push(0+u,1+u,2+u)):(d.push(n,a,n+f,a+x,n+y,a+v),g.push(0+u,1+u,2+u))),A===r.MITER&&(P>0?(d.push(n,a,n-f,a-x,B,I,n-y,a-v),g.push(0+u,1+u,2+u,0+u,2+u,3+u)):(d.push(n,a,n+f,a+x,_,E,n+y,a+v),g.push(0+u,1+u,2+u,0+u,2+u,3+u))),A===r.ROUND&&(P>0?Zt(n,a,n-y,a-v,n-f,a-x,d,g):Zt(n,a,n+f,a+x,n+y,a+v,d,g)),u=d.length/2,d.push(n-y,a-v,n+y,a+v))}const P=s[s.length-2],T=s[s.length-1],_=s[s.length-4],E=s[s.length-3],[B,I]=qt(P-_,T-E,h);if(d.push(P+B,T+I,P-B,T-I),g.push(0+u,1+u,2+u,0+u,2+u,3+u),u=d.length/2,!p){const t=s[s.length-2],e=s[s.length-1],r=s[s.length-4],n=s[s.length-3],[a,c]=qt(t-r,e-n,h);if(o===i.SQUARE){const s=-c,i=a;d.push(t+a,e+c,t+a+s,e+c+i,t-a+s,e-c+i,t-a,e-c),g.push(0+u,1+u,2+u,0+u,2+u,3+u)}o===i.ROUND&&Zt(t,e,t+a,e+c,t-a,e-c,d,g)}e.vertices.concat(d),e.indices.concat(g),f.end(d.length/2,g.length)},Xt=class{graphicsData=[];dirty=!1;shapeIndex=0;batchParts=[];vertices=new H;indices=new W;drawShape(t,e,s){const i=new X(t,e,s);this.graphicsData.push(i),this.dirty=!0}containsPoint(t){for(let e=0;e<this.graphicsData.length;e++){const{shape:s,fillStyle:i}=this.graphicsData[e];if(i.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];Gt(e),e.fillStyle.visible&&Yt(e,this),e.lineStyle.visible&&$t(e,this)}this.shapeIndex=this.graphicsData.length}}clear(){this.graphicsData=[],this.vertices.clear(),this.indices.clear(),this.batchParts=[],this.shapeIndex=0,this.dirty=!1}},Ht=class extends k{_lineStyle=new $;_fillStyle=new Z;geometry=new Xt;currentPath=new q;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 i={width:t,color:e,alpha:s};Object.assign(this._lineStyle,i)}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 q};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,i)=>this.drawShape(new c(t,e,s,i));drawCircle=(t,e,s)=>this.drawShape(new Dt(t,e,s));drawRoundedRect=(t,e,s,i,r)=>this.drawShape(new Ot(t,e,s,i,r));drawEllipse=(t,e,s,i)=>this.drawShape(new kt(t,e,s,i));drawPolygon=t=>{const e=new q(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,i=s[s.length-2],r=s[s.length-1];return i===t&&r===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,i)=>{const r=this.currentPath.points.length;0===r&&(this.currentPath.points=[0,0]);const n=this.currentPath.points[r-2],a=this.currentPath.points[r-1],h=t,o=e,c=s,l=i,u=((t,e,s,i,r,n)=>{const a=2*(t-2*s+r),h=-2*(t-s),o=2*(e-2*i+n),c=-2*(e-i),l=a*a+o*o,u=2*(a*h+o*c),p=h*h+c*c,f=Math.sqrt((4*l*p-u*u)/4),d=(l/2+u/4)*Math.sqrt((l+u/2)*(l+u/2)+f*f)+f*f/2*Math.log(Math.abs(l+u/2+Math.sqrt((l+u/2)*(l+u/2)+f*f))),x=u/4*Math.sqrt(u*u/4+f*f)+f*f/2*Math.log(u/2+Math.sqrt(u*u/4+f*f));return 1/(Math.sqrt(l)*l)*(d-x)})(n,a,h,o,c,l);let p=Math.ceil(u/10);p>2048&&(p=2048),p<8&&(p=8);for(let f=1;f<=p;f++){const t=f/p,e=(1-t)*(1-t)*n+2*t*(1-t)*h+t*t*c,s=(1-t)*(1-t)*a+2*t*(1-t)*o+t*t*l;this.currentPath.points.push(e,s)}return this};bezierCurveTo=(t,e,s,i,r,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],c=t,l=e,u=s,p=i,f=r,d=n,x=((t,e,s,i,r,n,a,h)=>{let o=t,c=e,l=0;for(let u=1;u<=10;u++){const p=u/10,f=(1-p)*(1-p)*(1-p)*t+3*p*(1-p)*(1-p)*s+3*p*p*(1-p)*r+p*p*p*a,d=(1-p)*(1-p)*(1-p)*e+3*p*(1-p)*(1-p)*i+3*p*p*(1-p)*n+p*p*p*h,x=f-o,g=d-c;l+=Math.sqrt(x*x+g*g),o=f,c=d}return l})(h,o,c,l,u,p,f,d);let g=Math.ceil(x/10);g>2048&&(g=2048),g<8&&(g=8);for(let y=1;y<=g;y++){const t=y/g,e=(1-t)*(1-t)*(1-t)*h+3*t*(1-t)*(1-t)*c+3*t*t*(1-t)*u+t*t*t*f,s=(1-t)*(1-t)*(1-t)*o+3*t*(1-t)*(1-t)*l+3*t*t*(1-t)*p+t*t*t*d;this.currentPath.points.push(e,s)}return this};arc=(t,e,s,i,r,n=!1)=>{if(!n){for(;r<i;)r+=2*Math.PI;r-i>2*Math.PI&&(r=i+2*Math.PI)}if(n){for(;r>i;)i+=2*Math.PI;i-r>2*Math.PI&&(r=i-2*Math.PI)}const a=r-i;if(0===a)return this;const h=t+Math.cos(i)*s,o=e+Math.sin(i)*s;this.lineTo(h,o);const c=Math.abs(a)*s;let l=Math.ceil(c/10);l>2048&&(l=2048),l<8&&(l=8);for(let u=1;u<=l;u++){const r=i+a*(u/l),n=t+Math.cos(r)*s,h=e+Math.sin(r)*s;this.lineTo(n,h)}return this};arcTo=(t,e,s,i,r)=>{if(!this.currentPath)return this;const n=this.currentPath.points.length;if(0===n||0===r)return this.lineTo(t,e),this;const a=this.currentPath.points[n-1]-e,h=this.currentPath.points[n-2]-t,o=i-e,c=s-t,l=a*c-h*o,u=Math.abs(l);if(u<1e-8)return this.lineTo(t,e),this;const p=a*a+h*h,f=o*o+c*c,d=a*o+h*c,x=r*Math.sqrt(p)/u,g=r*Math.sqrt(f)/u,y=x*d/p,v=g*d/f,m=x*c+g*h,b=x*o+g*a,w=h*(g+y),M=a*(g+y),P=c*(x+v),T=o*(x+v),_=Math.atan2(M-b,w-m),E=Math.atan2(T-b,P-m),B=h*o>c*a;return this.arc(m+t,b+e,r,_,E,B)};clear=()=>(this.geometry.clear(),this._lineStyle.reset(),this._fillStyle.reset(),this.currentPath=new q,this.batches=[],this.batchCount=0,this.markStructureDirty(),this);renderCanvas=t=>{this.startPoly();const e=t.ctx,{a:s,b:i,c:r,d:n,tx:a,ty:h}=this.transform.worldTransform;e.setTransform(s,i,r,n,a,h);const o=this.geometry.graphicsData;for(let l=0;l<o.length;l++){const{lineStyle:t,fillStyle:s,shape:i}=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(),i instanceof c){const{x:r,y:n,width:a,height:h}=i;s.visible&&(e.globalAlpha=s.alpha*this.worldAlpha,e.fillRect(r,n,a,h)),t.visible&&(e.globalAlpha=t.alpha*this.worldAlpha,e.strokeRect(r,n,a,h))}if(i instanceof Dt){const{x:r,y:n,radius:a}=i;e.arc(r,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(i instanceof Ot){const{x:r,y:n,width:a,height:h,radius:o}=i;e.moveTo(r+o,n),e.arc(r+o,n+o,o,1.5*Math.PI,Math.PI,!0),e.lineTo(r,n+h-o),e.arc(r+o,n+h-o,o,Math.PI,Math.PI/2,!0),e.lineTo(r+a-o,n+h),e.arc(r+a-o,n+h-o,o,Math.PI/2,0,!0),e.lineTo(r+a,n+o),e.arc(r+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(i instanceof kt){const{x:r,y:n,radiusX:a,radiusY:h}=i;e.ellipse(r,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(i instanceof q){const{points:r,closeStroke:n}=i;e.moveTo(r[0],r[1]);for(let t=2;t<r.length;t+=2)e.lineTo(r[t],r[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:i,vertexStart:r,vertexCount:n,indexStart:a,indexCount:h}=e[s],{color:o,alpha:c}=i,l=B(o,c*this.worldAlpha),u=m.get(this.type);u.vertexCount=n,u.indexCount=h,u.rgba=l,u.vertexOffset=r,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)}}};export{z as Application,h as BYTES_PER_VERTEX,k as Container,Ht as Graphics,i as LINE_CAP,r as LINE_JOIN,a as MAX_VERTEX_COUNT,n as RENDERER_TYPE,s as SHAPE_TYPE};
@@ -0,0 +1,2 @@
1
+ export declare const getBezierLength: (P0X: number, P0Y: number, P1X: number, P1Y: number, P2X: number, P2Y: number, P3X: number, P3Y: number) => number;
2
+ export declare const getQuadraticBezierLength: (P0X: number, P0Y: number, P1X: number, P1Y: number, P2X: number, P2Y: number) => number;
@@ -0,0 +1,3 @@
1
+ export declare const DEG_TO_RAD: number;
2
+ export declare const RAD_TO_DEG: number;
3
+ export declare const PI_2: number;
@@ -0,0 +1,5 @@
1
+ import { getBezierLength, getQuadraticBezierLength } from '@/utils/visual/math/bezier';
2
+ import { DEG_TO_RAD, PI_2, RAD_TO_DEG } from '@/utils/visual/math/enums';
3
+ import { Matrix } from '@/utils/visual/math/matrix';
4
+ import { Transform } from '@/utils/visual/math/transform';
5
+ export { getBezierLength, getQuadraticBezierLength, DEG_TO_RAD, PI_2, RAD_TO_DEG, Matrix, Transform };
@@ -0,0 +1,113 @@
1
+ import { Point } from '@/utils/visual/vertex/point';
2
+ interface TransformableObject {
3
+ position: Point;
4
+ scale: Point;
5
+ pivot: Point;
6
+ skew: Point;
7
+ rotation: number;
8
+ }
9
+ export declare class Matrix {
10
+ a: number;
11
+ b: number;
12
+ c: number;
13
+ d: number;
14
+ tx: number;
15
+ ty: number;
16
+ array: Float32Array | null;
17
+ constructor(a?: number, b?: number, c?: number, d?: number, tx?: number, ty?: number);
18
+ set: (a: number, b: number, c: number, d: number, tx: number, ty: number) => Matrix;
19
+ /**
20
+ * 将当前矩阵右乘一个矩阵
21
+ */
22
+ append: (m: Matrix) => Matrix;
23
+ /**
24
+ * Creates a Matrix object based on the given array. The Element to Matrix mapping order is as follows:
25
+ *
26
+ * a = array[0]
27
+ * b = array[1]
28
+ * c = array[3]
29
+ * d = array[4]
30
+ * tx = array[2]
31
+ * ty = array[5]
32
+ * @param array - The array that the matrix will be populated from.
33
+ *
34
+ * a,b,tx
35
+ * c,d,ty
36
+ */
37
+ fromArray: (array: number[]) => void;
38
+ /**
39
+ * Translates the matrix on the x and y.
40
+ * @param x - How much to translate x by
41
+ * @param y - How much to translate y by
42
+ * @returns This matrix. Good for chaining method calls.
43
+ */
44
+ translate: (x: number, y: number) => Matrix;
45
+ /**
46
+ * Applies a scale transformation to the matrix.
47
+ * @param x - The amount to scale horizontally
48
+ * @param y - The amount to scale vertically
49
+ * @returns This matrix. Good for chaining method calls.
50
+ */
51
+ scale: (x: number, y: number) => Matrix;
52
+ /**
53
+ * Sets the matrix based on all the available properties
54
+ * @param x - Position on the x axis
55
+ * @param y - Position on the y axis
56
+ * @param pivotX - Pivot on the x axis
57
+ * @param pivotY - Pivot on the y axis
58
+ * @param scaleX - Scale on the x axis
59
+ * @param scaleY - Scale on the y axis
60
+ * @param rotation - Rotation in radians
61
+ * @param skewX - Skew on the x axis
62
+ * @param skewY - Skew on the y axis
63
+ * @returns This matrix. Good for chaining method calls.
64
+ */
65
+ setTransform: (x: number, y: number, pivotX: number, pivotY: number, scaleX: number, scaleY: number, rotation: number, skewX: number, skewY: number) => Matrix;
66
+ /**
67
+ * Applies a rotation transformation to the matrix.
68
+ * @param angle - The angle in radians.
69
+ * @returns This matrix. Good for chaining method calls.
70
+ */
71
+ rotate: (angle: number) => Matrix;
72
+ /**
73
+ * check to see if two matrices are the same
74
+ * @param matrix - The matrix to compare to.
75
+ */
76
+ equals: (matrix: Matrix) => boolean;
77
+ /**
78
+ * Resets this Matrix to an identity (default) matrix.
79
+ * @returns This matrix. Good for chaining method calls.
80
+ */
81
+ identity: () => Matrix;
82
+ /**
83
+ * Decomposes the matrix (x, y, scaleX, scaleY, and rotation) and sets the properties on to a transform.
84
+ * @param transform - The transform to apply the properties to.
85
+ * @returns The transform with the newly applied properties
86
+ */
87
+ decompose: (transform: TransformableObject) => TransformableObject;
88
+ /**
89
+ * 对某个点应用当前的变换矩阵
90
+ * @param p 某个点
91
+ * @returns {Point} 点 p 应用当前变换矩阵后得到的一个新的点
92
+ */
93
+ apply: (p: Point) => Point;
94
+ /**
95
+ * 对某个点应用当前的变换矩阵的逆矩阵
96
+ * @param p 某个点
97
+ * @returns {Point} 点 p 应用当前变换矩阵的逆矩阵后得到的一个新的点
98
+ */
99
+ applyInverse: (p: Point) => Point;
100
+ /**
101
+ * 将当前矩阵左乘一个矩阵
102
+ */
103
+ prepend: (m: Matrix) => Matrix;
104
+ clone: () => Matrix;
105
+ /**
106
+ * Creates an array from the current Matrix object.
107
+ * @param transpose - Whether we need to transpose the matrix or not
108
+ * @param [out=new Float32Array(9)] - If provided the array will be assigned to out
109
+ * @returns The newly created array which contains the matrix
110
+ */
111
+ toArray: (transpose?: boolean, out?: Float32Array) => Float32Array;
112
+ }
113
+ export {};
@@ -0,0 +1,29 @@
1
+ import { Matrix } from '@/utils/visual/math/matrix';
2
+ import { ObservablePoint } from '@/utils/visual/vertex/point';
3
+ export declare class Transform {
4
+ localTransform: Matrix;
5
+ worldTransform: Matrix;
6
+ position: ObservablePoint;
7
+ scale: ObservablePoint;
8
+ pivot: ObservablePoint;
9
+ skew: ObservablePoint;
10
+ _rotation: number;
11
+ private rotateMatrix;
12
+ private skewMatrix;
13
+ private scaleMatrix;
14
+ private localMatrix;
15
+ shouldUpdateLocalTransform: boolean;
16
+ worldId: number;
17
+ private parentId;
18
+ constructor();
19
+ get rotation(): number;
20
+ set rotation(r: number);
21
+ private onSkewChange;
22
+ private onScaleChange;
23
+ private onChange;
24
+ /**
25
+ * 更新 localTransform
26
+ */
27
+ updateLocalTransform(): void;
28
+ updateTransform(parentTransform: Transform): void;
29
+ }
@@ -0,0 +1,78 @@
1
+ import { Renderer } from '@/utils/visual/render/render';
2
+ import type { Container } from '@/utils/visual/vertex/container';
3
+ import type { Batch } from '@/utils/visual/render/utils/batch';
4
+ import type { IApplicationOptions } from '@/utils/visual/types';
5
+ export declare abstract class BatchRenderer extends Renderer {
6
+ /**
7
+ * 上次构建大数组时的场景结构版本号(每个渲染器实例独立)。与根节点的 structureVersion
8
+ * 不一致时说明场景结构变了(增删节点 / 重绘),需要重建;否则只做逐帧 transform 更新。
9
+ * 初值 -1 保证首帧一定构建。基于版本号对比,多个渲染器共享同一场景也不会互相“消费”脏标记。
10
+ */
11
+ protected builtVersion: number;
12
+ /**
13
+ * 顶点个数
14
+ */
15
+ protected vertexCount: number;
16
+ /**
17
+ * 顶点下标个数
18
+ */
19
+ protected indexCount: number;
20
+ protected batches: Array<Batch | undefined>;
21
+ protected batchesCount: number;
22
+ /**
23
+ * 顶点数组 float32 视图
24
+ */
25
+ protected vertFloatView: Float32Array;
26
+ /**
27
+ * 顶点数组 Uint32 视图
28
+ */
29
+ protected vertIntView: Uint32Array;
30
+ /**
31
+ * 顶点下标数组
32
+ */
33
+ protected indexBuffer: Uint32Array;
34
+ /**
35
+ * 当前的 webGL|webGPU vertex buffer 的长度
36
+ */
37
+ protected curVertBufferLength: number;
38
+ /**
39
+ * 当前的 webGL|webGPU index buffer 的长度
40
+ */
41
+ protected curIndexBufferLength: number;
42
+ constructor(options: IApplicationOptions);
43
+ addBatch(batch: Batch): void;
44
+ protected startBuild(): void;
45
+ protected buildEnd(): void;
46
+ /**
47
+ * 如果现有的 typed array 放不下了,则新建一个
48
+ */
49
+ protected resizeBufferIfNeeded(): void;
50
+ /**
51
+ * 将数据打包到大数组里
52
+ */
53
+ protected packData(): void;
54
+ /**
55
+ * 调用 webGL 或 webGPU 的绘制 api 将内容绘制出来
56
+ */
57
+ protected abstract draw(): void;
58
+ /**
59
+ * 更新更新 vertex buffer 和 index buffer
60
+ */
61
+ protected abstract updateBuffer(): void;
62
+ /**
63
+ * 设置投影矩阵,这是为了适配 canvas 元素的尺寸
64
+ */
65
+ protected abstract setProjectionMatrix(): void;
66
+ /**
67
+ * 更新 stage 的 transform 对应的 uniform 变量
68
+ */
69
+ protected abstract setRootTransform(a: number, b: number, c: number, d: number, tx: number, ty: number): void;
70
+ /**
71
+ * 更新子节点的 transform
72
+ */
73
+ protected updateChildrenTransform(rootContainer: Container): void;
74
+ /**
75
+ * 更新节点的位置信息并渲染
76
+ */
77
+ render(rootContainer: Container): void;
78
+ }
@@ -0,0 +1,10 @@
1
+ import { Renderer } from '@/utils/visual/render/render';
2
+ import type { IApplicationOptions } from '@/utils/visual/types';
3
+ import type { Container } from '@/utils/visual/vertex/container';
4
+ export declare class CanvasRenderer extends Renderer {
5
+ ctx: CanvasRenderingContext2D;
6
+ private backgroundColor;
7
+ private backgroundAlpha;
8
+ constructor(options: IApplicationOptions);
9
+ render(container: Container): void;
10
+ }
@@ -0,0 +1,3 @@
1
+ import type { Renderer } from '@/utils/visual/render/render';
2
+ import type { IApplicationOptions } from '@/utils/visual/types';
3
+ export declare const getRenderer: (options: IApplicationOptions) => Renderer;
@@ -0,0 +1,11 @@
1
+ import { Rectangle } from '@/utils/visual/shape/rectangle';
2
+ import type { Container } from '@/utils/visual/vertex/container';
3
+ import type { IApplicationOptions } from '@/utils/visual/types';
4
+ export declare abstract class Renderer {
5
+ canvasEle: HTMLCanvasElement;
6
+ screen: Rectangle;
7
+ constructor(options: IApplicationOptions);
8
+ resizeView(width: number, height: number): void;
9
+ abstract render(rootContainer: Container): void;
10
+ init(): Promise<any>;
11
+ }
@@ -0,0 +1,90 @@
1
+ import type { BatchRenderer } from '@/utils/visual/render/batchRenderer';
2
+ import type { Container } from '@/utils/visual/vertex/container';
3
+ import type { Fill } from '@/utils/visual/style';
4
+ import type { Graphics } from '@/utils/visual/graphics';
5
+ /**
6
+ * 构建大数组
7
+ */
8
+ export declare const buildArray: (batchRenderer: BatchRenderer, container: Container) => void;
9
+ /**
10
+ * 更新大数组
11
+ */
12
+ export declare const updateArray: (floatView: Float32Array, container: Container) => void;
13
+ export declare abstract class Batch {
14
+ /**
15
+ * 顶点个数
16
+ */
17
+ vertexCount: number;
18
+ /**
19
+ * 顶点下标个数
20
+ */
21
+ indexCount: number;
22
+ /**
23
+ * rgba 的小端序形式
24
+ */
25
+ rgba: number;
26
+ /**
27
+ * 顶点数据在大数组中的起点
28
+ */
29
+ vertexStart: number;
30
+ /**
31
+ * 顶点下标数据在大数组中的起点
32
+ */
33
+ indexStart: number;
34
+ /**
35
+ * 将顶点数据写入大数组中
36
+ */
37
+ abstract packVertices(floatView: Float32Array, intView: Uint32Array): void;
38
+ /**
39
+ * 将顶点下标数据写入大数组中
40
+ */
41
+ abstract packIndices(int32: Uint32Array): void;
42
+ /**
43
+ * 在大数组中更新顶点位置数据
44
+ */
45
+ abstract updateVertices(floatView: Float32Array): void;
46
+ }
47
+ export declare class BatchPart {
48
+ style: Fill;
49
+ vertexStart: number;
50
+ indexStart: number;
51
+ vertexCount: number;
52
+ indexCount: number;
53
+ constructor(style: Fill);
54
+ start(vertexStart: number, indexStart: number): void;
55
+ end(vertexCount: number, indexCount: number): void;
56
+ }
57
+ export declare abstract class BatchPool {
58
+ protected idx: number;
59
+ abstract getOne(): Batch;
60
+ reset(): void;
61
+ }
62
+ export declare class GraphicsBatchPool extends BatchPool {
63
+ private batches;
64
+ constructor();
65
+ getOne(): GraphicsBatch;
66
+ }
67
+ export declare class GraphicsBatch extends Batch {
68
+ /**
69
+ * 顶点部分在 geometry.vertices 中的起始下标
70
+ */
71
+ vertexOffset: number;
72
+ /**
73
+ * 顶点下标部分在 geometry.indices 中的起始下标
74
+ */
75
+ indexOffset: number;
76
+ /**
77
+ * 对应的 Graphics 实例
78
+ */
79
+ graphics: Graphics;
80
+ packVertices(floatView: Float32Array, intView: Uint32Array): void;
81
+ packIndices(int32: Uint32Array): void;
82
+ updateVertices(floatView: Float32Array): void;
83
+ }
84
+ declare class BatchPools {
85
+ private batchesMap;
86
+ get(type: string): Batch;
87
+ reset(): void;
88
+ }
89
+ export declare const batchPool: BatchPools;
90
+ export {};
@@ -0,0 +1,63 @@
1
+ export declare class CustomFloatArray {
2
+ private _oldLength;
3
+ private _length;
4
+ private curMaxLen;
5
+ private float32;
6
+ private _data;
7
+ /**
8
+ * 获取长度
9
+ */
10
+ get length(): number;
11
+ /**
12
+ * 拼接一个 number 数组
13
+ */
14
+ concat(arr: number[]): void;
15
+ /**
16
+ * 插入数据
17
+ * @param num 要插入的数
18
+ */
19
+ push(num: number): void;
20
+ /**
21
+ * 扩容
22
+ */
23
+ expandCapacity(): void;
24
+ /**
25
+ * 以从 0 到 this.length 的这段 buffer 为底层,建立 Float32Array 视图并返回
26
+ */
27
+ get data(): Float32Array;
28
+ /**
29
+ * 清空
30
+ */
31
+ clear(): void;
32
+ }
33
+ export declare class CustomIntArray {
34
+ private _oldLength;
35
+ private _length;
36
+ private curMaxLen;
37
+ private int32;
38
+ private _data;
39
+ /**
40
+ * 获取长度
41
+ */
42
+ get length(): number;
43
+ /**
44
+ * 拼接一个 number 数组
45
+ */
46
+ concat(arr: number[]): void;
47
+ /**
48
+ * 拼接一个UInt16数组
49
+ */
50
+ concatUInt16(uint16: Uint32Array): void;
51
+ /**
52
+ * 扩容
53
+ */
54
+ expandCapacity(): void;
55
+ /**
56
+ * 以从 0 到 this.length 的这段 buffer 为底层,建立 Uint32Array 视图并返回
57
+ */
58
+ get data(): Uint32Array;
59
+ /**
60
+ * 清空
61
+ */
62
+ clear(): void;
63
+ }
@@ -0,0 +1,3 @@
1
+ export declare const getRgb: (color: string) => [number, number, number];
2
+ export declare const toRgbaLittleEndian: (color: string, alpha: number) => number;
3
+ export declare const toRgbArray: (color: string) => [number, number, number];
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,13 @@
1
+ import type { GraphicsData } from '@/utils/visual/graphics/graphicsData';
2
+ import type { GraphicsGeometry } from '@/utils/visual/graphics/graphicsGeometry';
3
+ /**
4
+ * 将一个图形顶点化
5
+ * @param data 子图形data
6
+ */
7
+ export declare const buildVertices: (data: GraphicsData) => void;
8
+ export declare const triangulateFill: (data: GraphicsData, geometry: GraphicsGeometry) => void;
9
+ export declare const getNormalVector: (x: number, y: number, lineWidth: number) => [number, number];
10
+ /**
11
+ * 构建描边的顶点 & 对其进行三角剖分
12
+ */
13
+ export declare const triangulateStroke: (data: GraphicsData, geometry: GraphicsGeometry) => void;
@@ -0,0 +1,7 @@
1
+ import type { WebGLRenderer } from '@/utils/visual/render/webGlRenderer';
2
+ /**
3
+ * 设置顶点属性布局。调用前需保证目标 ARRAY_BUFFER 已经绑定。
4
+ * 顶点格式与共享批处理管线(BatchRenderer)一致:position(2×Float32) + color(4×Uint8, 归一化),stride = BYTES_PER_VERTEX。
5
+ */
6
+ export declare const setupVertexLayout: (gl: WebGLRenderingContext, program: WebGLProgram) => void;
7
+ export declare const initShader: (renderer: WebGLRenderer) => WebGLProgram;
@@ -0,0 +1,2 @@
1
+ export declare const vertexShaderSource: string;
2
+ export declare const fragmentShaderSource: string;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * 顶点着色器
3
+ */
4
+ export declare const vertexShaderSource = "\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";
5
+ /**
6
+ * 片元着色器
7
+ */
8
+ export declare const fragmentShaderSource = "\n@fragment\nfn main(\n @location(0) v_color : vec4<f32>,\n) -> @location(0) vec4<f32> {\n return v_color;\n}\n";
@@ -0,0 +1,49 @@
1
+ import { BatchRenderer } from '@/utils/visual/render/batchRenderer';
2
+ import type { IApplicationOptions } from '@/utils/visual/types';
3
+ export declare class WebGPURenderer extends BatchRenderer {
4
+ private gpu;
5
+ private device;
6
+ private pipeline;
7
+ private renderPassDescriptor;
8
+ private options;
9
+ /**
10
+ * 顶点的 webGPU buffer
11
+ */
12
+ private gpuVertexBuffer;
13
+ /**
14
+ * 顶点下标的 webGPU buffer
15
+ */
16
+ private gpuIndexBuffer;
17
+ /**
18
+ * 投影矩阵的 webGPU buffer
19
+ */
20
+ private projectionMatBuffer;
21
+ /**
22
+ * stage 的变换矩阵的 webGPU buffer
23
+ */
24
+ private stageMatBuffer;
25
+ /**
26
+ * uniform 变量的 bind group
27
+ */
28
+ private uniformBindGroup;
29
+ constructor(options: IApplicationOptions);
30
+ init(): Promise<void>;
31
+ protected draw(): void;
32
+ private initUniformBindGroup;
33
+ private initGpuBuffer;
34
+ protected updateBuffer(): void;
35
+ protected setRootTransform(a: number, b: number, c: number, d: number, tx: number, ty: number): void;
36
+ protected setProjectionMatrix(): void;
37
+ /**
38
+ * 初始化 pipeline
39
+ */
40
+ private createPipeline;
41
+ /**
42
+ * 初始化 device
43
+ */
44
+ private initDevice;
45
+ /**
46
+ * 初始化 renderPassDescriptor
47
+ */
48
+ private initRenderPassDescriptor;
49
+ }