@nice2dev/ui-graphics 1.0.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 (511) hide show
  1. package/CHANGELOG.md +84 -0
  2. package/LICENSE +21 -0
  3. package/README.md +339 -0
  4. package/dist/cjs/animation/AnimatedPerson.js +153 -0
  5. package/dist/cjs/animation/AnimatedPerson.js.map +1 -0
  6. package/dist/cjs/animation/AnimationEditor.js +106 -0
  7. package/dist/cjs/animation/AnimationEditor.js.map +1 -0
  8. package/dist/cjs/animation/Audience.js +59 -0
  9. package/dist/cjs/animation/Audience.js.map +1 -0
  10. package/dist/cjs/animation/BodyRenderer.js +33 -0
  11. package/dist/cjs/animation/BodyRenderer.js.map +1 -0
  12. package/dist/cjs/animation/animationHelper.js +272 -0
  13. package/dist/cjs/animation/animationHelper.js.map +1 -0
  14. package/dist/cjs/animation/characterTypes.js +75 -0
  15. package/dist/cjs/animation/characterTypes.js.map +1 -0
  16. package/dist/cjs/animation/choreoDSL.js +190 -0
  17. package/dist/cjs/animation/choreoDSL.js.map +1 -0
  18. package/dist/cjs/animation/choreography.js +41 -0
  19. package/dist/cjs/animation/choreography.js.map +1 -0
  20. package/dist/cjs/animation/karaokeIntegration.js +98 -0
  21. package/dist/cjs/animation/karaokeIntegration.js.map +1 -0
  22. package/dist/cjs/animation/lottieExport.js +128 -0
  23. package/dist/cjs/animation/lottieExport.js.map +1 -0
  24. package/dist/cjs/animation/motionPath.js +196 -0
  25. package/dist/cjs/animation/motionPath.js.map +1 -0
  26. package/dist/cjs/animation/physics.js +201 -0
  27. package/dist/cjs/animation/physics.js.map +1 -0
  28. package/dist/cjs/animation/rig/RigPlayer.js +63 -0
  29. package/dist/cjs/animation/rig/RigPlayer.js.map +1 -0
  30. package/dist/cjs/animation/rig/RiggedBody.js +30 -0
  31. package/dist/cjs/animation/rig/RiggedBody.js.map +1 -0
  32. package/dist/cjs/animation/rig/choreoRigBridge.js +63 -0
  33. package/dist/cjs/animation/rig/choreoRigBridge.js.map +1 -0
  34. package/dist/cjs/animation/rig/ik.js +22 -0
  35. package/dist/cjs/animation/rig/ik.js.map +1 -0
  36. package/dist/cjs/animation/rig/poseOps.js +49 -0
  37. package/dist/cjs/animation/rig/poseOps.js.map +1 -0
  38. package/dist/cjs/animation/rig/presets.js +60 -0
  39. package/dist/cjs/animation/rig/presets.js.map +1 -0
  40. package/dist/cjs/animation/rig/rigMath.js +41 -0
  41. package/dist/cjs/animation/rig/rigMath.js.map +1 -0
  42. package/dist/cjs/animation/rig/rigTypes.js +44 -0
  43. package/dist/cjs/animation/rig/rigTypes.js.map +1 -0
  44. package/dist/cjs/animation/shapes/arms.js +15 -0
  45. package/dist/cjs/animation/shapes/arms.js.map +1 -0
  46. package/dist/cjs/animation/shapes/eyes.js +52 -0
  47. package/dist/cjs/animation/shapes/eyes.js.map +1 -0
  48. package/dist/cjs/animation/shapes/hair.js +55 -0
  49. package/dist/cjs/animation/shapes/hair.js.map +1 -0
  50. package/dist/cjs/animation/shapes/heads.js +62 -0
  51. package/dist/cjs/animation/shapes/heads.js.map +1 -0
  52. package/dist/cjs/animation/shapes/headwear.js +44 -0
  53. package/dist/cjs/animation/shapes/headwear.js.map +1 -0
  54. package/dist/cjs/animation/shapes/legs.js +15 -0
  55. package/dist/cjs/animation/shapes/legs.js.map +1 -0
  56. package/dist/cjs/animation/shapes/mouths.js +53 -0
  57. package/dist/cjs/animation/shapes/mouths.js.map +1 -0
  58. package/dist/cjs/animation/shapes/noses.js +31 -0
  59. package/dist/cjs/animation/shapes/noses.js.map +1 -0
  60. package/dist/cjs/animation/shapes/outfits.js +43 -0
  61. package/dist/cjs/animation/shapes/outfits.js.map +1 -0
  62. package/dist/cjs/animation/shapes/torsos.js +13 -0
  63. package/dist/cjs/animation/shapes/torsos.js.map +1 -0
  64. package/dist/cjs/animation/spineExport.js +132 -0
  65. package/dist/cjs/animation/spineExport.js.map +1 -0
  66. package/dist/cjs/core/LocalUI.js +54 -0
  67. package/dist/cjs/core/LocalUI.js.map +1 -0
  68. package/dist/cjs/core/collaboration.js +259 -0
  69. package/dist/cjs/core/collaboration.js.map +1 -0
  70. package/dist/cjs/core/colorBlindness.js +97 -0
  71. package/dist/cjs/core/colorBlindness.js.map +1 -0
  72. package/dist/cjs/core/dragDrop.js +168 -0
  73. package/dist/cjs/core/dragDrop.js.map +1 -0
  74. package/dist/cjs/core/fixes.js +185 -0
  75. package/dist/cjs/core/fixes.js.map +1 -0
  76. package/dist/cjs/core/gridGuides.js +245 -0
  77. package/dist/cjs/core/gridGuides.js.map +1 -0
  78. package/dist/cjs/core/historyVisual.js +124 -0
  79. package/dist/cjs/core/historyVisual.js.map +1 -0
  80. package/dist/cjs/core/i18n.js +16 -0
  81. package/dist/cjs/core/i18n.js.map +1 -0
  82. package/dist/cjs/core/integrations.js +261 -0
  83. package/dist/cjs/core/integrations.js.map +1 -0
  84. package/dist/cjs/core/minimap.js +142 -0
  85. package/dist/cjs/core/minimap.js.map +1 -0
  86. package/dist/cjs/core/plugins.js +129 -0
  87. package/dist/cjs/core/plugins.js.map +1 -0
  88. package/dist/cjs/core/rtl.js +102 -0
  89. package/dist/cjs/core/rtl.js.map +1 -0
  90. package/dist/cjs/core/shortcuts.js +205 -0
  91. package/dist/cjs/core/shortcuts.js.map +1 -0
  92. package/dist/cjs/core/theme.js +171 -0
  93. package/dist/cjs/core/theme.js.map +1 -0
  94. package/dist/cjs/font/NiceFontEditor.js +193 -0
  95. package/dist/cjs/font/NiceFontEditor.js.map +1 -0
  96. package/dist/cjs/game/GameAsset2dEditor.js +371 -0
  97. package/dist/cjs/game/GameAsset2dEditor.js.map +1 -0
  98. package/dist/cjs/game/GameAsset2dEditor.module.css.js +6 -0
  99. package/dist/cjs/game/GameAsset2dEditor.module.css.js.map +1 -0
  100. package/dist/cjs/game/gameAssetTypes.js +20 -0
  101. package/dist/cjs/game/gameAssetTypes.js.map +1 -0
  102. package/dist/cjs/game/gameAssetUtils.js +475 -0
  103. package/dist/cjs/game/gameAssetUtils.js.map +1 -0
  104. package/dist/cjs/game/useGameAssetEditor.js +761 -0
  105. package/dist/cjs/game/useGameAssetEditor.js.map +1 -0
  106. package/dist/cjs/icon/NiceIconEditor.js +249 -0
  107. package/dist/cjs/icon/NiceIconEditor.js.map +1 -0
  108. package/dist/cjs/index.js +264 -0
  109. package/dist/cjs/index.js.map +1 -0
  110. package/dist/cjs/nice2dev-ui/dist/index.js +32070 -0
  111. package/dist/cjs/nice2dev-ui/dist/index.js.map +1 -0
  112. package/dist/cjs/nice2dev-ui-graphics.css +1 -0
  113. package/dist/cjs/photo/FilterThumb.js +29 -0
  114. package/dist/cjs/photo/FilterThumb.js.map +1 -0
  115. package/dist/cjs/photo/PhotoEditor.js +20 -0
  116. package/dist/cjs/photo/PhotoEditor.js.map +1 -0
  117. package/dist/cjs/photo/PhotoEditor.module.css.js +6 -0
  118. package/dist/cjs/photo/PhotoEditor.module.css.js.map +1 -0
  119. package/dist/cjs/photo/PhotoEditorCanvas.js +59 -0
  120. package/dist/cjs/photo/PhotoEditorCanvas.js.map +1 -0
  121. package/dist/cjs/photo/PhotoEditorLeftPanel.js +174 -0
  122. package/dist/cjs/photo/PhotoEditorLeftPanel.js.map +1 -0
  123. package/dist/cjs/photo/PhotoEditorToolbar.js +15 -0
  124. package/dist/cjs/photo/PhotoEditorToolbar.js.map +1 -0
  125. package/dist/cjs/photo/photoEditorActions.js +80 -0
  126. package/dist/cjs/photo/photoEditorActions.js.map +1 -0
  127. package/dist/cjs/photo/photoEditorTypes.js +40 -0
  128. package/dist/cjs/photo/photoEditorTypes.js.map +1 -0
  129. package/dist/cjs/photo/photoFilters.js +880 -0
  130. package/dist/cjs/photo/photoFilters.js.map +1 -0
  131. package/dist/cjs/photo/photoOverlays.js +651 -0
  132. package/dist/cjs/photo/photoOverlays.js.map +1 -0
  133. package/dist/cjs/photo/photoSelection.js +547 -0
  134. package/dist/cjs/photo/photoSelection.js.map +1 -0
  135. package/dist/cjs/photo/usePhotoEditor.js +640 -0
  136. package/dist/cjs/photo/usePhotoEditor.js.map +1 -0
  137. package/dist/cjs/pixel/HSVPicker.js +173 -0
  138. package/dist/cjs/pixel/HSVPicker.js.map +1 -0
  139. package/dist/cjs/pixel/PixelEditor.js +28 -0
  140. package/dist/cjs/pixel/PixelEditor.js.map +1 -0
  141. package/dist/cjs/pixel/PixelEditor.module.css.js +6 -0
  142. package/dist/cjs/pixel/PixelEditor.module.css.js.map +1 -0
  143. package/dist/cjs/pixel/PixelEditorCanvas.js +15 -0
  144. package/dist/cjs/pixel/PixelEditorCanvas.js.map +1 -0
  145. package/dist/cjs/pixel/PixelEditorMenuBar.js +11 -0
  146. package/dist/cjs/pixel/PixelEditorMenuBar.js.map +1 -0
  147. package/dist/cjs/pixel/PixelEditorRightPanel.js +15 -0
  148. package/dist/cjs/pixel/PixelEditorRightPanel.js.map +1 -0
  149. package/dist/cjs/pixel/PixelEditorStatusBar.js +15 -0
  150. package/dist/cjs/pixel/PixelEditorStatusBar.js.map +1 -0
  151. package/dist/cjs/pixel/PixelEditorTimeline.js +11 -0
  152. package/dist/cjs/pixel/PixelEditorTimeline.js.map +1 -0
  153. package/dist/cjs/pixel/PixelEditorToolbar.js +16 -0
  154. package/dist/cjs/pixel/PixelEditorToolbar.js.map +1 -0
  155. package/dist/cjs/pixel/asepriteFormat.js +512 -0
  156. package/dist/cjs/pixel/asepriteFormat.js.map +1 -0
  157. package/dist/cjs/pixel/pixelEditorExports.js +471 -0
  158. package/dist/cjs/pixel/pixelEditorExports.js.map +1 -0
  159. package/dist/cjs/pixel/pixelEditorTypes.js +102 -0
  160. package/dist/cjs/pixel/pixelEditorTypes.js.map +1 -0
  161. package/dist/cjs/pixel/pixelEditorUtils.js +664 -0
  162. package/dist/cjs/pixel/pixelEditorUtils.js.map +1 -0
  163. package/dist/cjs/pixel/usePixelEditor.js +1112 -0
  164. package/dist/cjs/pixel/usePixelEditor.js.map +1 -0
  165. package/dist/cjs/texture/Nice3DTexturePainter.js +236 -0
  166. package/dist/cjs/texture/Nice3DTexturePainter.js.map +1 -0
  167. package/dist/cjs/ui/NiceUIDesigner.js +191 -0
  168. package/dist/cjs/ui/NiceUIDesigner.js.map +1 -0
  169. package/dist/cjs/vector/VectorEditor.js +31 -0
  170. package/dist/cjs/vector/VectorEditor.js.map +1 -0
  171. package/dist/cjs/vector/VectorEditor.module.css.js +6 -0
  172. package/dist/cjs/vector/VectorEditor.module.css.js.map +1 -0
  173. package/dist/cjs/vector/VectorEditorMenuBar.js +16 -0
  174. package/dist/cjs/vector/VectorEditorMenuBar.js.map +1 -0
  175. package/dist/cjs/vector/VectorEditorRightPanel.js +126 -0
  176. package/dist/cjs/vector/VectorEditorRightPanel.js.map +1 -0
  177. package/dist/cjs/vector/VectorEditorShapeRenderer.js +55 -0
  178. package/dist/cjs/vector/VectorEditorShapeRenderer.js.map +1 -0
  179. package/dist/cjs/vector/VectorEditorStatusBar.js +14 -0
  180. package/dist/cjs/vector/VectorEditorStatusBar.js.map +1 -0
  181. package/dist/cjs/vector/useVectorEditor.js +613 -0
  182. package/dist/cjs/vector/useVectorEditor.js.map +1 -0
  183. package/dist/cjs/vector/vectorBooleanOps.js +511 -0
  184. package/dist/cjs/vector/vectorBooleanOps.js.map +1 -0
  185. package/dist/cjs/vector/vectorEditorExport.js +159 -0
  186. package/dist/cjs/vector/vectorEditorExport.js.map +1 -0
  187. package/dist/cjs/vector/vectorEditorImport.js +150 -0
  188. package/dist/cjs/vector/vectorEditorImport.js.map +1 -0
  189. package/dist/cjs/vector/vectorEditorTypes.js +72 -0
  190. package/dist/cjs/vector/vectorEditorTypes.js.map +1 -0
  191. package/dist/cjs/vector/vectorGradients.js +201 -0
  192. package/dist/cjs/vector/vectorGradients.js.map +1 -0
  193. package/dist/esm/animation/AnimatedPerson.js +151 -0
  194. package/dist/esm/animation/AnimatedPerson.js.map +1 -0
  195. package/dist/esm/animation/AnimationEditor.js +104 -0
  196. package/dist/esm/animation/AnimationEditor.js.map +1 -0
  197. package/dist/esm/animation/Audience.js +57 -0
  198. package/dist/esm/animation/Audience.js.map +1 -0
  199. package/dist/esm/animation/BodyRenderer.js +28 -0
  200. package/dist/esm/animation/BodyRenderer.js.map +1 -0
  201. package/dist/esm/animation/animationHelper.js +268 -0
  202. package/dist/esm/animation/animationHelper.js.map +1 -0
  203. package/dist/esm/animation/characterTypes.js +70 -0
  204. package/dist/esm/animation/characterTypes.js.map +1 -0
  205. package/dist/esm/animation/choreoDSL.js +182 -0
  206. package/dist/esm/animation/choreoDSL.js.map +1 -0
  207. package/dist/esm/animation/choreography.js +36 -0
  208. package/dist/esm/animation/choreography.js.map +1 -0
  209. package/dist/esm/animation/karaokeIntegration.js +91 -0
  210. package/dist/esm/animation/karaokeIntegration.js.map +1 -0
  211. package/dist/esm/animation/lottieExport.js +123 -0
  212. package/dist/esm/animation/lottieExport.js.map +1 -0
  213. package/dist/esm/animation/motionPath.js +185 -0
  214. package/dist/esm/animation/motionPath.js.map +1 -0
  215. package/dist/esm/animation/physics.js +192 -0
  216. package/dist/esm/animation/physics.js.map +1 -0
  217. package/dist/esm/animation/rig/RigPlayer.js +61 -0
  218. package/dist/esm/animation/rig/RigPlayer.js.map +1 -0
  219. package/dist/esm/animation/rig/RiggedBody.js +28 -0
  220. package/dist/esm/animation/rig/RiggedBody.js.map +1 -0
  221. package/dist/esm/animation/rig/choreoRigBridge.js +60 -0
  222. package/dist/esm/animation/rig/choreoRigBridge.js.map +1 -0
  223. package/dist/esm/animation/rig/ik.js +20 -0
  224. package/dist/esm/animation/rig/ik.js.map +1 -0
  225. package/dist/esm/animation/rig/poseOps.js +45 -0
  226. package/dist/esm/animation/rig/poseOps.js.map +1 -0
  227. package/dist/esm/animation/rig/presets.js +53 -0
  228. package/dist/esm/animation/rig/presets.js.map +1 -0
  229. package/dist/esm/animation/rig/rigMath.js +37 -0
  230. package/dist/esm/animation/rig/rigMath.js.map +1 -0
  231. package/dist/esm/animation/rig/rigTypes.js +40 -0
  232. package/dist/esm/animation/rig/rigTypes.js.map +1 -0
  233. package/dist/esm/animation/shapes/arms.js +13 -0
  234. package/dist/esm/animation/shapes/arms.js.map +1 -0
  235. package/dist/esm/animation/shapes/eyes.js +45 -0
  236. package/dist/esm/animation/shapes/eyes.js.map +1 -0
  237. package/dist/esm/animation/shapes/hair.js +46 -0
  238. package/dist/esm/animation/shapes/hair.js.map +1 -0
  239. package/dist/esm/animation/shapes/heads.js +52 -0
  240. package/dist/esm/animation/shapes/heads.js.map +1 -0
  241. package/dist/esm/animation/shapes/headwear.js +36 -0
  242. package/dist/esm/animation/shapes/headwear.js.map +1 -0
  243. package/dist/esm/animation/shapes/legs.js +13 -0
  244. package/dist/esm/animation/shapes/legs.js.map +1 -0
  245. package/dist/esm/animation/shapes/mouths.js +45 -0
  246. package/dist/esm/animation/shapes/mouths.js.map +1 -0
  247. package/dist/esm/animation/shapes/noses.js +23 -0
  248. package/dist/esm/animation/shapes/noses.js.map +1 -0
  249. package/dist/esm/animation/shapes/outfits.js +37 -0
  250. package/dist/esm/animation/shapes/outfits.js.map +1 -0
  251. package/dist/esm/animation/shapes/torsos.js +11 -0
  252. package/dist/esm/animation/shapes/torsos.js.map +1 -0
  253. package/dist/esm/animation/spineExport.js +128 -0
  254. package/dist/esm/animation/spineExport.js.map +1 -0
  255. package/dist/esm/core/LocalUI.js +50 -0
  256. package/dist/esm/core/LocalUI.js.map +1 -0
  257. package/dist/esm/core/collaboration.js +252 -0
  258. package/dist/esm/core/collaboration.js.map +1 -0
  259. package/dist/esm/core/colorBlindness.js +90 -0
  260. package/dist/esm/core/colorBlindness.js.map +1 -0
  261. package/dist/esm/core/dragDrop.js +165 -0
  262. package/dist/esm/core/dragDrop.js.map +1 -0
  263. package/dist/esm/core/fixes.js +179 -0
  264. package/dist/esm/core/fixes.js.map +1 -0
  265. package/dist/esm/core/gridGuides.js +232 -0
  266. package/dist/esm/core/gridGuides.js.map +1 -0
  267. package/dist/esm/core/historyVisual.js +121 -0
  268. package/dist/esm/core/historyVisual.js.map +1 -0
  269. package/dist/esm/core/i18n.js +13 -0
  270. package/dist/esm/core/i18n.js.map +1 -0
  271. package/dist/esm/core/integrations.js +254 -0
  272. package/dist/esm/core/integrations.js.map +1 -0
  273. package/dist/esm/core/minimap.js +139 -0
  274. package/dist/esm/core/minimap.js.map +1 -0
  275. package/dist/esm/core/plugins.js +124 -0
  276. package/dist/esm/core/plugins.js.map +1 -0
  277. package/dist/esm/core/rtl.js +95 -0
  278. package/dist/esm/core/rtl.js.map +1 -0
  279. package/dist/esm/core/shortcuts.js +200 -0
  280. package/dist/esm/core/shortcuts.js.map +1 -0
  281. package/dist/esm/core/theme.js +162 -0
  282. package/dist/esm/core/theme.js.map +1 -0
  283. package/dist/esm/font/NiceFontEditor.js +189 -0
  284. package/dist/esm/font/NiceFontEditor.js.map +1 -0
  285. package/dist/esm/game/GameAsset2dEditor.js +369 -0
  286. package/dist/esm/game/GameAsset2dEditor.js.map +1 -0
  287. package/dist/esm/game/GameAsset2dEditor.module.css.js +4 -0
  288. package/dist/esm/game/GameAsset2dEditor.module.css.js.map +1 -0
  289. package/dist/esm/game/gameAssetTypes.js +18 -0
  290. package/dist/esm/game/gameAssetTypes.js.map +1 -0
  291. package/dist/esm/game/gameAssetUtils.js +456 -0
  292. package/dist/esm/game/gameAssetUtils.js.map +1 -0
  293. package/dist/esm/game/useGameAssetEditor.js +759 -0
  294. package/dist/esm/game/useGameAssetEditor.js.map +1 -0
  295. package/dist/esm/icon/NiceIconEditor.js +246 -0
  296. package/dist/esm/icon/NiceIconEditor.js.map +1 -0
  297. package/dist/esm/index.js +59 -0
  298. package/dist/esm/index.js.map +1 -0
  299. package/dist/esm/nice2dev-ui/dist/index.js +31720 -0
  300. package/dist/esm/nice2dev-ui/dist/index.js.map +1 -0
  301. package/dist/esm/nice2dev-ui-graphics.css +1 -0
  302. package/dist/esm/photo/FilterThumb.js +27 -0
  303. package/dist/esm/photo/FilterThumb.js.map +1 -0
  304. package/dist/esm/photo/PhotoEditor.js +18 -0
  305. package/dist/esm/photo/PhotoEditor.js.map +1 -0
  306. package/dist/esm/photo/PhotoEditor.module.css.js +4 -0
  307. package/dist/esm/photo/PhotoEditor.module.css.js.map +1 -0
  308. package/dist/esm/photo/PhotoEditorCanvas.js +57 -0
  309. package/dist/esm/photo/PhotoEditorCanvas.js.map +1 -0
  310. package/dist/esm/photo/PhotoEditorLeftPanel.js +172 -0
  311. package/dist/esm/photo/PhotoEditorLeftPanel.js.map +1 -0
  312. package/dist/esm/photo/PhotoEditorToolbar.js +13 -0
  313. package/dist/esm/photo/PhotoEditorToolbar.js.map +1 -0
  314. package/dist/esm/photo/photoEditorActions.js +75 -0
  315. package/dist/esm/photo/photoEditorActions.js.map +1 -0
  316. package/dist/esm/photo/photoEditorTypes.js +36 -0
  317. package/dist/esm/photo/photoEditorTypes.js.map +1 -0
  318. package/dist/esm/photo/photoFilters.js +871 -0
  319. package/dist/esm/photo/photoFilters.js.map +1 -0
  320. package/dist/esm/photo/photoOverlays.js +636 -0
  321. package/dist/esm/photo/photoOverlays.js.map +1 -0
  322. package/dist/esm/photo/photoSelection.js +535 -0
  323. package/dist/esm/photo/photoSelection.js.map +1 -0
  324. package/dist/esm/photo/usePhotoEditor.js +638 -0
  325. package/dist/esm/photo/usePhotoEditor.js.map +1 -0
  326. package/dist/esm/pixel/HSVPicker.js +171 -0
  327. package/dist/esm/pixel/HSVPicker.js.map +1 -0
  328. package/dist/esm/pixel/PixelEditor.js +26 -0
  329. package/dist/esm/pixel/PixelEditor.js.map +1 -0
  330. package/dist/esm/pixel/PixelEditor.module.css.js +4 -0
  331. package/dist/esm/pixel/PixelEditor.module.css.js.map +1 -0
  332. package/dist/esm/pixel/PixelEditorCanvas.js +13 -0
  333. package/dist/esm/pixel/PixelEditorCanvas.js.map +1 -0
  334. package/dist/esm/pixel/PixelEditorMenuBar.js +9 -0
  335. package/dist/esm/pixel/PixelEditorMenuBar.js.map +1 -0
  336. package/dist/esm/pixel/PixelEditorRightPanel.js +13 -0
  337. package/dist/esm/pixel/PixelEditorRightPanel.js.map +1 -0
  338. package/dist/esm/pixel/PixelEditorStatusBar.js +13 -0
  339. package/dist/esm/pixel/PixelEditorStatusBar.js.map +1 -0
  340. package/dist/esm/pixel/PixelEditorTimeline.js +9 -0
  341. package/dist/esm/pixel/PixelEditorTimeline.js.map +1 -0
  342. package/dist/esm/pixel/PixelEditorToolbar.js +14 -0
  343. package/dist/esm/pixel/PixelEditorToolbar.js.map +1 -0
  344. package/dist/esm/pixel/asepriteFormat.js +505 -0
  345. package/dist/esm/pixel/asepriteFormat.js.map +1 -0
  346. package/dist/esm/pixel/pixelEditorExports.js +461 -0
  347. package/dist/esm/pixel/pixelEditorExports.js.map +1 -0
  348. package/dist/esm/pixel/pixelEditorTypes.js +90 -0
  349. package/dist/esm/pixel/pixelEditorTypes.js.map +1 -0
  350. package/dist/esm/pixel/pixelEditorUtils.js +631 -0
  351. package/dist/esm/pixel/pixelEditorUtils.js.map +1 -0
  352. package/dist/esm/pixel/usePixelEditor.js +1110 -0
  353. package/dist/esm/pixel/usePixelEditor.js.map +1 -0
  354. package/dist/esm/texture/Nice3DTexturePainter.js +233 -0
  355. package/dist/esm/texture/Nice3DTexturePainter.js.map +1 -0
  356. package/dist/esm/ui/NiceUIDesigner.js +187 -0
  357. package/dist/esm/ui/NiceUIDesigner.js.map +1 -0
  358. package/dist/esm/vector/VectorEditor.js +29 -0
  359. package/dist/esm/vector/VectorEditor.js.map +1 -0
  360. package/dist/esm/vector/VectorEditor.module.css.js +4 -0
  361. package/dist/esm/vector/VectorEditor.module.css.js.map +1 -0
  362. package/dist/esm/vector/VectorEditorMenuBar.js +14 -0
  363. package/dist/esm/vector/VectorEditorMenuBar.js.map +1 -0
  364. package/dist/esm/vector/VectorEditorRightPanel.js +124 -0
  365. package/dist/esm/vector/VectorEditorRightPanel.js.map +1 -0
  366. package/dist/esm/vector/VectorEditorShapeRenderer.js +53 -0
  367. package/dist/esm/vector/VectorEditorShapeRenderer.js.map +1 -0
  368. package/dist/esm/vector/VectorEditorStatusBar.js +12 -0
  369. package/dist/esm/vector/VectorEditorStatusBar.js.map +1 -0
  370. package/dist/esm/vector/useVectorEditor.js +611 -0
  371. package/dist/esm/vector/useVectorEditor.js.map +1 -0
  372. package/dist/esm/vector/vectorBooleanOps.js +507 -0
  373. package/dist/esm/vector/vectorBooleanOps.js.map +1 -0
  374. package/dist/esm/vector/vectorEditorExport.js +152 -0
  375. package/dist/esm/vector/vectorEditorExport.js.map +1 -0
  376. package/dist/esm/vector/vectorEditorImport.js +148 -0
  377. package/dist/esm/vector/vectorEditorImport.js.map +1 -0
  378. package/dist/esm/vector/vectorEditorTypes.js +63 -0
  379. package/dist/esm/vector/vectorEditorTypes.js.map +1 -0
  380. package/dist/esm/vector/vectorGradients.js +193 -0
  381. package/dist/esm/vector/vectorGradients.js.map +1 -0
  382. package/dist/types/__benchmarks__/bench.d.ts +13 -0
  383. package/dist/types/__tests__/setup.d.ts +4 -0
  384. package/dist/types/animation/AnimatedPerson.d.ts +14 -0
  385. package/dist/types/animation/AnimationEditor.d.ts +20 -0
  386. package/dist/types/animation/Audience.d.ts +11 -0
  387. package/dist/types/animation/BodyRenderer.d.ts +12 -0
  388. package/dist/types/animation/animationHelper.d.ts +28 -0
  389. package/dist/types/animation/characterTypes.d.ts +37 -0
  390. package/dist/types/animation/choreoDSL.d.ts +88 -0
  391. package/dist/types/animation/choreography.d.ts +8 -0
  392. package/dist/types/animation/karaokeIntegration.d.ts +31 -0
  393. package/dist/types/animation/lottieExport.d.ts +77 -0
  394. package/dist/types/animation/motionPath.d.ts +60 -0
  395. package/dist/types/animation/physics.d.ts +73 -0
  396. package/dist/types/animation/rig/RigPlayer.d.ts +32 -0
  397. package/dist/types/animation/rig/RiggedBody.d.ts +19 -0
  398. package/dist/types/animation/rig/choreoRigBridge.d.ts +9 -0
  399. package/dist/types/animation/rig/ik.d.ts +8 -0
  400. package/dist/types/animation/rig/poseOps.d.ts +14 -0
  401. package/dist/types/animation/rig/presets.d.ts +13 -0
  402. package/dist/types/animation/rig/rigMath.d.ts +7 -0
  403. package/dist/types/animation/rig/rigTypes.d.ts +38 -0
  404. package/dist/types/animation/shapes/arms.d.ts +10 -0
  405. package/dist/types/animation/shapes/eyes.d.ts +17 -0
  406. package/dist/types/animation/shapes/hair.d.ts +17 -0
  407. package/dist/types/animation/shapes/heads.d.ts +18 -0
  408. package/dist/types/animation/shapes/headwear.d.ts +16 -0
  409. package/dist/types/animation/shapes/legs.d.ts +10 -0
  410. package/dist/types/animation/shapes/mouths.d.ts +17 -0
  411. package/dist/types/animation/shapes/noses.d.ts +17 -0
  412. package/dist/types/animation/shapes/outfits.d.ts +14 -0
  413. package/dist/types/animation/shapes/torsos.d.ts +9 -0
  414. package/dist/types/animation/spineExport.d.ts +66 -0
  415. package/dist/types/core/LocalUI.d.ts +21 -0
  416. package/dist/types/core/collaboration.d.ts +164 -0
  417. package/dist/types/core/colorBlindness.d.ts +24 -0
  418. package/dist/types/core/dragDrop.d.ts +46 -0
  419. package/dist/types/core/fixes.d.ts +80 -0
  420. package/dist/types/core/gridGuides.d.ts +70 -0
  421. package/dist/types/core/historyVisual.d.ts +915 -0
  422. package/dist/types/core/i18n.d.ts +27 -0
  423. package/dist/types/core/integrations.d.ts +103 -0
  424. package/dist/types/core/minimap.d.ts +49 -0
  425. package/dist/types/core/plugins.d.ts +111 -0
  426. package/dist/types/core/rtl.d.ts +32 -0
  427. package/dist/types/core/shortcuts.d.ts +150 -0
  428. package/dist/types/core/theme.d.ts +78 -0
  429. package/dist/types/core/useGamepad.d.ts +64 -0
  430. package/dist/types/core/usePointerPressure.d.ts +88 -0
  431. package/dist/types/font/NiceFontEditor.d.ts +62 -0
  432. package/dist/types/game/AnimationPreviewPlayer.d.ts +29 -0
  433. package/dist/types/game/CollisionEditor.d.ts +101 -0
  434. package/dist/types/game/GameAsset2dEditor.d.ts +17 -0
  435. package/dist/types/game/GameAssetExportPanel.d.ts +20 -0
  436. package/dist/types/game/IsometricEditor.d.ts +22 -0
  437. package/dist/types/game/IsometricTilePanel.d.ts +18 -0
  438. package/dist/types/game/gameAssetExport.d.ts +160 -0
  439. package/dist/types/game/gameAssetTypes.d.ts +238 -0
  440. package/dist/types/game/gameAssetUtils.d.ts +23 -0
  441. package/dist/types/game/index.d.ts +8 -0
  442. package/dist/types/game/isometricTiles.d.ts +250 -0
  443. package/dist/types/game/useAnimationPreview.d.ts +63 -0
  444. package/dist/types/game/useCollisionEditor.d.ts +96 -0
  445. package/dist/types/game/useGameAssetEditor.d.ts +79 -0
  446. package/dist/types/game/useGameAssetExport.d.ts +82 -0
  447. package/dist/types/icon/NiceIconEditor.d.ts +79 -0
  448. package/dist/types/index.d.ts +85 -0
  449. package/dist/types/photo/BatchProcessingPanel.d.ts +13 -0
  450. package/dist/types/photo/FaceDetectionPanel.d.ts +18 -0
  451. package/dist/types/photo/FilterThumb.d.ts +14 -0
  452. package/dist/types/photo/PerspectiveCorrectionPanel.d.ts +17 -0
  453. package/dist/types/photo/PhotoEditor.d.ts +2 -0
  454. package/dist/types/photo/PhotoEditorCanvas.d.ts +14 -0
  455. package/dist/types/photo/PhotoEditorLeftPanel.d.ts +13 -0
  456. package/dist/types/photo/PhotoEditorToolbar.d.ts +13 -0
  457. package/dist/types/photo/RawFilePanel.d.ts +14 -0
  458. package/dist/types/photo/StyleTransferPanel.d.ts +15 -0
  459. package/dist/types/photo/aiStyleTransfer.d.ts +58 -0
  460. package/dist/types/photo/batchProcessing.d.ts +95 -0
  461. package/dist/types/photo/faceDetection.d.ts +103 -0
  462. package/dist/types/photo/index.d.ts +17 -0
  463. package/dist/types/photo/perspectiveCorrection.d.ts +134 -0
  464. package/dist/types/photo/photoEditorActions.d.ts +40 -0
  465. package/dist/types/photo/photoEditorTypes.d.ts +34 -0
  466. package/dist/types/photo/photoFilters.d.ts +55 -0
  467. package/dist/types/photo/photoOverlays.d.ts +126 -0
  468. package/dist/types/photo/photoSelection.d.ts +56 -0
  469. package/dist/types/photo/rawFileSupport.d.ts +124 -0
  470. package/dist/types/photo/usePhotoEditor.d.ts +123 -0
  471. package/dist/types/pixel/HSVPicker.d.ts +11 -0
  472. package/dist/types/pixel/PaletteExtractorPanel.d.ts +16 -0
  473. package/dist/types/pixel/PixelEditor.d.ts +17 -0
  474. package/dist/types/pixel/PixelEditorCanvas.d.ts +10 -0
  475. package/dist/types/pixel/PixelEditorMenuBar.d.ts +11 -0
  476. package/dist/types/pixel/PixelEditorRightPanel.d.ts +11 -0
  477. package/dist/types/pixel/PixelEditorStatusBar.d.ts +11 -0
  478. package/dist/types/pixel/PixelEditorTimeline.d.ts +11 -0
  479. package/dist/types/pixel/PixelEditorToolbar.d.ts +11 -0
  480. package/dist/types/pixel/TileMapPanel.d.ts +14 -0
  481. package/dist/types/pixel/asepriteFormat.d.ts +62 -0
  482. package/dist/types/pixel/paletteExtractor.d.ts +73 -0
  483. package/dist/types/pixel/pixelEditorExports.d.ts +31 -0
  484. package/dist/types/pixel/pixelEditorTypes.d.ts +51 -0
  485. package/dist/types/pixel/pixelEditorUtils.d.ts +136 -0
  486. package/dist/types/pixel/tileMapMode.d.ts +122 -0
  487. package/dist/types/pixel/usePixelEditor.d.ts +114 -0
  488. package/dist/types/texture/Nice3DTexturePainter.d.ts +55 -0
  489. package/dist/types/ui/NiceUIDesigner.d.ts +43 -0
  490. package/dist/types/vector/PathSimplificationPanel.d.ts +15 -0
  491. package/dist/types/vector/PdfExportPanel.d.ts +20 -0
  492. package/dist/types/vector/TextOnPathPanel.d.ts +26 -0
  493. package/dist/types/vector/VectorEditor.d.ts +32 -0
  494. package/dist/types/vector/VectorEditorMenuBar.d.ts +8 -0
  495. package/dist/types/vector/VectorEditorRightPanel.d.ts +7 -0
  496. package/dist/types/vector/VectorEditorShapeRenderer.d.ts +9 -0
  497. package/dist/types/vector/VectorEditorStatusBar.d.ts +9 -0
  498. package/dist/types/vector/VectorFilterPanel.d.ts +19 -0
  499. package/dist/types/vector/VectorPatternPanel.d.ts +21 -0
  500. package/dist/types/vector/pathSimplification.d.ts +135 -0
  501. package/dist/types/vector/pdfExport.d.ts +65 -0
  502. package/dist/types/vector/textOnPath.d.ts +145 -0
  503. package/dist/types/vector/useVectorEditor.d.ts +90 -0
  504. package/dist/types/vector/vectorBooleanOps.d.ts +22 -0
  505. package/dist/types/vector/vectorEditorExport.d.ts +8 -0
  506. package/dist/types/vector/vectorEditorImport.d.ts +7 -0
  507. package/dist/types/vector/vectorEditorTypes.d.ts +47 -0
  508. package/dist/types/vector/vectorGradients.d.ts +64 -0
  509. package/dist/types/vector/vectorPatternFills.d.ts +101 -0
  510. package/dist/types/vector/vectorSvgFilters.d.ts +134 -0
  511. package/package.json +93 -0
@@ -0,0 +1,664 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * pixelEditorUtils.ts — Drawing algorithms for the pixel editor.
5
+ * Bresenham line, midpoint ellipse, flood fill, selection, brush shapes,
6
+ * pressure-aware blending, dithering, gradient, symmetry etc.
7
+ */
8
+ const DEFAULT_BRUSH = {
9
+ size: 1,
10
+ shape: 'square',
11
+ opacity: 100,
12
+ flow: 100,
13
+ spacing: 25,
14
+ pressureSize: true,
15
+ pressureOpacity: false,
16
+ hardness: 100,
17
+ };
18
+ /** Read a pixel from ImageData at (x,y). Returns [r,g,b,a]. */
19
+ function getPixel(data, x, y) {
20
+ if (x < 0 || y < 0 || x >= data.width || y >= data.height)
21
+ return [0, 0, 0, 0];
22
+ const i = (y * data.width + x) * 4;
23
+ return [data.data[i], data.data[i + 1], data.data[i + 2], data.data[i + 3]];
24
+ }
25
+ /** Set a pixel in ImageData at (x,y). */
26
+ function setPixel(data, x, y, color) {
27
+ if (x < 0 || y < 0 || x >= data.width || y >= data.height)
28
+ return;
29
+ const i = (y * data.width + x) * 4;
30
+ data.data[i] = color[0];
31
+ data.data[i + 1] = color[1];
32
+ data.data[i + 2] = color[2];
33
+ data.data[i + 3] = color[3];
34
+ }
35
+ /** Blend a pixel onto ImageData at (x,y) with alpha compositing. */
36
+ function blendPixel(data, x, y, color, strength = 1) {
37
+ if (x < 0 || y < 0 || x >= data.width || y >= data.height)
38
+ return;
39
+ const i = (y * data.width + x) * 4;
40
+ const sa = (color[3] / 255) * strength;
41
+ if (sa <= 0)
42
+ return;
43
+ const da = data.data[i + 3] / 255;
44
+ const oa = sa + da * (1 - sa);
45
+ if (oa <= 0)
46
+ return;
47
+ data.data[i] = Math.round((color[0] * sa + data.data[i] * da * (1 - sa)) / oa);
48
+ data.data[i + 1] = Math.round((color[1] * sa + data.data[i + 1] * da * (1 - sa)) / oa);
49
+ data.data[i + 2] = Math.round((color[2] * sa + data.data[i + 2] * da * (1 - sa)) / oa);
50
+ data.data[i + 3] = Math.round(oa * 255);
51
+ }
52
+ /** Generate brush mask: returns array of {dx, dy, strength} offsets. */
53
+ function getBrushMask(cfg, pressure = 0.5) {
54
+ const sz = cfg.pressureSize ? Math.max(1, Math.round(cfg.size * pressure)) : cfg.size;
55
+ const half = Math.floor(sz / 2);
56
+ const flowMul = cfg.flow / 100;
57
+ const opaMul = (cfg.opacity / 100) * (cfg.pressureOpacity ? pressure : 1);
58
+ const mask = [];
59
+ for (let dy = -half; dy < sz - half; dy++) {
60
+ for (let dx = -half; dx < sz - half; dx++) {
61
+ let inBrush = false;
62
+ let dist = 0;
63
+ switch (cfg.shape) {
64
+ case 'square':
65
+ inBrush = true;
66
+ dist = Math.max(Math.abs(dx), Math.abs(dy)) / Math.max(half, 0.5);
67
+ break;
68
+ case 'circle': {
69
+ const r = Math.sqrt(dx * dx + dy * dy);
70
+ inBrush = r <= half + 0.5;
71
+ dist = half > 0 ? r / half : 0;
72
+ break;
73
+ }
74
+ case 'diamond':
75
+ inBrush = Math.abs(dx) + Math.abs(dy) <= half;
76
+ dist = half > 0 ? (Math.abs(dx) + Math.abs(dy)) / half : 0;
77
+ break;
78
+ case 'spray':
79
+ inBrush = Math.random() < 0.3 && Math.sqrt(dx * dx + dy * dy) <= half + 0.5;
80
+ dist = 0;
81
+ break;
82
+ }
83
+ if (!inBrush)
84
+ continue;
85
+ // hardness: 100 = hard edge, 0 = soft falloff
86
+ const hardFactor = cfg.hardness / 100;
87
+ const edge = dist > hardFactor ? Math.max(0, 1 - (dist - hardFactor) / (1 - hardFactor + 0.001)) : 1;
88
+ mask.push({ dx, dy, strength: edge * flowMul * opaMul });
89
+ }
90
+ }
91
+ return mask;
92
+ }
93
+ /** Apply brush stamp at (x,y) with all brush settings. */
94
+ function applyBrushStamp(data, x, y, color, cfg, pressure = 0.5, erase = false) {
95
+ const mask = getBrushMask(cfg, pressure);
96
+ for (const { dx, dy, strength } of mask) {
97
+ const gx = x + dx, gy = y + dy;
98
+ if (gx < 0 || gy < 0 || gx >= data.width || gy >= data.height)
99
+ continue;
100
+ if (erase) {
101
+ const cur = getPixel(data, gx, gy);
102
+ const newA = Math.max(0, cur[3] - Math.round(255 * strength));
103
+ setPixel(data, gx, gy, [cur[0], cur[1], cur[2], newA]);
104
+ }
105
+ else {
106
+ blendPixel(data, gx, gy, color, strength);
107
+ }
108
+ }
109
+ }
110
+ /** Get symmetry points for a coordinate. */
111
+ function getSymmetryPoints(x, y, w, h, mode) {
112
+ const pts = [{ x, y }];
113
+ switch (mode) {
114
+ case 'h':
115
+ pts.push({ x: w - 1 - x, y });
116
+ break;
117
+ case 'v':
118
+ pts.push({ x, y: h - 1 - y });
119
+ break;
120
+ case 'both':
121
+ pts.push({ x: w - 1 - x, y }, { x, y: h - 1 - y }, { x: w - 1 - x, y: h - 1 - y });
122
+ break;
123
+ case 'radial4': {
124
+ const cx = w / 2, cy = h / 2;
125
+ const dx = x - cx, dy = y - cy;
126
+ pts.push({ x: Math.round(cx - dy), y: Math.round(cy + dx) }, { x: Math.round(cx - dx), y: Math.round(cy - dy) }, { x: Math.round(cx + dy), y: Math.round(cy - dx) });
127
+ break;
128
+ }
129
+ }
130
+ return pts;
131
+ }
132
+ /** Draw a linear gradient between two points on ImageData. */
133
+ function drawGradient(data, x0, y0, x1, y1, color1, color2, sel) {
134
+ var _a, _b, _c, _d;
135
+ const dx = x1 - x0, dy = y1 - y0;
136
+ const len = Math.sqrt(dx * dx + dy * dy);
137
+ if (len === 0)
138
+ return;
139
+ const sx = (_a = sel === null || sel === void 0 ? void 0 : sel.x) !== null && _a !== void 0 ? _a : 0, sy = (_b = sel === null || sel === void 0 ? void 0 : sel.y) !== null && _b !== void 0 ? _b : 0;
140
+ const sw = (_c = sel === null || sel === void 0 ? void 0 : sel.w) !== null && _c !== void 0 ? _c : data.width, sh = (_d = sel === null || sel === void 0 ? void 0 : sel.h) !== null && _d !== void 0 ? _d : data.height;
141
+ for (let py = sy; py < sy + sh; py++) {
142
+ for (let px = sx; px < sx + sw; px++) {
143
+ const t = Math.max(0, Math.min(1, ((px - x0) * dx + (py - y0) * dy) / (len * len)));
144
+ const c = [
145
+ Math.round(color1[0] + (color2[0] - color1[0]) * t),
146
+ Math.round(color1[1] + (color2[1] - color1[1]) * t),
147
+ Math.round(color1[2] + (color2[2] - color1[2]) * t),
148
+ Math.round(color1[3] + (color2[3] - color1[3]) * t),
149
+ ];
150
+ setPixel(data, px, py, c);
151
+ }
152
+ }
153
+ }
154
+ /** Ordered dithering 4x4 Bayer matrix. */
155
+ const BAYER4 = [
156
+ [0, 8, 2, 10],
157
+ [12, 4, 14, 6],
158
+ [3, 11, 1, 9],
159
+ [15, 7, 13, 5],
160
+ ];
161
+ /** Apply dithered brush stamp. */
162
+ function applyDitherStamp(data, x, y, color, size, pressure = 0.5) {
163
+ const half = Math.floor(size / 2);
164
+ const threshold = pressure * 16;
165
+ for (let dy = -half; dy < size - half; dy++) {
166
+ for (let dx = -half; dx < size - half; dx++) {
167
+ const gx = x + dx, gy = y + dy;
168
+ if (gx < 0 || gy < 0 || gx >= data.width || gy >= data.height)
169
+ continue;
170
+ const bayer = BAYER4[((gy % 4) + 4) % 4][((gx % 4) + 4) % 4];
171
+ if (bayer < threshold) {
172
+ setPixel(data, gx, gy, color);
173
+ }
174
+ }
175
+ }
176
+ }
177
+ /** Copy pixels from a selection region. */
178
+ function copySelection(data, sel) {
179
+ const out = new ImageData(sel.w, sel.h);
180
+ for (let y = 0; y < sel.h; y++) {
181
+ for (let x = 0; x < sel.w; x++) {
182
+ const px = getPixel(data, sel.x + x, sel.y + y);
183
+ setPixel(out, x, y, px);
184
+ }
185
+ }
186
+ return out;
187
+ }
188
+ /** Paste ImageData at position. */
189
+ function pasteAt(dst, src, ox, oy) {
190
+ for (let y = 0; y < src.height; y++) {
191
+ for (let x = 0; x < src.width; x++) {
192
+ const px = getPixel(src, x, y);
193
+ if (px[3] > 0)
194
+ blendPixel(dst, ox + x, oy + y, px, 1);
195
+ }
196
+ }
197
+ }
198
+ /** Clear pixels in selection region. */
199
+ function clearSelection(data, sel) {
200
+ for (let y = sel.y; y < sel.y + sel.h; y++) {
201
+ for (let x = sel.x; x < sel.x + sel.w; x++) {
202
+ setPixel(data, x, y, [0, 0, 0, 0]);
203
+ }
204
+ }
205
+ }
206
+ /** Bresenham line — calls callback for each pixel along the line. */
207
+ function bresenhamLine(x0, y0, x1, y1, cb) {
208
+ const dx = Math.abs(x1 - x0), dy = -Math.abs(y1 - y0);
209
+ const sx = x0 < x1 ? 1 : -1, sy = y0 < y1 ? 1 : -1;
210
+ let err = dx + dy;
211
+ for (;;) {
212
+ cb(x0, y0);
213
+ if (x0 === x1 && y0 === y1)
214
+ break;
215
+ const e2 = 2 * err;
216
+ if (e2 >= dy) {
217
+ err += dy;
218
+ x0 += sx;
219
+ }
220
+ if (e2 <= dx) {
221
+ err += dx;
222
+ y0 += sy;
223
+ }
224
+ }
225
+ }
226
+ /** Flood fill — fills connected region of same color with new color. */
227
+ function floodFill(data, startX, startY, fillColor) {
228
+ const w = data.width, h = data.height;
229
+ if (startX < 0 || startY < 0 || startX >= w || startY >= h)
230
+ return;
231
+ const target = getPixel(data, startX, startY);
232
+ if (colorsEqual(target, fillColor))
233
+ return;
234
+ const stack = [startX, startY];
235
+ const visited = new Uint8Array(w * h);
236
+ while (stack.length > 0) {
237
+ const y = stack.pop();
238
+ const x = stack.pop();
239
+ const key = y * w + x;
240
+ if (x < 0 || y < 0 || x >= w || y >= h)
241
+ continue;
242
+ if (visited[key])
243
+ continue;
244
+ visited[key] = 1;
245
+ const current = getPixel(data, x, y);
246
+ if (!colorsEqual(current, target))
247
+ continue;
248
+ setPixel(data, x, y, fillColor);
249
+ stack.push(x - 1, y, x + 1, y, x, y - 1, x, y + 1);
250
+ }
251
+ }
252
+ /** Check if two RGBA colors are equal (with small tolerance for alpha). */
253
+ function colorsEqual(a, b, tolerance = 0) {
254
+ return Math.abs(a[0] - b[0]) <= tolerance &&
255
+ Math.abs(a[1] - b[1]) <= tolerance &&
256
+ Math.abs(a[2] - b[2]) <= tolerance &&
257
+ Math.abs(a[3] - b[3]) <= tolerance;
258
+ }
259
+ /** Parse hex color string to RGBA. */
260
+ function hexToRGBA(hex, alpha = 255) {
261
+ const h = hex.startsWith('#') ? hex.slice(1) : hex;
262
+ return [
263
+ parseInt(h.slice(0, 2), 16) || 0,
264
+ parseInt(h.slice(2, 4), 16) || 0,
265
+ parseInt(h.slice(4, 6), 16) || 0,
266
+ alpha,
267
+ ];
268
+ }
269
+ /** Convert RGBA to hex string. */
270
+ function rgbaToHex(c) {
271
+ return '#' + [c[0], c[1], c[2]].map(v => v.toString(16).padStart(2, '0')).join('');
272
+ }
273
+ /** Create blank ImageData. */
274
+ function createBlankImageData(width, height) {
275
+ return new ImageData(width, height);
276
+ }
277
+ /** Clone ImageData. */
278
+ function cloneImageData(src) {
279
+ const dst = new ImageData(src.width, src.height);
280
+ dst.data.set(src.data);
281
+ return dst;
282
+ }
283
+ /** Flip ImageData horizontally. */
284
+ function flipH(src) {
285
+ const dst = new ImageData(src.width, src.height);
286
+ for (let y = 0; y < src.height; y++)
287
+ for (let x = 0; x < src.width; x++) {
288
+ const si = (y * src.width + x) * 4;
289
+ const di = (y * src.width + (src.width - 1 - x)) * 4;
290
+ dst.data[di] = src.data[si];
291
+ dst.data[di + 1] = src.data[si + 1];
292
+ dst.data[di + 2] = src.data[si + 2];
293
+ dst.data[di + 3] = src.data[si + 3];
294
+ }
295
+ return dst;
296
+ }
297
+ /** Flip ImageData vertically. */
298
+ function flipV(src) {
299
+ const dst = new ImageData(src.width, src.height);
300
+ for (let y = 0; y < src.height; y++)
301
+ for (let x = 0; x < src.width; x++) {
302
+ const si = (y * src.width + x) * 4;
303
+ const di = ((src.height - 1 - y) * src.width + x) * 4;
304
+ dst.data[di] = src.data[si];
305
+ dst.data[di + 1] = src.data[si + 1];
306
+ dst.data[di + 2] = src.data[si + 2];
307
+ dst.data[di + 3] = src.data[si + 3];
308
+ }
309
+ return dst;
310
+ }
311
+ /** Rotate ImageData 90° clockwise. Returns new ImageData with swapped dimensions. */
312
+ function rotateCW(src) {
313
+ const dst = new ImageData(src.height, src.width);
314
+ for (let y = 0; y < src.height; y++)
315
+ for (let x = 0; x < src.width; x++) {
316
+ const si = (y * src.width + x) * 4;
317
+ const di = (x * dst.width + (dst.width - 1 - y)) * 4;
318
+ dst.data[di] = src.data[si];
319
+ dst.data[di + 1] = src.data[si + 1];
320
+ dst.data[di + 2] = src.data[si + 2];
321
+ dst.data[di + 3] = src.data[si + 3];
322
+ }
323
+ return dst;
324
+ }
325
+ // Bayer matrices for ordered dithering
326
+ const BAYER_2x2 = [
327
+ [0, 2],
328
+ [3, 1],
329
+ ];
330
+ const BAYER_8x8 = [
331
+ [0, 32, 8, 40, 2, 34, 10, 42],
332
+ [48, 16, 56, 24, 50, 18, 58, 26],
333
+ [12, 44, 4, 36, 14, 46, 6, 38],
334
+ [60, 28, 52, 20, 62, 30, 54, 22],
335
+ [3, 35, 11, 43, 1, 33, 9, 41],
336
+ [51, 19, 59, 27, 49, 17, 57, 25],
337
+ [15, 47, 7, 39, 13, 45, 5, 37],
338
+ [63, 31, 55, 23, 61, 29, 53, 21],
339
+ ];
340
+ /** Find closest color in palette */
341
+ function findClosestPaletteColor(r, g, b, palette) {
342
+ let minDist = Infinity;
343
+ let closest = palette[0];
344
+ for (const color of palette) {
345
+ const dr = r - color[0];
346
+ const dg = g - color[1];
347
+ const db = b - color[2];
348
+ const dist = dr * dr + dg * dg + db * db;
349
+ if (dist < minDist) {
350
+ minDist = dist;
351
+ closest = color;
352
+ }
353
+ }
354
+ return closest;
355
+ }
356
+ /** Apply ordered dithering with Bayer matrix */
357
+ function ditherOrdered(data, palette, matrix = BAYER4, strength = 1.0) {
358
+ const result = cloneImageData(data);
359
+ const matrixSize = matrix.length;
360
+ const maxMatrixValue = matrixSize * matrixSize;
361
+ for (let y = 0; y < data.height; y++) {
362
+ for (let x = 0; x < data.width; x++) {
363
+ const i = (y * data.width + x) * 4;
364
+ const a = data.data[i + 3];
365
+ if (a < 128)
366
+ continue; // Skip transparent pixels
367
+ const threshold = (matrix[y % matrixSize][x % matrixSize] / maxMatrixValue - 0.5) * strength * 64;
368
+ const r = Math.max(0, Math.min(255, data.data[i] + threshold));
369
+ const g = Math.max(0, Math.min(255, data.data[i + 1] + threshold));
370
+ const b = Math.max(0, Math.min(255, data.data[i + 2] + threshold));
371
+ const closest = findClosestPaletteColor(r, g, b, palette);
372
+ result.data[i] = closest[0];
373
+ result.data[i + 1] = closest[1];
374
+ result.data[i + 2] = closest[2];
375
+ }
376
+ }
377
+ return result;
378
+ }
379
+ /** Floyd-Steinberg error diffusion dithering */
380
+ function ditherFloydSteinberg(data, palette) {
381
+ const result = cloneImageData(data);
382
+ const errors = new Float32Array(data.width * data.height * 3);
383
+ for (let y = 0; y < data.height; y++) {
384
+ for (let x = 0; x < data.width; x++) {
385
+ const idx = (y * data.width + x);
386
+ const i = idx * 4;
387
+ const ei = idx * 3;
388
+ if (data.data[i + 3] < 128)
389
+ continue;
390
+ const oldR = Math.max(0, Math.min(255, data.data[i] + errors[ei]));
391
+ const oldG = Math.max(0, Math.min(255, data.data[i + 1] + errors[ei + 1]));
392
+ const oldB = Math.max(0, Math.min(255, data.data[i + 2] + errors[ei + 2]));
393
+ const newColor = findClosestPaletteColor(oldR, oldG, oldB, palette);
394
+ result.data[i] = newColor[0];
395
+ result.data[i + 1] = newColor[1];
396
+ result.data[i + 2] = newColor[2];
397
+ const errR = oldR - newColor[0];
398
+ const errG = oldG - newColor[1];
399
+ const errB = oldB - newColor[2];
400
+ // Distribute error: [7/16, 3/16, 5/16, 1/16]
401
+ const distribute = (dx, dy, factor) => {
402
+ const nx = x + dx, ny = y + dy;
403
+ if (nx >= 0 && nx < data.width && ny >= 0 && ny < data.height) {
404
+ const ni = (ny * data.width + nx) * 3;
405
+ errors[ni] += errR * factor;
406
+ errors[ni + 1] += errG * factor;
407
+ errors[ni + 2] += errB * factor;
408
+ }
409
+ };
410
+ distribute(1, 0, 7 / 16);
411
+ distribute(-1, 1, 3 / 16);
412
+ distribute(0, 1, 5 / 16);
413
+ distribute(1, 1, 1 / 16);
414
+ }
415
+ }
416
+ return result;
417
+ }
418
+ /** Jarvis-Judice-Ninke dithering (larger error diffusion kernel) */
419
+ function ditherJarvisJudiceNinke(data, palette) {
420
+ const result = cloneImageData(data);
421
+ const errors = new Float32Array(data.width * data.height * 3);
422
+ for (let y = 0; y < data.height; y++) {
423
+ for (let x = 0; x < data.width; x++) {
424
+ const idx = (y * data.width + x);
425
+ const i = idx * 4;
426
+ const ei = idx * 3;
427
+ if (data.data[i + 3] < 128)
428
+ continue;
429
+ const oldR = Math.max(0, Math.min(255, data.data[i] + errors[ei]));
430
+ const oldG = Math.max(0, Math.min(255, data.data[i + 1] + errors[ei + 1]));
431
+ const oldB = Math.max(0, Math.min(255, data.data[i + 2] + errors[ei + 2]));
432
+ const newColor = findClosestPaletteColor(oldR, oldG, oldB, palette);
433
+ result.data[i] = newColor[0];
434
+ result.data[i + 1] = newColor[1];
435
+ result.data[i + 2] = newColor[2];
436
+ const errR = oldR - newColor[0];
437
+ const errG = oldG - newColor[1];
438
+ const errB = oldB - newColor[2];
439
+ const distribute = (dx, dy, factor) => {
440
+ const nx = x + dx, ny = y + dy;
441
+ if (nx >= 0 && nx < data.width && ny >= 0 && ny < data.height) {
442
+ const ni = (ny * data.width + nx) * 3;
443
+ errors[ni] += errR * factor;
444
+ errors[ni + 1] += errG * factor;
445
+ errors[ni + 2] += errB * factor;
446
+ }
447
+ };
448
+ // JJN kernel: /48
449
+ distribute(1, 0, 7 / 48);
450
+ distribute(2, 0, 5 / 48);
451
+ distribute(-2, 1, 3 / 48);
452
+ distribute(-1, 1, 5 / 48);
453
+ distribute(0, 1, 7 / 48);
454
+ distribute(1, 1, 5 / 48);
455
+ distribute(2, 1, 3 / 48);
456
+ distribute(-2, 2, 1 / 48);
457
+ distribute(-1, 2, 3 / 48);
458
+ distribute(0, 2, 5 / 48);
459
+ distribute(1, 2, 3 / 48);
460
+ distribute(2, 2, 1 / 48);
461
+ }
462
+ }
463
+ return result;
464
+ }
465
+ /** Atkinson dithering (preserves details better) */
466
+ function ditherAtkinson(data, palette) {
467
+ const result = cloneImageData(data);
468
+ const errors = new Float32Array(data.width * data.height * 3);
469
+ for (let y = 0; y < data.height; y++) {
470
+ for (let x = 0; x < data.width; x++) {
471
+ const idx = (y * data.width + x);
472
+ const i = idx * 4;
473
+ const ei = idx * 3;
474
+ if (data.data[i + 3] < 128)
475
+ continue;
476
+ const oldR = Math.max(0, Math.min(255, data.data[i] + errors[ei]));
477
+ const oldG = Math.max(0, Math.min(255, data.data[i + 1] + errors[ei + 1]));
478
+ const oldB = Math.max(0, Math.min(255, data.data[i + 2] + errors[ei + 2]));
479
+ const newColor = findClosestPaletteColor(oldR, oldG, oldB, palette);
480
+ result.data[i] = newColor[0];
481
+ result.data[i + 1] = newColor[1];
482
+ result.data[i + 2] = newColor[2];
483
+ // Atkinson only diffuses 6/8 = 3/4 of error
484
+ const errR = (oldR - newColor[0]) / 8;
485
+ const errG = (oldG - newColor[1]) / 8;
486
+ const errB = (oldB - newColor[2]) / 8;
487
+ const distribute = (dx, dy) => {
488
+ const nx = x + dx, ny = y + dy;
489
+ if (nx >= 0 && nx < data.width && ny >= 0 && ny < data.height) {
490
+ const ni = (ny * data.width + nx) * 3;
491
+ errors[ni] += errR;
492
+ errors[ni + 1] += errG;
493
+ errors[ni + 2] += errB;
494
+ }
495
+ };
496
+ distribute(1, 0);
497
+ distribute(2, 0);
498
+ distribute(-1, 1);
499
+ distribute(0, 1);
500
+ distribute(1, 1);
501
+ distribute(0, 2);
502
+ }
503
+ }
504
+ return result;
505
+ }
506
+ /** Random dithering */
507
+ function ditherRandom(data, palette, strength = 32) {
508
+ const result = cloneImageData(data);
509
+ for (let y = 0; y < data.height; y++) {
510
+ for (let x = 0; x < data.width; x++) {
511
+ const i = (y * data.width + x) * 4;
512
+ if (data.data[i + 3] < 128)
513
+ continue;
514
+ const noise = (Math.random() - 0.5) * strength * 2;
515
+ const r = Math.max(0, Math.min(255, data.data[i] + noise));
516
+ const g = Math.max(0, Math.min(255, data.data[i + 1] + noise));
517
+ const b = Math.max(0, Math.min(255, data.data[i + 2] + noise));
518
+ const closest = findClosestPaletteColor(r, g, b, palette);
519
+ result.data[i] = closest[0];
520
+ result.data[i + 1] = closest[1];
521
+ result.data[i + 2] = closest[2];
522
+ }
523
+ }
524
+ return result;
525
+ }
526
+ /** Apply dithering with specified algorithm */
527
+ function applyDithering(data, palette, algorithm) {
528
+ switch (algorithm) {
529
+ case 'none':
530
+ // Just quantize without dithering
531
+ return ditherOrdered(data, palette, [[0]], 0);
532
+ case 'ordered-2x2':
533
+ return ditherOrdered(data, palette, BAYER_2x2);
534
+ case 'ordered-4x4':
535
+ return ditherOrdered(data, palette, BAYER4);
536
+ case 'ordered-8x8':
537
+ return ditherOrdered(data, palette, BAYER_8x8);
538
+ case 'floyd-steinberg':
539
+ return ditherFloydSteinberg(data, palette);
540
+ case 'jarvis-judice-ninke':
541
+ return ditherJarvisJudiceNinke(data, palette);
542
+ case 'atkinson':
543
+ return ditherAtkinson(data, palette);
544
+ case 'random':
545
+ return ditherRandom(data, palette);
546
+ default:
547
+ return ditherFloydSteinberg(data, palette);
548
+ }
549
+ }
550
+ /** Generate palette from image using median cut algorithm */
551
+ function extractPalette(data, maxColors) {
552
+ const colors = [];
553
+ // Collect all non-transparent pixels
554
+ for (let i = 0; i < data.data.length; i += 4) {
555
+ if (data.data[i + 3] >= 128) {
556
+ colors.push([data.data[i], data.data[i + 1], data.data[i + 2]]);
557
+ }
558
+ }
559
+ if (colors.length === 0)
560
+ return [[0, 0, 0, 255]];
561
+ // Simple median cut
562
+ function medianCut(colors, depth) {
563
+ if (depth === 0 || colors.length <= 1) {
564
+ // Return average color
565
+ const r = Math.round(colors.reduce((s, c) => s + c[0], 0) / colors.length);
566
+ const g = Math.round(colors.reduce((s, c) => s + c[1], 0) / colors.length);
567
+ const b = Math.round(colors.reduce((s, c) => s + c[2], 0) / colors.length);
568
+ return [[r, g, b]];
569
+ }
570
+ // Find channel with largest range
571
+ const ranges = [0, 1, 2].map(ch => {
572
+ const vals = colors.map(c => c[ch]);
573
+ return Math.max(...vals) - Math.min(...vals);
574
+ });
575
+ const channel = ranges.indexOf(Math.max(...ranges));
576
+ // Sort by channel and split
577
+ colors.sort((a, b) => a[channel] - b[channel]);
578
+ const mid = Math.floor(colors.length / 2);
579
+ return [
580
+ ...medianCut(colors.slice(0, mid), depth - 1),
581
+ ...medianCut(colors.slice(mid), depth - 1),
582
+ ];
583
+ }
584
+ const depth = Math.ceil(Math.log2(maxColors));
585
+ const palette = medianCut(colors, depth).slice(0, maxColors);
586
+ return palette.map(c => [c[0], c[1], c[2], 255]);
587
+ }
588
+ /** Convert hex palette to RGBA array */
589
+ function hexPaletteToRGBA(hexColors) {
590
+ return hexColors.map(hex => hexToRGBA(hex));
591
+ }
592
+ /** Create reference overlay from file */
593
+ async function createReferenceOverlay(file, targetWidth, targetHeight) {
594
+ return new Promise((resolve, reject) => {
595
+ const img = new Image();
596
+ img.onload = () => {
597
+ // Scale to fit within target dimensions
598
+ const scale = Math.min(targetWidth / img.width, targetHeight / img.height, 1 // Don't scale up
599
+ );
600
+ const canvas = document.createElement('canvas');
601
+ canvas.width = Math.round(img.width * scale);
602
+ canvas.height = Math.round(img.height * scale);
603
+ const ctx = canvas.getContext('2d');
604
+ ctx.imageSmoothingEnabled = false;
605
+ ctx.drawImage(img, 0, 0, canvas.width, canvas.height);
606
+ resolve({
607
+ image: ctx.getImageData(0, 0, canvas.width, canvas.height),
608
+ x: 0,
609
+ y: 0,
610
+ opacity: 0.4,
611
+ scale: 1,
612
+ locked: false,
613
+ });
614
+ };
615
+ img.onerror = reject;
616
+ img.src = URL.createObjectURL(file);
617
+ });
618
+ }
619
+ /** Render reference overlay onto canvas */
620
+ function renderReferenceOverlay(ctx, ref, zoom, panX, panY) {
621
+ ctx.save();
622
+ ctx.globalAlpha = ref.opacity;
623
+ const tempCanvas = document.createElement('canvas');
624
+ tempCanvas.width = ref.image.width;
625
+ tempCanvas.height = ref.image.height;
626
+ tempCanvas.getContext('2d').putImageData(ref.image, 0, 0);
627
+ ctx.imageSmoothingEnabled = false;
628
+ ctx.drawImage(tempCanvas, (ref.x + panX) * zoom, (ref.y + panY) * zoom, ref.image.width * ref.scale * zoom, ref.image.height * ref.scale * zoom);
629
+ ctx.restore();
630
+ }
631
+
632
+ exports.DEFAULT_BRUSH = DEFAULT_BRUSH;
633
+ exports.applyBrushStamp = applyBrushStamp;
634
+ exports.applyDitherStamp = applyDitherStamp;
635
+ exports.applyDithering = applyDithering;
636
+ exports.blendPixel = blendPixel;
637
+ exports.bresenhamLine = bresenhamLine;
638
+ exports.clearSelection = clearSelection;
639
+ exports.cloneImageData = cloneImageData;
640
+ exports.colorsEqual = colorsEqual;
641
+ exports.copySelection = copySelection;
642
+ exports.createBlankImageData = createBlankImageData;
643
+ exports.createReferenceOverlay = createReferenceOverlay;
644
+ exports.ditherAtkinson = ditherAtkinson;
645
+ exports.ditherFloydSteinberg = ditherFloydSteinberg;
646
+ exports.ditherJarvisJudiceNinke = ditherJarvisJudiceNinke;
647
+ exports.ditherOrdered = ditherOrdered;
648
+ exports.ditherRandom = ditherRandom;
649
+ exports.drawGradient = drawGradient;
650
+ exports.extractPalette = extractPalette;
651
+ exports.flipH = flipH;
652
+ exports.flipV = flipV;
653
+ exports.floodFill = floodFill;
654
+ exports.getBrushMask = getBrushMask;
655
+ exports.getPixel = getPixel;
656
+ exports.getSymmetryPoints = getSymmetryPoints;
657
+ exports.hexPaletteToRGBA = hexPaletteToRGBA;
658
+ exports.hexToRGBA = hexToRGBA;
659
+ exports.pasteAt = pasteAt;
660
+ exports.renderReferenceOverlay = renderReferenceOverlay;
661
+ exports.rgbaToHex = rgbaToHex;
662
+ exports.rotateCW = rotateCW;
663
+ exports.setPixel = setPixel;
664
+ //# sourceMappingURL=pixelEditorUtils.js.map