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