@nice2dev/ui-graphics 1.1.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/animation/AnimatedPerson.js +69 -63
- package/dist/cjs/animation/AnimatedPerson.js.map +1 -1
- package/dist/cjs/animation/AnimationEditor.js +27 -20
- package/dist/cjs/animation/AnimationEditor.js.map +1 -1
- package/dist/cjs/animation/Audience.js +17 -11
- package/dist/cjs/animation/Audience.js.map +1 -1
- package/dist/cjs/animation/BodyRenderer.js +7 -7
- package/dist/cjs/animation/BodyRenderer.js.map +1 -1
- package/dist/cjs/animation/animationHelper.js +83 -52
- package/dist/cjs/animation/animationHelper.js.map +1 -1
- package/dist/cjs/animation/characterTypes.js +171 -30
- package/dist/cjs/animation/characterTypes.js.map +1 -1
- package/dist/cjs/animation/choreoDSL.js +114 -62
- package/dist/cjs/animation/choreoDSL.js.map +1 -1
- package/dist/cjs/animation/karaokeIntegration.js +10 -11
- package/dist/cjs/animation/karaokeIntegration.js.map +1 -1
- package/dist/cjs/animation/lottieExport.js +15 -9
- package/dist/cjs/animation/lottieExport.js.map +1 -1
- package/dist/cjs/animation/motionPath.js +125 -30
- package/dist/cjs/animation/motionPath.js.map +1 -1
- package/dist/cjs/animation/physics.js +157 -57
- package/dist/cjs/animation/physics.js.map +1 -1
- package/dist/cjs/animation/rig/RigPlayer.js +7 -6
- package/dist/cjs/animation/rig/RigPlayer.js.map +1 -1
- package/dist/cjs/animation/rig/RiggedBody.js +7 -7
- package/dist/cjs/animation/rig/RiggedBody.js.map +1 -1
- package/dist/cjs/animation/rig/choreoRigBridge.js +52 -29
- package/dist/cjs/animation/rig/choreoRigBridge.js.map +1 -1
- package/dist/cjs/animation/rig/poseOps.js +6 -3
- package/dist/cjs/animation/rig/poseOps.js.map +1 -1
- package/dist/cjs/animation/shapes/arms.js +7 -6
- package/dist/cjs/animation/shapes/arms.js.map +1 -1
- package/dist/cjs/animation/shapes/eyes.js +31 -18
- package/dist/cjs/animation/shapes/eyes.js.map +1 -1
- package/dist/cjs/animation/shapes/hair.js +39 -23
- package/dist/cjs/animation/shapes/hair.js.map +1 -1
- package/dist/cjs/animation/shapes/heads.js +47 -29
- package/dist/cjs/animation/shapes/heads.js.map +1 -1
- package/dist/cjs/animation/shapes/headwear.js +26 -14
- package/dist/cjs/animation/shapes/headwear.js.map +1 -1
- package/dist/cjs/animation/shapes/legs.js +7 -6
- package/dist/cjs/animation/shapes/legs.js.map +1 -1
- package/dist/cjs/animation/shapes/mouths.js +28 -18
- package/dist/cjs/animation/shapes/mouths.js.map +1 -1
- package/dist/cjs/animation/shapes/noses.js +18 -9
- package/dist/cjs/animation/shapes/noses.js.map +1 -1
- package/dist/cjs/animation/shapes/outfits.js +25 -14
- package/dist/cjs/animation/shapes/outfits.js.map +1 -1
- package/dist/cjs/animation/shapes/torsos.js +5 -4
- package/dist/cjs/animation/shapes/torsos.js.map +1 -1
- package/dist/cjs/animation/spineExport.js +33 -26
- package/dist/cjs/animation/spineExport.js.map +1 -1
- package/dist/cjs/core/LocalUI.js +16 -16
- package/dist/cjs/core/LocalUI.js.map +1 -1
- package/dist/cjs/core/NiceBrushEngine.js +205 -69
- package/dist/cjs/core/NiceBrushEngine.js.map +1 -1
- package/dist/cjs/core/collaboration.js +35 -21
- package/dist/cjs/core/collaboration.js.map +1 -1
- package/dist/cjs/core/colorBlindness.js +64 -24
- package/dist/cjs/core/colorBlindness.js.map +1 -1
- package/dist/cjs/core/dragDrop.js +34 -26
- package/dist/cjs/core/dragDrop.js.map +1 -1
- package/dist/cjs/core/fixes.js +26 -14
- package/dist/cjs/core/fixes.js.map +1 -1
- package/dist/cjs/core/gridGuides.js +24 -16
- package/dist/cjs/core/gridGuides.js.map +1 -1
- package/dist/cjs/core/historyVisual.js +42 -23
- package/dist/cjs/core/historyVisual.js.map +1 -1
- package/dist/cjs/core/integrations.js +65 -48
- package/dist/cjs/core/integrations.js.map +1 -1
- package/dist/cjs/core/minimap.js +40 -24
- package/dist/cjs/core/minimap.js.map +1 -1
- package/dist/cjs/core/plugins.js +10 -6
- package/dist/cjs/core/plugins.js.map +1 -1
- package/dist/cjs/core/rtl.js +32 -27
- package/dist/cjs/core/rtl.js.map +1 -1
- package/dist/cjs/core/shortcuts.js +77 -39
- package/dist/cjs/core/shortcuts.js.map +1 -1
- package/dist/cjs/core/theme.js +68 -61
- package/dist/cjs/core/theme.js.map +1 -1
- package/dist/cjs/core/yjsCollaboration.js +61 -28
- package/dist/cjs/core/yjsCollaboration.js.map +1 -1
- package/dist/cjs/font/NiceFontEditor.js +160 -57
- package/dist/cjs/font/NiceFontEditor.js.map +1 -1
- package/dist/cjs/font/fontFormatUtils.js +37 -24
- package/dist/cjs/font/fontFormatUtils.js.map +1 -1
- package/dist/cjs/game/GameAsset2dEditor.js +73 -60
- package/dist/cjs/game/GameAsset2dEditor.js.map +1 -1
- package/dist/cjs/game/gameAssetUtils.js +18 -13
- package/dist/cjs/game/gameAssetUtils.js.map +1 -1
- package/dist/cjs/game/useGameAssetEditor.js +160 -143
- package/dist/cjs/game/useGameAssetEditor.js.map +1 -1
- package/dist/cjs/icon/NiceIconEditor.js +329 -106
- package/dist/cjs/icon/NiceIconEditor.js.map +1 -1
- package/dist/cjs/packages/ui/dist/NiceErrorBoundary-D75yr_WE.js +572 -0
- package/dist/cjs/packages/ui/dist/NiceErrorBoundary-D75yr_WE.js.map +1 -0
- package/dist/cjs/packages/ui/dist/NiceForm-CKoJA6NG.js +4979 -0
- package/dist/cjs/packages/ui/dist/NiceForm-CKoJA6NG.js.map +1 -0
- package/dist/cjs/packages/ui/dist/NiceModal-1QX7NhyH.js +98 -0
- package/dist/cjs/packages/ui/dist/NiceModal-1QX7NhyH.js.map +1 -0
- package/dist/cjs/packages/ui/dist/NiceModuleLifecyclePanel-CMrPbSw9.js +5244 -0
- package/dist/cjs/packages/ui/dist/NiceModuleLifecyclePanel-CMrPbSw9.js.map +1 -0
- package/dist/cjs/packages/ui/dist/NicePagination-DbE-uOkl.js +174 -0
- package/dist/cjs/packages/ui/dist/NicePagination-DbE-uOkl.js.map +1 -0
- package/dist/cjs/packages/ui/dist/NicePinCodeInput-B8cI8zu8.js +10459 -0
- package/dist/cjs/packages/ui/dist/NicePinCodeInput-B8cI8zu8.js.map +1 -0
- package/dist/cjs/packages/ui/dist/NiceSavedQueryPanel-CZ5bYOe_.js +6313 -0
- package/dist/cjs/packages/ui/dist/NiceSavedQueryPanel-CZ5bYOe_.js.map +1 -0
- package/dist/cjs/packages/ui/dist/NiceTabs-DzLHzwuA.js +1639 -0
- package/dist/cjs/packages/ui/dist/NiceTabs-DzLHzwuA.js.map +1 -0
- package/dist/cjs/packages/ui/dist/NiceWindow-DeC83yfE.js +807 -0
- package/dist/cjs/packages/ui/dist/NiceWindow-DeC83yfE.js.map +1 -0
- package/dist/cjs/packages/ui/dist/charts-BAS21jkC.js +3833 -0
- package/dist/cjs/packages/ui/dist/charts-BAS21jkC.js.map +1 -0
- package/dist/cjs/packages/ui/dist/core-Da43q-pO.js +11683 -0
- package/dist/cjs/packages/ui/dist/core-Da43q-pO.js.map +1 -0
- package/dist/cjs/packages/ui/dist/index-pAuGTbuB.js +28876 -0
- package/dist/cjs/packages/ui/dist/index-pAuGTbuB.js.map +1 -0
- package/dist/cjs/photo/FilterThumb.js +7 -5
- package/dist/cjs/photo/FilterThumb.js.map +1 -1
- package/dist/cjs/photo/NiceAITools.js +78 -32
- package/dist/cjs/photo/NiceAITools.js.map +1 -1
- package/dist/cjs/photo/PhotoEditor.js +4 -4
- package/dist/cjs/photo/PhotoEditor.js.map +1 -1
- package/dist/cjs/photo/PhotoEditorCanvas.js +56 -22
- package/dist/cjs/photo/PhotoEditorCanvas.js.map +1 -1
- package/dist/cjs/photo/PhotoEditorLeftPanel.js +106 -48
- package/dist/cjs/photo/PhotoEditorLeftPanel.js.map +1 -1
- package/dist/cjs/photo/PhotoEditorToolbar.js +2 -2
- package/dist/cjs/photo/PhotoEditorToolbar.js.map +1 -1
- package/dist/cjs/photo/photoEditorActions.js +27 -18
- package/dist/cjs/photo/photoEditorActions.js.map +1 -1
- package/dist/cjs/photo/photoFilters.js +316 -81
- package/dist/cjs/photo/photoFilters.js.map +1 -1
- package/dist/cjs/photo/photoOverlays.js +521 -165
- package/dist/cjs/photo/photoOverlays.js.map +1 -1
- package/dist/cjs/photo/photoSelection.js +69 -35
- package/dist/cjs/photo/photoSelection.js.map +1 -1
- package/dist/cjs/photo/usePhotoEditor.js +203 -97
- package/dist/cjs/photo/usePhotoEditor.js.map +1 -1
- package/dist/cjs/pixel/HSVPicker.js +32 -19
- package/dist/cjs/pixel/HSVPicker.js.map +1 -1
- package/dist/cjs/pixel/PixelEditor.js +25 -14
- package/dist/cjs/pixel/PixelEditor.js.map +1 -1
- package/dist/cjs/pixel/PixelEditorCanvas.js +2 -2
- package/dist/cjs/pixel/PixelEditorCanvas.js.map +1 -1
- package/dist/cjs/pixel/PixelEditorMenuBar.js +3 -3
- package/dist/cjs/pixel/PixelEditorMenuBar.js.map +1 -1
- package/dist/cjs/pixel/PixelEditorRightPanel.js +28 -8
- package/dist/cjs/pixel/PixelEditorRightPanel.js.map +1 -1
- package/dist/cjs/pixel/PixelEditorStatusBar.js +2 -2
- package/dist/cjs/pixel/PixelEditorStatusBar.js.map +1 -1
- package/dist/cjs/pixel/PixelEditorTimeline.js +3 -4
- package/dist/cjs/pixel/PixelEditorTimeline.js.map +1 -1
- package/dist/cjs/pixel/PixelEditorToolbar.js +3 -3
- package/dist/cjs/pixel/PixelEditorToolbar.js.map +1 -1
- package/dist/cjs/pixel/SpriteGeneratorPanel.js +136 -54
- package/dist/cjs/pixel/SpriteGeneratorPanel.js.map +1 -1
- package/dist/cjs/pixel/asepriteFormat.js +122 -38
- package/dist/cjs/pixel/asepriteFormat.js.map +1 -1
- package/dist/cjs/pixel/characterGeneratorPresets.js +208 -54
- package/dist/cjs/pixel/characterGeneratorPresets.js.map +1 -1
- package/dist/cjs/pixel/pixelEditorExports.js +42 -35
- package/dist/cjs/pixel/pixelEditorExports.js.map +1 -1
- package/dist/cjs/pixel/pixelEditorTypes.js +67 -33
- package/dist/cjs/pixel/pixelEditorTypes.js.map +1 -1
- package/dist/cjs/pixel/pixelEditorUtils.js +62 -38
- package/dist/cjs/pixel/pixelEditorUtils.js.map +1 -1
- package/dist/cjs/pixel/spriteGeneratorCore.js +47 -24
- package/dist/cjs/pixel/spriteGeneratorCore.js.map +1 -1
- package/dist/cjs/pixel/usePixelEditor.js +475 -213
- package/dist/cjs/pixel/usePixelEditor.js.map +1 -1
- package/dist/cjs/texture/Nice3DTexturePainter.js +201 -71
- package/dist/cjs/texture/Nice3DTexturePainter.js.map +1 -1
- package/dist/cjs/ui/NiceUIDesigner.js +280 -91
- package/dist/cjs/ui/NiceUIDesigner.js.map +1 -1
- package/dist/cjs/vector/NiceSvgToCode.js +96 -34
- package/dist/cjs/vector/NiceSvgToCode.js.map +1 -1
- package/dist/cjs/vector/VectorEditor.js +14 -13
- package/dist/cjs/vector/VectorEditor.js.map +1 -1
- package/dist/cjs/vector/VectorEditorMenuBar.js +7 -6
- package/dist/cjs/vector/VectorEditorMenuBar.js.map +1 -1
- package/dist/cjs/vector/VectorEditorRightPanel.js +87 -32
- package/dist/cjs/vector/VectorEditorRightPanel.js.map +1 -1
- package/dist/cjs/vector/VectorEditorShapeRenderer.js +17 -15
- package/dist/cjs/vector/VectorEditorShapeRenderer.js.map +1 -1
- package/dist/cjs/vector/VectorEditorStatusBar.js.map +1 -1
- package/dist/cjs/vector/useVectorEditor.js +312 -122
- package/dist/cjs/vector/useVectorEditor.js.map +1 -1
- package/dist/cjs/vector/vectorBooleanOps.js +60 -42
- package/dist/cjs/vector/vectorBooleanOps.js.map +1 -1
- package/dist/cjs/vector/vectorEditorExport.js +40 -34
- package/dist/cjs/vector/vectorEditorExport.js.map +1 -1
- package/dist/cjs/vector/vectorGradients.js +41 -40
- package/dist/cjs/vector/vectorGradients.js.map +1 -1
- package/dist/esm/animation/AnimatedPerson.js +69 -63
- package/dist/esm/animation/AnimatedPerson.js.map +1 -1
- package/dist/esm/animation/AnimationEditor.js +27 -20
- package/dist/esm/animation/AnimationEditor.js.map +1 -1
- package/dist/esm/animation/Audience.js +17 -11
- package/dist/esm/animation/Audience.js.map +1 -1
- package/dist/esm/animation/BodyRenderer.js +7 -7
- package/dist/esm/animation/BodyRenderer.js.map +1 -1
- package/dist/esm/animation/animationHelper.js +83 -52
- package/dist/esm/animation/animationHelper.js.map +1 -1
- package/dist/esm/animation/characterTypes.js +171 -30
- package/dist/esm/animation/characterTypes.js.map +1 -1
- package/dist/esm/animation/choreoDSL.js +114 -62
- package/dist/esm/animation/choreoDSL.js.map +1 -1
- package/dist/esm/animation/karaokeIntegration.js +10 -11
- package/dist/esm/animation/karaokeIntegration.js.map +1 -1
- package/dist/esm/animation/lottieExport.js +15 -9
- package/dist/esm/animation/lottieExport.js.map +1 -1
- package/dist/esm/animation/motionPath.js +125 -30
- package/dist/esm/animation/motionPath.js.map +1 -1
- package/dist/esm/animation/physics.js +157 -57
- package/dist/esm/animation/physics.js.map +1 -1
- package/dist/esm/animation/rig/RigPlayer.js +7 -6
- package/dist/esm/animation/rig/RigPlayer.js.map +1 -1
- package/dist/esm/animation/rig/RiggedBody.js +7 -7
- package/dist/esm/animation/rig/RiggedBody.js.map +1 -1
- package/dist/esm/animation/rig/choreoRigBridge.js +52 -29
- package/dist/esm/animation/rig/choreoRigBridge.js.map +1 -1
- package/dist/esm/animation/rig/poseOps.js +6 -3
- package/dist/esm/animation/rig/poseOps.js.map +1 -1
- package/dist/esm/animation/shapes/arms.js +7 -6
- package/dist/esm/animation/shapes/arms.js.map +1 -1
- package/dist/esm/animation/shapes/eyes.js +31 -18
- package/dist/esm/animation/shapes/eyes.js.map +1 -1
- package/dist/esm/animation/shapes/hair.js +39 -23
- package/dist/esm/animation/shapes/hair.js.map +1 -1
- package/dist/esm/animation/shapes/heads.js +47 -29
- package/dist/esm/animation/shapes/heads.js.map +1 -1
- package/dist/esm/animation/shapes/headwear.js +26 -14
- package/dist/esm/animation/shapes/headwear.js.map +1 -1
- package/dist/esm/animation/shapes/legs.js +7 -6
- package/dist/esm/animation/shapes/legs.js.map +1 -1
- package/dist/esm/animation/shapes/mouths.js +28 -18
- package/dist/esm/animation/shapes/mouths.js.map +1 -1
- package/dist/esm/animation/shapes/noses.js +18 -9
- package/dist/esm/animation/shapes/noses.js.map +1 -1
- package/dist/esm/animation/shapes/outfits.js +25 -14
- package/dist/esm/animation/shapes/outfits.js.map +1 -1
- package/dist/esm/animation/shapes/torsos.js +5 -4
- package/dist/esm/animation/shapes/torsos.js.map +1 -1
- package/dist/esm/animation/spineExport.js +33 -26
- package/dist/esm/animation/spineExport.js.map +1 -1
- package/dist/esm/core/LocalUI.js +16 -16
- package/dist/esm/core/LocalUI.js.map +1 -1
- package/dist/esm/core/NiceBrushEngine.js +205 -69
- package/dist/esm/core/NiceBrushEngine.js.map +1 -1
- package/dist/esm/core/collaboration.js +35 -21
- package/dist/esm/core/collaboration.js.map +1 -1
- package/dist/esm/core/colorBlindness.js +64 -24
- package/dist/esm/core/colorBlindness.js.map +1 -1
- package/dist/esm/core/dragDrop.js +34 -26
- package/dist/esm/core/dragDrop.js.map +1 -1
- package/dist/esm/core/fixes.js +26 -14
- package/dist/esm/core/fixes.js.map +1 -1
- package/dist/esm/core/gridGuides.js +24 -16
- package/dist/esm/core/gridGuides.js.map +1 -1
- package/dist/esm/core/historyVisual.js +42 -23
- package/dist/esm/core/historyVisual.js.map +1 -1
- package/dist/esm/core/integrations.js +65 -48
- package/dist/esm/core/integrations.js.map +1 -1
- package/dist/esm/core/minimap.js +40 -24
- package/dist/esm/core/minimap.js.map +1 -1
- package/dist/esm/core/plugins.js +10 -6
- package/dist/esm/core/plugins.js.map +1 -1
- package/dist/esm/core/rtl.js +32 -27
- package/dist/esm/core/rtl.js.map +1 -1
- package/dist/esm/core/shortcuts.js +77 -39
- package/dist/esm/core/shortcuts.js.map +1 -1
- package/dist/esm/core/theme.js +68 -61
- package/dist/esm/core/theme.js.map +1 -1
- package/dist/esm/core/yjsCollaboration.js +61 -28
- package/dist/esm/core/yjsCollaboration.js.map +1 -1
- package/dist/esm/font/NiceFontEditor.js +160 -57
- package/dist/esm/font/NiceFontEditor.js.map +1 -1
- package/dist/esm/font/fontFormatUtils.js +37 -24
- package/dist/esm/font/fontFormatUtils.js.map +1 -1
- package/dist/esm/game/GameAsset2dEditor.js +73 -60
- package/dist/esm/game/GameAsset2dEditor.js.map +1 -1
- package/dist/esm/game/gameAssetUtils.js +18 -13
- package/dist/esm/game/gameAssetUtils.js.map +1 -1
- package/dist/esm/game/useGameAssetEditor.js +160 -143
- package/dist/esm/game/useGameAssetEditor.js.map +1 -1
- package/dist/esm/icon/NiceIconEditor.js +329 -106
- package/dist/esm/icon/NiceIconEditor.js.map +1 -1
- package/dist/esm/packages/ui/dist/NiceErrorBoundary-D75yr_WE.js +563 -0
- package/dist/esm/packages/ui/dist/NiceErrorBoundary-D75yr_WE.js.map +1 -0
- package/dist/esm/packages/ui/dist/NiceForm-CKoJA6NG.js +4960 -0
- package/dist/esm/packages/ui/dist/NiceForm-CKoJA6NG.js.map +1 -0
- package/dist/esm/packages/ui/dist/NiceModal-1QX7NhyH.js +96 -0
- package/dist/esm/packages/ui/dist/NiceModal-1QX7NhyH.js.map +1 -0
- package/dist/esm/packages/ui/dist/NiceModuleLifecyclePanel-CMrPbSw9.js +5201 -0
- package/dist/esm/packages/ui/dist/NiceModuleLifecyclePanel-CMrPbSw9.js.map +1 -0
- package/dist/esm/packages/ui/dist/NicePagination-DbE-uOkl.js +172 -0
- package/dist/esm/packages/ui/dist/NicePagination-DbE-uOkl.js.map +1 -0
- package/dist/esm/packages/ui/dist/NicePinCodeInput-B8cI8zu8.js +10408 -0
- package/dist/esm/packages/ui/dist/NicePinCodeInput-B8cI8zu8.js.map +1 -0
- package/dist/esm/packages/ui/dist/NiceSavedQueryPanel-CZ5bYOe_.js +6296 -0
- package/dist/esm/packages/ui/dist/NiceSavedQueryPanel-CZ5bYOe_.js.map +1 -0
- package/dist/esm/packages/ui/dist/NiceTabs-DzLHzwuA.js +1630 -0
- package/dist/esm/packages/ui/dist/NiceTabs-DzLHzwuA.js.map +1 -0
- package/dist/esm/packages/ui/dist/NiceWindow-DeC83yfE.js +796 -0
- package/dist/esm/packages/ui/dist/NiceWindow-DeC83yfE.js.map +1 -0
- package/dist/esm/packages/ui/dist/charts-BAS21jkC.js +3809 -0
- package/dist/esm/packages/ui/dist/charts-BAS21jkC.js.map +1 -0
- package/dist/esm/packages/ui/dist/core-Da43q-pO.js +11502 -0
- package/dist/esm/packages/ui/dist/core-Da43q-pO.js.map +1 -0
- package/dist/esm/packages/ui/dist/index-pAuGTbuB.js +28792 -0
- package/dist/esm/packages/ui/dist/index-pAuGTbuB.js.map +1 -0
- package/dist/esm/photo/FilterThumb.js +7 -5
- package/dist/esm/photo/FilterThumb.js.map +1 -1
- package/dist/esm/photo/NiceAITools.js +78 -32
- package/dist/esm/photo/NiceAITools.js.map +1 -1
- package/dist/esm/photo/PhotoEditor.js +4 -4
- package/dist/esm/photo/PhotoEditor.js.map +1 -1
- package/dist/esm/photo/PhotoEditorCanvas.js +56 -22
- package/dist/esm/photo/PhotoEditorCanvas.js.map +1 -1
- package/dist/esm/photo/PhotoEditorLeftPanel.js +106 -48
- package/dist/esm/photo/PhotoEditorLeftPanel.js.map +1 -1
- package/dist/esm/photo/PhotoEditorToolbar.js +2 -2
- package/dist/esm/photo/PhotoEditorToolbar.js.map +1 -1
- package/dist/esm/photo/photoEditorActions.js +27 -18
- package/dist/esm/photo/photoEditorActions.js.map +1 -1
- package/dist/esm/photo/photoFilters.js +316 -81
- package/dist/esm/photo/photoFilters.js.map +1 -1
- package/dist/esm/photo/photoOverlays.js +521 -165
- package/dist/esm/photo/photoOverlays.js.map +1 -1
- package/dist/esm/photo/photoSelection.js +69 -35
- package/dist/esm/photo/photoSelection.js.map +1 -1
- package/dist/esm/photo/usePhotoEditor.js +203 -97
- package/dist/esm/photo/usePhotoEditor.js.map +1 -1
- package/dist/esm/pixel/HSVPicker.js +32 -19
- package/dist/esm/pixel/HSVPicker.js.map +1 -1
- package/dist/esm/pixel/PixelEditor.js +25 -14
- package/dist/esm/pixel/PixelEditor.js.map +1 -1
- package/dist/esm/pixel/PixelEditorCanvas.js +2 -2
- package/dist/esm/pixel/PixelEditorCanvas.js.map +1 -1
- package/dist/esm/pixel/PixelEditorMenuBar.js +3 -3
- package/dist/esm/pixel/PixelEditorMenuBar.js.map +1 -1
- package/dist/esm/pixel/PixelEditorRightPanel.js +28 -8
- package/dist/esm/pixel/PixelEditorRightPanel.js.map +1 -1
- package/dist/esm/pixel/PixelEditorStatusBar.js +2 -2
- package/dist/esm/pixel/PixelEditorStatusBar.js.map +1 -1
- package/dist/esm/pixel/PixelEditorTimeline.js +3 -4
- package/dist/esm/pixel/PixelEditorTimeline.js.map +1 -1
- package/dist/esm/pixel/PixelEditorToolbar.js +3 -3
- package/dist/esm/pixel/PixelEditorToolbar.js.map +1 -1
- package/dist/esm/pixel/SpriteGeneratorPanel.js +136 -54
- package/dist/esm/pixel/SpriteGeneratorPanel.js.map +1 -1
- package/dist/esm/pixel/asepriteFormat.js +122 -38
- package/dist/esm/pixel/asepriteFormat.js.map +1 -1
- package/dist/esm/pixel/characterGeneratorPresets.js +208 -54
- package/dist/esm/pixel/characterGeneratorPresets.js.map +1 -1
- package/dist/esm/pixel/pixelEditorExports.js +42 -35
- package/dist/esm/pixel/pixelEditorExports.js.map +1 -1
- package/dist/esm/pixel/pixelEditorTypes.js +67 -33
- package/dist/esm/pixel/pixelEditorTypes.js.map +1 -1
- package/dist/esm/pixel/pixelEditorUtils.js +62 -38
- package/dist/esm/pixel/pixelEditorUtils.js.map +1 -1
- package/dist/esm/pixel/spriteGeneratorCore.js +47 -24
- package/dist/esm/pixel/spriteGeneratorCore.js.map +1 -1
- package/dist/esm/pixel/usePixelEditor.js +475 -213
- package/dist/esm/pixel/usePixelEditor.js.map +1 -1
- package/dist/esm/texture/Nice3DTexturePainter.js +201 -71
- package/dist/esm/texture/Nice3DTexturePainter.js.map +1 -1
- package/dist/esm/ui/NiceUIDesigner.js +280 -91
- package/dist/esm/ui/NiceUIDesigner.js.map +1 -1
- package/dist/esm/vector/NiceSvgToCode.js +96 -34
- package/dist/esm/vector/NiceSvgToCode.js.map +1 -1
- package/dist/esm/vector/VectorEditor.js +14 -13
- package/dist/esm/vector/VectorEditor.js.map +1 -1
- package/dist/esm/vector/VectorEditorMenuBar.js +7 -6
- package/dist/esm/vector/VectorEditorMenuBar.js.map +1 -1
- package/dist/esm/vector/VectorEditorRightPanel.js +87 -32
- package/dist/esm/vector/VectorEditorRightPanel.js.map +1 -1
- package/dist/esm/vector/VectorEditorShapeRenderer.js +17 -15
- package/dist/esm/vector/VectorEditorShapeRenderer.js.map +1 -1
- package/dist/esm/vector/VectorEditorStatusBar.js.map +1 -1
- package/dist/esm/vector/useVectorEditor.js +312 -122
- package/dist/esm/vector/useVectorEditor.js.map +1 -1
- package/dist/esm/vector/vectorBooleanOps.js +60 -42
- package/dist/esm/vector/vectorBooleanOps.js.map +1 -1
- package/dist/esm/vector/vectorEditorExport.js +40 -34
- package/dist/esm/vector/vectorEditorExport.js.map +1 -1
- package/dist/esm/vector/vectorGradients.js +41 -40
- package/dist/esm/vector/vectorGradients.js.map +1 -1
- package/package.json +2 -2
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var React = require('react');
|
|
4
|
-
var
|
|
4
|
+
var vectorBooleanOps = require('./vectorBooleanOps.js');
|
|
5
5
|
var vectorEditorExport = require('./vectorEditorExport.js');
|
|
6
6
|
var vectorEditorImport = require('./vectorEditorImport.js');
|
|
7
|
-
var
|
|
7
|
+
var vectorEditorTypes = require('./vectorEditorTypes.js');
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* useVectorEditor — extracted logic + state for VectorEditor.
|
|
@@ -15,12 +15,12 @@ function useVectorEditor({ artW, artH, onSaveToLibrary }) {
|
|
|
15
15
|
/* ── state ── */
|
|
16
16
|
const [shapes, setShapes] = React.useState([]);
|
|
17
17
|
const [selId, setSelId] = React.useState(null);
|
|
18
|
-
const [tool, setTool] = React.useState(
|
|
19
|
-
const [fillCol, setFillCol] = React.useState(
|
|
20
|
-
const [strokeCol, setStrokeCol] = React.useState(
|
|
18
|
+
const [tool, setTool] = React.useState('pointer');
|
|
19
|
+
const [fillCol, setFillCol] = React.useState('#5566cc');
|
|
20
|
+
const [strokeCol, setStrokeCol] = React.useState('#ffffff');
|
|
21
21
|
const [strokeW, setStrokeW] = React.useState(2);
|
|
22
22
|
const [fontSize, setFontSize] = React.useState(24);
|
|
23
|
-
const [fontFamily, setFontFamily] = React.useState(
|
|
23
|
+
const [fontFamily, setFontFamily] = React.useState('sans-serif');
|
|
24
24
|
const [shapeOpacity, setShapeOpacity] = React.useState(1);
|
|
25
25
|
const [cornerRadius, setCornerRadius] = React.useState(12);
|
|
26
26
|
const [polygonSides, setPolygonSides] = React.useState(6);
|
|
@@ -30,7 +30,7 @@ function useVectorEditor({ artW, artH, onSaveToLibrary }) {
|
|
|
30
30
|
const [px, setPx] = React.useState(0);
|
|
31
31
|
const [py, setPy] = React.useState(0);
|
|
32
32
|
const [dlgSvg, setDlgSvg] = React.useState(false);
|
|
33
|
-
const [svgText, setSvgText] = React.useState(
|
|
33
|
+
const [svgText, setSvgText] = React.useState('');
|
|
34
34
|
const [snapGrid, setSnapGrid] = React.useState(false);
|
|
35
35
|
const [gridSize, setGridSize] = React.useState(16);
|
|
36
36
|
const [hasClipboard, setHasClipboard] = React.useState(false);
|
|
@@ -61,18 +61,21 @@ function useVectorEditor({ artW, artH, onSaveToLibrary }) {
|
|
|
61
61
|
hIdx.current = hist.current.length - 1;
|
|
62
62
|
}, []);
|
|
63
63
|
React.useEffect(() => {
|
|
64
|
-
if (hist.current.length === 0)
|
|
64
|
+
if (hist.current.length === 0) {
|
|
65
65
|
snap([]);
|
|
66
|
+
}
|
|
66
67
|
}, [snap]);
|
|
67
68
|
const undo = React.useCallback(() => {
|
|
68
|
-
if (hIdx.current <= 0)
|
|
69
|
+
if (hIdx.current <= 0) {
|
|
69
70
|
return;
|
|
71
|
+
}
|
|
70
72
|
hIdx.current--;
|
|
71
73
|
setShapes(vectorEditorTypes.cloneShapes(hist.current[hIdx.current].shapes));
|
|
72
74
|
}, []);
|
|
73
75
|
const redo = React.useCallback(() => {
|
|
74
|
-
if (hIdx.current >= hist.current.length - 1)
|
|
76
|
+
if (hIdx.current >= hist.current.length - 1) {
|
|
75
77
|
return;
|
|
78
|
+
}
|
|
76
79
|
hIdx.current++;
|
|
77
80
|
setShapes(vectorEditorTypes.cloneShapes(hist.current[hIdx.current].shapes));
|
|
78
81
|
}, []);
|
|
@@ -80,8 +83,9 @@ function useVectorEditor({ artW, artH, onSaveToLibrary }) {
|
|
|
80
83
|
const scr2art = React.useCallback((cx, cy) => {
|
|
81
84
|
var _a;
|
|
82
85
|
const r = (_a = boxRef.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
|
|
83
|
-
if (!r)
|
|
86
|
+
if (!r) {
|
|
84
87
|
return { x: 0, y: 0 };
|
|
88
|
+
}
|
|
85
89
|
let x = (cx - r.left - r.width / 2 - px) / zoom + artW / 2;
|
|
86
90
|
let y = (cy - r.top - r.height / 2 - py) / zoom + artH / 2;
|
|
87
91
|
if (snapGrid) {
|
|
@@ -98,8 +102,9 @@ function useVectorEditor({ artW, artH, onSaveToLibrary }) {
|
|
|
98
102
|
panStart.current = { mx: e.clientX, my: e.clientY, px, py };
|
|
99
103
|
return;
|
|
100
104
|
}
|
|
101
|
-
if (e.button !== 0)
|
|
105
|
+
if (e.button !== 0) {
|
|
102
106
|
return;
|
|
107
|
+
}
|
|
103
108
|
const p = scr2art(e.clientX, e.clientY);
|
|
104
109
|
const defaultBase = {
|
|
105
110
|
fill: fillCol,
|
|
@@ -108,7 +113,7 @@ function useVectorEditor({ artW, artH, onSaveToLibrary }) {
|
|
|
108
113
|
opacity: shapeOpacity,
|
|
109
114
|
rotation: 0,
|
|
110
115
|
};
|
|
111
|
-
if (tool ===
|
|
116
|
+
if (tool === 'pointer') {
|
|
112
117
|
let hit = null;
|
|
113
118
|
for (let i = shapes.length - 1; i >= 0; i--) {
|
|
114
119
|
const s = shapes[i];
|
|
@@ -124,13 +129,22 @@ function useVectorEditor({ artW, artH, onSaveToLibrary }) {
|
|
|
124
129
|
}
|
|
125
130
|
return;
|
|
126
131
|
}
|
|
127
|
-
if (tool ===
|
|
132
|
+
if (tool === 'pen') {
|
|
128
133
|
penPts.current.push(p);
|
|
129
134
|
if (penPts.current.length === 1) {
|
|
130
135
|
const ns = {
|
|
131
|
-
id: vectorEditorTypes.sid(),
|
|
132
|
-
|
|
133
|
-
|
|
136
|
+
id: vectorEditorTypes.sid(),
|
|
137
|
+
type: 'polyline',
|
|
138
|
+
x: p.x,
|
|
139
|
+
y: p.y,
|
|
140
|
+
w: 0,
|
|
141
|
+
h: 0,
|
|
142
|
+
points: [{ x: p.x, y: p.y }],
|
|
143
|
+
fill: 'none',
|
|
144
|
+
stroke: strokeCol,
|
|
145
|
+
strokeWidth: strokeW,
|
|
146
|
+
opacity: shapeOpacity,
|
|
147
|
+
rotation: 0,
|
|
134
148
|
};
|
|
135
149
|
pendingShape.current = ns;
|
|
136
150
|
setShapes((prev) => [...prev, ns]);
|
|
@@ -142,21 +156,37 @@ function useVectorEditor({ artW, artH, onSaveToLibrary }) {
|
|
|
142
156
|
setShapes((prev) => prev.map((s) => {
|
|
143
157
|
var _a;
|
|
144
158
|
return s.id === ((_a = pendingShape.current) === null || _a === void 0 ? void 0 : _a.id)
|
|
145
|
-
? {
|
|
159
|
+
? {
|
|
160
|
+
...s,
|
|
161
|
+
points: pts,
|
|
162
|
+
x: Math.min(...xs),
|
|
163
|
+
y: Math.min(...ys),
|
|
164
|
+
w: Math.max(...xs) - Math.min(...xs),
|
|
165
|
+
h: Math.max(...ys) - Math.min(...ys),
|
|
166
|
+
}
|
|
146
167
|
: s;
|
|
147
168
|
}));
|
|
148
169
|
}
|
|
149
170
|
return;
|
|
150
171
|
}
|
|
151
|
-
if (tool ===
|
|
152
|
-
const txt = prompt(
|
|
153
|
-
if (!txt)
|
|
172
|
+
if (tool === 'text') {
|
|
173
|
+
const txt = prompt('Enter text:', 'Hello');
|
|
174
|
+
if (!txt) {
|
|
154
175
|
return;
|
|
176
|
+
}
|
|
155
177
|
const ns = {
|
|
156
|
-
id: vectorEditorTypes.sid(),
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
178
|
+
id: vectorEditorTypes.sid(),
|
|
179
|
+
type: 'text',
|
|
180
|
+
x: p.x,
|
|
181
|
+
y: p.y,
|
|
182
|
+
w: txt.length * fontSize * 0.6,
|
|
183
|
+
h: fontSize,
|
|
184
|
+
...defaultBase,
|
|
185
|
+
stroke: 'none',
|
|
186
|
+
strokeWidth: 0,
|
|
187
|
+
text: txt,
|
|
188
|
+
fontSize,
|
|
189
|
+
fontFamily,
|
|
160
190
|
};
|
|
161
191
|
const next = [...shapes, ns];
|
|
162
192
|
snap(next);
|
|
@@ -164,11 +194,17 @@ function useVectorEditor({ artW, artH, onSaveToLibrary }) {
|
|
|
164
194
|
setSelId(ns.id);
|
|
165
195
|
return;
|
|
166
196
|
}
|
|
167
|
-
if (tool ===
|
|
197
|
+
if (tool === 'polygon') {
|
|
168
198
|
const r2 = 40;
|
|
169
199
|
const ns = {
|
|
170
|
-
id: vectorEditorTypes.sid(),
|
|
171
|
-
|
|
200
|
+
id: vectorEditorTypes.sid(),
|
|
201
|
+
type: 'polygon',
|
|
202
|
+
x: p.x - r2,
|
|
203
|
+
y: p.y - r2,
|
|
204
|
+
w: r2 * 2,
|
|
205
|
+
h: r2 * 2,
|
|
206
|
+
...defaultBase,
|
|
207
|
+
sides: polygonSides,
|
|
172
208
|
};
|
|
173
209
|
drawing.current = true;
|
|
174
210
|
startPt.current = p;
|
|
@@ -176,11 +212,18 @@ function useVectorEditor({ artW, artH, onSaveToLibrary }) {
|
|
|
176
212
|
setShapes((prev) => [...prev, ns]);
|
|
177
213
|
return;
|
|
178
214
|
}
|
|
179
|
-
if (tool ===
|
|
215
|
+
if (tool === 'star') {
|
|
180
216
|
const r2 = 40;
|
|
181
217
|
const ns = {
|
|
182
|
-
id: vectorEditorTypes.sid(),
|
|
183
|
-
|
|
218
|
+
id: vectorEditorTypes.sid(),
|
|
219
|
+
type: 'star',
|
|
220
|
+
x: p.x - r2,
|
|
221
|
+
y: p.y - r2,
|
|
222
|
+
w: r2 * 2,
|
|
223
|
+
h: r2 * 2,
|
|
224
|
+
...defaultBase,
|
|
225
|
+
sides: starPoints2,
|
|
226
|
+
innerRadius: starInnerRatio,
|
|
184
227
|
};
|
|
185
228
|
drawing.current = true;
|
|
186
229
|
startPt.current = p;
|
|
@@ -191,29 +234,61 @@ function useVectorEditor({ artW, artH, onSaveToLibrary }) {
|
|
|
191
234
|
// rect / roundrect / ellipse / line / arrow — start drag
|
|
192
235
|
drawing.current = true;
|
|
193
236
|
startPt.current = p;
|
|
194
|
-
const typeMap = {
|
|
195
|
-
|
|
196
|
-
|
|
237
|
+
const typeMap = {
|
|
238
|
+
line: 'line',
|
|
239
|
+
arrow: 'arrow',
|
|
240
|
+
ellipse: 'ellipse',
|
|
241
|
+
roundrect: 'roundrect',
|
|
242
|
+
};
|
|
243
|
+
const shapeType = typeMap[tool] || 'rect';
|
|
244
|
+
const isLineLike = shapeType === 'line' || shapeType === 'arrow';
|
|
197
245
|
const ns = {
|
|
198
|
-
id: vectorEditorTypes.sid(),
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
246
|
+
id: vectorEditorTypes.sid(),
|
|
247
|
+
type: shapeType,
|
|
248
|
+
x: p.x,
|
|
249
|
+
y: p.y,
|
|
250
|
+
w: 0,
|
|
251
|
+
h: 0,
|
|
252
|
+
x2: p.x,
|
|
253
|
+
y2: p.y,
|
|
254
|
+
fill: isLineLike ? 'none' : fillCol,
|
|
255
|
+
stroke: strokeCol,
|
|
256
|
+
strokeWidth: strokeW,
|
|
257
|
+
opacity: shapeOpacity,
|
|
258
|
+
rotation: 0,
|
|
259
|
+
rx: shapeType === 'roundrect' ? cornerRadius : undefined,
|
|
203
260
|
};
|
|
204
261
|
pendingShape.current = ns;
|
|
205
262
|
setShapes((prev) => [...prev, ns]);
|
|
206
|
-
}, [
|
|
263
|
+
}, [
|
|
264
|
+
tool,
|
|
265
|
+
shapes,
|
|
266
|
+
scr2art,
|
|
267
|
+
px,
|
|
268
|
+
py,
|
|
269
|
+
fillCol,
|
|
270
|
+
strokeCol,
|
|
271
|
+
strokeW,
|
|
272
|
+
fontSize,
|
|
273
|
+
fontFamily,
|
|
274
|
+
snap,
|
|
275
|
+
shapeOpacity,
|
|
276
|
+
polygonSides,
|
|
277
|
+
starPoints2,
|
|
278
|
+
starInnerRatio,
|
|
279
|
+
cornerRadius,
|
|
280
|
+
]);
|
|
207
281
|
const onMove = React.useCallback((e) => {
|
|
208
282
|
if (panning.current) {
|
|
209
283
|
setPx(panStart.current.px + (e.clientX - panStart.current.mx));
|
|
210
284
|
setPy(panStart.current.py + (e.clientY - panStart.current.my));
|
|
211
285
|
return;
|
|
212
286
|
}
|
|
213
|
-
if (!drawing.current)
|
|
287
|
+
if (!drawing.current) {
|
|
214
288
|
return;
|
|
289
|
+
}
|
|
215
290
|
const p = scr2art(e.clientX, e.clientY);
|
|
216
|
-
if (tool ===
|
|
291
|
+
if (tool === 'pointer' && selId) {
|
|
217
292
|
const dx = p.x - startPt.current.x;
|
|
218
293
|
const dy = p.y - startPt.current.y;
|
|
219
294
|
startPt.current = p;
|
|
@@ -221,7 +296,9 @@ function useVectorEditor({ artW, artH, onSaveToLibrary }) {
|
|
|
221
296
|
var _a;
|
|
222
297
|
return s.id === selId
|
|
223
298
|
? {
|
|
224
|
-
...s,
|
|
299
|
+
...s,
|
|
300
|
+
x: s.x + dx,
|
|
301
|
+
y: s.y + dy,
|
|
225
302
|
x2: s.x2 != null ? s.x2 + dx : undefined,
|
|
226
303
|
y2: s.y2 != null ? s.y2 + dy : undefined,
|
|
227
304
|
points: (_a = s.points) === null || _a === void 0 ? void 0 : _a.map((pt) => ({ x: pt.x + dx, y: pt.y + dy })),
|
|
@@ -230,10 +307,11 @@ function useVectorEditor({ artW, artH, onSaveToLibrary }) {
|
|
|
230
307
|
}));
|
|
231
308
|
return;
|
|
232
309
|
}
|
|
233
|
-
if (!pendingShape.current)
|
|
310
|
+
if (!pendingShape.current) {
|
|
234
311
|
return;
|
|
312
|
+
}
|
|
235
313
|
const t = pendingShape.current.type;
|
|
236
|
-
if (t ===
|
|
314
|
+
if (t === 'polygon' || t === 'star') {
|
|
237
315
|
const cx = startPt.current.x;
|
|
238
316
|
const cy = startPt.current.y;
|
|
239
317
|
const dx = p.x - cx;
|
|
@@ -244,14 +322,14 @@ function useVectorEditor({ artW, artH, onSaveToLibrary }) {
|
|
|
244
322
|
: s));
|
|
245
323
|
return;
|
|
246
324
|
}
|
|
247
|
-
if (t ===
|
|
325
|
+
if (t === 'rect' || t === 'roundrect' || t === 'ellipse') {
|
|
248
326
|
const x1 = Math.min(startPt.current.x, p.x);
|
|
249
327
|
const y1 = Math.min(startPt.current.y, p.y);
|
|
250
328
|
const w2 = Math.abs(p.x - startPt.current.x);
|
|
251
329
|
const h2 = Math.abs(p.y - startPt.current.y);
|
|
252
330
|
setShapes((prev) => prev.map((s) => s.id === pendingShape.current.id ? { ...s, x: x1, y: y1, w: w2, h: h2 } : s));
|
|
253
331
|
}
|
|
254
|
-
else if (t ===
|
|
332
|
+
else if (t === 'line' || t === 'arrow') {
|
|
255
333
|
setShapes((prev) => prev.map((s) => s.id === pendingShape.current.id
|
|
256
334
|
? { ...s, w: Math.abs(p.x - s.x), h: Math.abs(p.y - s.y), x2: p.x, y2: p.y }
|
|
257
335
|
: s));
|
|
@@ -267,9 +345,9 @@ function useVectorEditor({ artW, artH, onSaveToLibrary }) {
|
|
|
267
345
|
drawing.current = false;
|
|
268
346
|
if (pendingShape.current) {
|
|
269
347
|
const ps = pendingShape.current;
|
|
270
|
-
if (ps.type !==
|
|
348
|
+
if (ps.type !== 'polyline' && ps.type !== 'text') {
|
|
271
349
|
const minD = 3;
|
|
272
|
-
const isTiny = ps.type ===
|
|
350
|
+
const isTiny = ps.type === 'line' || ps.type === 'arrow'
|
|
273
351
|
? Math.abs(((_a = ps.x2) !== null && _a !== void 0 ? _a : ps.x) - ps.x) < minD && Math.abs(((_b = ps.y2) !== null && _b !== void 0 ? _b : ps.y) - ps.y) < minD
|
|
274
352
|
: Math.abs(ps.w) < minD && Math.abs(ps.h) < minD;
|
|
275
353
|
if (isTiny) {
|
|
@@ -284,14 +362,22 @@ function useVectorEditor({ artW, artH, onSaveToLibrary }) {
|
|
|
284
362
|
}
|
|
285
363
|
}, [snap]);
|
|
286
364
|
const onWheel = React.useCallback((e) => {
|
|
287
|
-
e.preventDefault();
|
|
288
365
|
setZoom((z) => {
|
|
289
366
|
const n = e.deltaY < 0 ? z * 1.15 : z / 1.15;
|
|
290
367
|
return Math.max(0.1, Math.min(10, n));
|
|
291
368
|
});
|
|
292
369
|
}, []);
|
|
370
|
+
React.useEffect(() => {
|
|
371
|
+
const el = boxRef.current;
|
|
372
|
+
if (!el) {
|
|
373
|
+
return;
|
|
374
|
+
}
|
|
375
|
+
const handler = (e) => e.preventDefault();
|
|
376
|
+
el.addEventListener('wheel', handler, { passive: false });
|
|
377
|
+
return () => el.removeEventListener('wheel', handler);
|
|
378
|
+
}, []);
|
|
293
379
|
const onDblClick = React.useCallback(() => {
|
|
294
|
-
if (tool ===
|
|
380
|
+
if (tool === 'pen' && pendingShape.current) {
|
|
295
381
|
snap(shapesRef.current);
|
|
296
382
|
setSelId(pendingShape.current.id);
|
|
297
383
|
pendingShape.current = null;
|
|
@@ -300,52 +386,69 @@ function useVectorEditor({ artW, artH, onSaveToLibrary }) {
|
|
|
300
386
|
}, [tool, snap]);
|
|
301
387
|
/* ── shape operations ── */
|
|
302
388
|
const deleteShape = React.useCallback(() => {
|
|
303
|
-
if (!selId)
|
|
389
|
+
if (!selId) {
|
|
304
390
|
return;
|
|
391
|
+
}
|
|
305
392
|
const next = shapes.filter((s) => s.id !== selId);
|
|
306
393
|
snap(next);
|
|
307
394
|
setShapes(next);
|
|
308
395
|
setSelId(null);
|
|
309
396
|
}, [selId, shapes, snap]);
|
|
310
397
|
const bringToFront = React.useCallback(() => {
|
|
311
|
-
if (!selId)
|
|
398
|
+
if (!selId) {
|
|
312
399
|
return;
|
|
400
|
+
}
|
|
313
401
|
const next = [...shapes.filter((s) => s.id !== selId), shapes.find((s) => s.id === selId)];
|
|
314
402
|
snap(next);
|
|
315
403
|
setShapes(next);
|
|
316
404
|
}, [selId, shapes, snap]);
|
|
317
405
|
const sendToBack = React.useCallback(() => {
|
|
318
|
-
if (!selId)
|
|
406
|
+
if (!selId) {
|
|
319
407
|
return;
|
|
408
|
+
}
|
|
320
409
|
const next = [shapes.find((s) => s.id === selId), ...shapes.filter((s) => s.id !== selId)];
|
|
321
410
|
snap(next);
|
|
322
411
|
setShapes(next);
|
|
323
412
|
}, [selId, shapes, snap]);
|
|
324
413
|
const updateSel = React.useCallback((patch) => {
|
|
325
|
-
if (!selId)
|
|
414
|
+
if (!selId) {
|
|
326
415
|
return;
|
|
416
|
+
}
|
|
327
417
|
setShapes((prev) => prev.map((s) => (s.id === selId ? { ...s, ...patch } : s)));
|
|
328
418
|
}, [selId]);
|
|
329
419
|
/* ── clipboard ── */
|
|
330
420
|
const copyShape = React.useCallback(() => {
|
|
331
|
-
if (!selShape)
|
|
421
|
+
if (!selShape) {
|
|
332
422
|
return;
|
|
423
|
+
}
|
|
333
424
|
clipboard.current = JSON.parse(JSON.stringify(selShape));
|
|
334
425
|
setHasClipboard(true);
|
|
335
426
|
}, [selShape]);
|
|
336
427
|
const pasteShape = React.useCallback(() => {
|
|
337
|
-
if (!clipboard.current)
|
|
428
|
+
if (!clipboard.current) {
|
|
338
429
|
return;
|
|
339
|
-
|
|
430
|
+
}
|
|
431
|
+
const ns = {
|
|
432
|
+
...JSON.parse(JSON.stringify(clipboard.current)),
|
|
433
|
+
id: vectorEditorTypes.sid(),
|
|
434
|
+
x: clipboard.current.x + 20,
|
|
435
|
+
y: clipboard.current.y + 20,
|
|
436
|
+
};
|
|
340
437
|
const next = [...shapes, ns];
|
|
341
438
|
snap(next);
|
|
342
439
|
setShapes(next);
|
|
343
440
|
setSelId(ns.id);
|
|
344
441
|
}, [shapes, snap]);
|
|
345
442
|
const duplicateShape = React.useCallback(() => {
|
|
346
|
-
if (!selShape)
|
|
443
|
+
if (!selShape) {
|
|
347
444
|
return;
|
|
348
|
-
|
|
445
|
+
}
|
|
446
|
+
const ns = {
|
|
447
|
+
...JSON.parse(JSON.stringify(selShape)),
|
|
448
|
+
id: vectorEditorTypes.sid(),
|
|
449
|
+
x: selShape.x + 20,
|
|
450
|
+
y: selShape.y + 20,
|
|
451
|
+
};
|
|
349
452
|
const next = [...shapes, ns];
|
|
350
453
|
snap(next);
|
|
351
454
|
setShapes(next);
|
|
@@ -353,69 +456,82 @@ function useVectorEditor({ artW, artH, onSaveToLibrary }) {
|
|
|
353
456
|
}, [selShape, shapes, snap]);
|
|
354
457
|
/* ── flip ── */
|
|
355
458
|
const flipH = React.useCallback(() => {
|
|
356
|
-
if (!selId || !selShape)
|
|
459
|
+
if (!selId || !selShape) {
|
|
357
460
|
return;
|
|
461
|
+
}
|
|
358
462
|
if (selShape.points) {
|
|
359
463
|
const cx = selShape.x + selShape.w / 2;
|
|
360
|
-
const next = shapes.map((s) => {
|
|
464
|
+
const next = shapes.map((s) => {
|
|
465
|
+
var _a;
|
|
466
|
+
return s.id === selId
|
|
467
|
+
? { ...s, points: (_a = s.points) === null || _a === void 0 ? void 0 : _a.map((pt) => ({ x: cx * 2 - pt.x, y: pt.y })) }
|
|
468
|
+
: s;
|
|
469
|
+
});
|
|
361
470
|
snap(next);
|
|
362
471
|
setShapes(next);
|
|
363
472
|
}
|
|
364
|
-
else if (selShape.type ===
|
|
365
|
-
const next = shapes.map((s) => { var _a; return s.id === selId ? { ...s, x: (_a = s.x2) !== null && _a !== void 0 ? _a : s.x, x2: s.x } : s; });
|
|
473
|
+
else if (selShape.type === 'line' || selShape.type === 'arrow') {
|
|
474
|
+
const next = shapes.map((s) => { var _a; return (s.id === selId ? { ...s, x: (_a = s.x2) !== null && _a !== void 0 ? _a : s.x, x2: s.x } : s); });
|
|
366
475
|
snap(next);
|
|
367
476
|
setShapes(next);
|
|
368
477
|
}
|
|
369
478
|
else {
|
|
370
479
|
const newRot = selShape.rotation ? -selShape.rotation : 0;
|
|
371
|
-
const next = shapes.map((s) => s.id === selId ? { ...s, rotation: newRot } : s);
|
|
480
|
+
const next = shapes.map((s) => (s.id === selId ? { ...s, rotation: newRot } : s));
|
|
372
481
|
snap(next);
|
|
373
482
|
setShapes(next);
|
|
374
483
|
}
|
|
375
484
|
}, [selId, selShape, shapes, snap]);
|
|
376
485
|
const flipV = React.useCallback(() => {
|
|
377
|
-
if (!selId || !selShape)
|
|
486
|
+
if (!selId || !selShape) {
|
|
378
487
|
return;
|
|
488
|
+
}
|
|
379
489
|
if (selShape.points) {
|
|
380
490
|
const cy = selShape.y + selShape.h / 2;
|
|
381
|
-
const next = shapes.map((s) => {
|
|
491
|
+
const next = shapes.map((s) => {
|
|
492
|
+
var _a;
|
|
493
|
+
return s.id === selId
|
|
494
|
+
? { ...s, points: (_a = s.points) === null || _a === void 0 ? void 0 : _a.map((pt) => ({ x: pt.x, y: cy * 2 - pt.y })) }
|
|
495
|
+
: s;
|
|
496
|
+
});
|
|
382
497
|
snap(next);
|
|
383
498
|
setShapes(next);
|
|
384
499
|
}
|
|
385
|
-
else if (selShape.type ===
|
|
386
|
-
const next = shapes.map((s) => { var _a; return s.id === selId ? { ...s, y: (_a = s.y2) !== null && _a !== void 0 ? _a : s.y, y2: s.y } : s; });
|
|
500
|
+
else if (selShape.type === 'line' || selShape.type === 'arrow') {
|
|
501
|
+
const next = shapes.map((s) => { var _a; return (s.id === selId ? { ...s, y: (_a = s.y2) !== null && _a !== void 0 ? _a : s.y, y2: s.y } : s); });
|
|
387
502
|
snap(next);
|
|
388
503
|
setShapes(next);
|
|
389
504
|
}
|
|
390
505
|
else {
|
|
391
506
|
const newRot = selShape.rotation ? (180 - selShape.rotation) % 360 : 180;
|
|
392
|
-
const next = shapes.map((s) => s.id === selId ? { ...s, rotation: newRot } : s);
|
|
507
|
+
const next = shapes.map((s) => (s.id === selId ? { ...s, rotation: newRot } : s));
|
|
393
508
|
snap(next);
|
|
394
509
|
setShapes(next);
|
|
395
510
|
}
|
|
396
511
|
}, [selId, selShape, shapes, snap]);
|
|
397
512
|
/* ── alignment ── */
|
|
398
513
|
const alignShapes = React.useCallback((mode) => {
|
|
399
|
-
if (!selId || !selShape)
|
|
514
|
+
if (!selId || !selShape) {
|
|
400
515
|
return;
|
|
516
|
+
}
|
|
401
517
|
let patch = {};
|
|
402
518
|
switch (mode) {
|
|
403
|
-
case
|
|
519
|
+
case 'left':
|
|
404
520
|
patch = { x: 0 };
|
|
405
521
|
break;
|
|
406
|
-
case
|
|
522
|
+
case 'right':
|
|
407
523
|
patch = { x: artW - selShape.w };
|
|
408
524
|
break;
|
|
409
|
-
case
|
|
525
|
+
case 'center':
|
|
410
526
|
patch = { x: (artW - selShape.w) / 2 };
|
|
411
527
|
break;
|
|
412
|
-
case
|
|
528
|
+
case 'top':
|
|
413
529
|
patch = { y: 0 };
|
|
414
530
|
break;
|
|
415
|
-
case
|
|
531
|
+
case 'bottom':
|
|
416
532
|
patch = { y: artH - selShape.h };
|
|
417
533
|
break;
|
|
418
|
-
case
|
|
534
|
+
case 'middle':
|
|
419
535
|
patch = { y: (artH - selShape.h) / 2 };
|
|
420
536
|
break;
|
|
421
537
|
}
|
|
@@ -427,15 +543,17 @@ function useVectorEditor({ artW, artH, onSaveToLibrary }) {
|
|
|
427
543
|
const [boolSecondShape, setBoolSecondShape] = React.useState(null);
|
|
428
544
|
const applyBoolean = React.useCallback((operation) => {
|
|
429
545
|
var _a;
|
|
430
|
-
if (!selId || !boolSecondShape)
|
|
546
|
+
if (!selId || !boolSecondShape) {
|
|
431
547
|
return;
|
|
548
|
+
}
|
|
432
549
|
const shapeA = shapes.find((s) => s.id === selId);
|
|
433
550
|
const shapeB = shapes.find((s) => s.id === boolSecondShape);
|
|
434
|
-
if (!shapeA || !shapeB)
|
|
551
|
+
if (!shapeA || !shapeB) {
|
|
435
552
|
return;
|
|
553
|
+
}
|
|
436
554
|
const result = vectorBooleanOps.booleanOperation(shapeA, shapeB, operation);
|
|
437
555
|
if (!result) {
|
|
438
|
-
|
|
556
|
+
console.warn('[VectorEditor] Boolean operation resulted in empty shape');
|
|
439
557
|
return;
|
|
440
558
|
}
|
|
441
559
|
// Remove original shapes, add result(s)
|
|
@@ -452,13 +570,14 @@ function useVectorEditor({ artW, artH, onSaveToLibrary }) {
|
|
|
452
570
|
setShapes(next);
|
|
453
571
|
setBoolSecondShape(null);
|
|
454
572
|
}, [selId, boolSecondShape, shapes, snap]);
|
|
455
|
-
const unionShapes = React.useCallback(() => applyBoolean(
|
|
456
|
-
const subtractShapes = React.useCallback(() => applyBoolean(
|
|
457
|
-
const intersectShapes = React.useCallback(() => applyBoolean(
|
|
458
|
-
const excludeShapes = React.useCallback(() => applyBoolean(
|
|
573
|
+
const unionShapes = React.useCallback(() => applyBoolean('union'), [applyBoolean]);
|
|
574
|
+
const subtractShapes = React.useCallback(() => applyBoolean('difference'), [applyBoolean]);
|
|
575
|
+
const intersectShapes = React.useCallback(() => applyBoolean('intersection'), [applyBoolean]);
|
|
576
|
+
const excludeShapes = React.useCallback(() => applyBoolean('exclusion'), [applyBoolean]);
|
|
459
577
|
const outlineStroke = React.useCallback(() => {
|
|
460
|
-
if (!selId || !selShape)
|
|
578
|
+
if (!selId || !selShape) {
|
|
461
579
|
return;
|
|
580
|
+
}
|
|
462
581
|
const result = vectorBooleanOps.flattenToOutline(selShape);
|
|
463
582
|
const next = shapes.map((s) => (s.id === selId ? result : s));
|
|
464
583
|
snap(next);
|
|
@@ -470,7 +589,7 @@ function useVectorEditor({ artW, artH, onSaveToLibrary }) {
|
|
|
470
589
|
try {
|
|
471
590
|
const imported = vectorEditorImport.parseSVGToShapes(raw);
|
|
472
591
|
if (imported.length === 0) {
|
|
473
|
-
|
|
592
|
+
console.warn('[VectorEditor] No supported shapes found in SVG.');
|
|
474
593
|
return;
|
|
475
594
|
}
|
|
476
595
|
const next = [...shapes, ...imported];
|
|
@@ -479,10 +598,12 @@ function useVectorEditor({ artW, artH, onSaveToLibrary }) {
|
|
|
479
598
|
setDlgSvg(false);
|
|
480
599
|
}
|
|
481
600
|
catch (e) {
|
|
482
|
-
|
|
601
|
+
console.warn('[VectorEditor] SVG parse error:', e instanceof Error ? e.message : 'Failed to parse SVG.');
|
|
483
602
|
}
|
|
484
603
|
}, [shapes, snap]);
|
|
485
|
-
const openFile = React.useCallback(async (file) => {
|
|
604
|
+
const openFile = React.useCallback(async (file) => {
|
|
605
|
+
importSVGString(await file.text());
|
|
606
|
+
}, [importSVGString]);
|
|
486
607
|
/* ── new / reset ── */
|
|
487
608
|
const newCanvas = React.useCallback(() => {
|
|
488
609
|
snap([]);
|
|
@@ -494,17 +615,19 @@ function useVectorEditor({ artW, artH, onSaveToLibrary }) {
|
|
|
494
615
|
}, [snap]);
|
|
495
616
|
/* ── save to library ── */
|
|
496
617
|
const saveToLibrary = React.useCallback(() => {
|
|
497
|
-
if (!onSaveToLibrary)
|
|
618
|
+
if (!onSaveToLibrary) {
|
|
498
619
|
return;
|
|
620
|
+
}
|
|
499
621
|
const svg = vectorEditorExport.buildSVGString(shapes, artW, artH);
|
|
500
|
-
const blob = new Blob([svg], { type:
|
|
622
|
+
const blob = new Blob([svg], { type: 'image/svg+xml' });
|
|
501
623
|
const reader = new FileReader();
|
|
502
624
|
reader.onload = () => {
|
|
503
|
-
const defaultName =
|
|
504
|
-
const name = window.prompt(
|
|
505
|
-
if (!name || !name.trim())
|
|
625
|
+
const defaultName = 'drawing.svg';
|
|
626
|
+
const name = window.prompt('Save to library as:', defaultName);
|
|
627
|
+
if (!name || !name.trim()) {
|
|
506
628
|
return;
|
|
507
|
-
|
|
629
|
+
}
|
|
630
|
+
onSaveToLibrary(reader.result, name.trim(), 'image/svg+xml');
|
|
508
631
|
};
|
|
509
632
|
reader.readAsDataURL(blob);
|
|
510
633
|
}, [shapes, artW, artH, onSaveToLibrary]);
|
|
@@ -516,7 +639,7 @@ function useVectorEditor({ artW, artH, onSaveToLibrary }) {
|
|
|
516
639
|
const exportBMP = React.useCallback(() => vectorEditorExport.exportBMPFile(shapes, artW, artH), [shapes, artW, artH]);
|
|
517
640
|
/* ── tool switch helper (finishes pen) ── */
|
|
518
641
|
const switchTool = React.useCallback((newTool) => {
|
|
519
|
-
if (tool ===
|
|
642
|
+
if (tool === 'pen' && newTool !== 'pen' && pendingShape.current) {
|
|
520
643
|
snap(shapes);
|
|
521
644
|
pendingShape.current = null;
|
|
522
645
|
penPts.current = [];
|
|
@@ -527,34 +650,35 @@ function useVectorEditor({ artW, artH, onSaveToLibrary }) {
|
|
|
527
650
|
React.useEffect(() => {
|
|
528
651
|
const h = (e) => {
|
|
529
652
|
const t = e.target;
|
|
530
|
-
if (t.tagName ===
|
|
653
|
+
if (t.tagName === 'INPUT' || t.tagName === 'TEXTAREA') {
|
|
531
654
|
return;
|
|
532
|
-
|
|
655
|
+
}
|
|
656
|
+
if (e.ctrlKey && e.key === 'z') {
|
|
533
657
|
e.preventDefault();
|
|
534
658
|
undo();
|
|
535
659
|
return;
|
|
536
660
|
}
|
|
537
|
-
if (e.ctrlKey && (e.key ===
|
|
661
|
+
if (e.ctrlKey && (e.key === 'y' || (e.shiftKey && e.key === 'Z'))) {
|
|
538
662
|
e.preventDefault();
|
|
539
663
|
redo();
|
|
540
664
|
return;
|
|
541
665
|
}
|
|
542
|
-
if (e.ctrlKey && e.key ===
|
|
666
|
+
if (e.ctrlKey && e.key === 'c') {
|
|
543
667
|
e.preventDefault();
|
|
544
668
|
copyShape();
|
|
545
669
|
return;
|
|
546
670
|
}
|
|
547
|
-
if (e.ctrlKey && e.key ===
|
|
671
|
+
if (e.ctrlKey && e.key === 'v') {
|
|
548
672
|
e.preventDefault();
|
|
549
673
|
pasteShape();
|
|
550
674
|
return;
|
|
551
675
|
}
|
|
552
|
-
if (e.ctrlKey && e.key ===
|
|
676
|
+
if (e.ctrlKey && e.key === 'd') {
|
|
553
677
|
e.preventDefault();
|
|
554
678
|
duplicateShape();
|
|
555
679
|
return;
|
|
556
680
|
}
|
|
557
|
-
if (e.key ===
|
|
681
|
+
if (e.key === 'Escape') {
|
|
558
682
|
if (pendingShape.current) {
|
|
559
683
|
setShapes((prev) => prev.filter((s) => s.id !== pendingShape.current.id));
|
|
560
684
|
pendingShape.current = null;
|
|
@@ -567,45 +691,111 @@ function useVectorEditor({ artW, artH, onSaveToLibrary }) {
|
|
|
567
691
|
return;
|
|
568
692
|
}
|
|
569
693
|
const km = {
|
|
570
|
-
v:
|
|
571
|
-
|
|
694
|
+
v: 'pointer',
|
|
695
|
+
r: 'rect',
|
|
696
|
+
u: 'roundrect',
|
|
697
|
+
c: 'ellipse',
|
|
698
|
+
l: 'line',
|
|
699
|
+
a: 'arrow',
|
|
700
|
+
g: 'polygon',
|
|
701
|
+
s: 'star',
|
|
702
|
+
p: 'pen',
|
|
703
|
+
t: 'text',
|
|
572
704
|
};
|
|
573
705
|
if (km[e.key.toLowerCase()] && !e.ctrlKey && !e.altKey) {
|
|
574
706
|
setTool(km[e.key.toLowerCase()]);
|
|
575
707
|
return;
|
|
576
708
|
}
|
|
577
|
-
if (e.key ===
|
|
709
|
+
if (e.key === 'Delete' || e.key === 'Backspace') {
|
|
578
710
|
deleteShape();
|
|
711
|
+
}
|
|
579
712
|
};
|
|
580
|
-
window.addEventListener(
|
|
581
|
-
return () => window.removeEventListener(
|
|
713
|
+
window.addEventListener('keydown', h);
|
|
714
|
+
return () => window.removeEventListener('keydown', h);
|
|
582
715
|
}, [undo, redo, deleteShape, copyShape, pasteShape, duplicateShape]);
|
|
583
716
|
/* ── return ── */
|
|
584
717
|
return {
|
|
585
718
|
// state
|
|
586
|
-
shapes,
|
|
587
|
-
|
|
588
|
-
|
|
719
|
+
shapes,
|
|
720
|
+
selId,
|
|
721
|
+
tool,
|
|
722
|
+
fillCol,
|
|
723
|
+
strokeCol,
|
|
724
|
+
strokeW,
|
|
725
|
+
fontSize,
|
|
726
|
+
fontFamily,
|
|
727
|
+
shapeOpacity,
|
|
728
|
+
cornerRadius,
|
|
729
|
+
polygonSides,
|
|
730
|
+
starPoints2,
|
|
731
|
+
starInnerRatio,
|
|
732
|
+
zoom,
|
|
733
|
+
px,
|
|
734
|
+
py,
|
|
735
|
+
dlgSvg,
|
|
736
|
+
svgText,
|
|
737
|
+
snapGrid,
|
|
738
|
+
gridSize,
|
|
739
|
+
hasClipboard,
|
|
589
740
|
boolSecondShape,
|
|
590
741
|
// derived
|
|
591
742
|
selShape,
|
|
592
743
|
// setters
|
|
593
|
-
setTool,
|
|
594
|
-
|
|
595
|
-
|
|
744
|
+
setTool,
|
|
745
|
+
setFillCol,
|
|
746
|
+
setStrokeCol,
|
|
747
|
+
setStrokeW,
|
|
748
|
+
setFontSize,
|
|
749
|
+
setFontFamily,
|
|
750
|
+
setShapeOpacity,
|
|
751
|
+
setCornerRadius,
|
|
752
|
+
setPolygonSides,
|
|
753
|
+
setStarPoints2,
|
|
754
|
+
setStarInnerRatio,
|
|
755
|
+
setZoom,
|
|
756
|
+
setDlgSvg,
|
|
757
|
+
setSvgText,
|
|
758
|
+
setSnapGrid,
|
|
759
|
+
setGridSize,
|
|
760
|
+
setSelId,
|
|
596
761
|
setBoolSecondShape,
|
|
597
762
|
// refs
|
|
598
|
-
boxRef,
|
|
763
|
+
boxRef,
|
|
764
|
+
fInp,
|
|
599
765
|
// mouse handlers
|
|
600
|
-
onDown,
|
|
766
|
+
onDown,
|
|
767
|
+
onMove,
|
|
768
|
+
onUp,
|
|
769
|
+
onWheel,
|
|
770
|
+
onDblClick,
|
|
601
771
|
// actions
|
|
602
|
-
undo,
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
772
|
+
undo,
|
|
773
|
+
redo,
|
|
774
|
+
deleteShape,
|
|
775
|
+
bringToFront,
|
|
776
|
+
sendToBack,
|
|
777
|
+
updateSel,
|
|
778
|
+
copyShape,
|
|
779
|
+
pasteShape,
|
|
780
|
+
duplicateShape,
|
|
781
|
+
flipH,
|
|
782
|
+
flipV,
|
|
783
|
+
alignShapes,
|
|
784
|
+
unionShapes,
|
|
785
|
+
subtractShapes,
|
|
786
|
+
intersectShapes,
|
|
787
|
+
excludeShapes,
|
|
788
|
+
outlineStroke,
|
|
789
|
+
importSVGString,
|
|
790
|
+
openFile,
|
|
791
|
+
newCanvas,
|
|
792
|
+
exportSVG,
|
|
793
|
+
exportPNG,
|
|
794
|
+
exportJPG,
|
|
795
|
+
exportWebP,
|
|
796
|
+
exportBMP,
|
|
797
|
+
switchTool,
|
|
798
|
+
saveToLibrary,
|
|
609
799
|
};
|
|
610
800
|
}
|
|
611
801
|
|