@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
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
var React = require('react');
|
|
4
4
|
var i18n = require('../core/i18n.js');
|
|
5
|
+
var photoEditorActions = require('./photoEditorActions.js');
|
|
5
6
|
var photoFilters = require('./photoFilters.js');
|
|
6
7
|
var photoOverlays = require('./photoOverlays.js');
|
|
7
|
-
var photoEditorActions = require('./photoEditorActions.js');
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* usePhotoEditor.ts — Custom hook encapsulating all PhotoEditor state & logic.
|
|
@@ -13,7 +13,7 @@ var photoEditorActions = require('./photoEditorActions.js');
|
|
|
13
13
|
* out of the god-component so that the main component file is pure composition.
|
|
14
14
|
*/
|
|
15
15
|
// ── Hook ──
|
|
16
|
-
function usePhotoEditor({ src, playerColor =
|
|
16
|
+
function usePhotoEditor({ src, playerColor = '#00aaff', onSave, onCancel, initialState, }) {
|
|
17
17
|
const { t: _t } = i18n.useNiceTranslation();
|
|
18
18
|
const t = (key, def) => _t(key, def);
|
|
19
19
|
// ── State ──
|
|
@@ -21,12 +21,12 @@ function usePhotoEditor({ src, playerColor = "#00aaff", onSave, onCancel, initia
|
|
|
21
21
|
const [image, setImage] = React.useState(null);
|
|
22
22
|
const [loading, setLoading] = React.useState(true);
|
|
23
23
|
// Tabs
|
|
24
|
-
const [activeTab, setActiveTabRaw] = React.useState(
|
|
24
|
+
const [activeTab, setActiveTabRaw] = React.useState('filters');
|
|
25
25
|
const [cropMode, setCropMode] = React.useState(false);
|
|
26
26
|
// Filter
|
|
27
|
-
const [selectedFilter, setSelectedFilter] = React.useState(
|
|
27
|
+
const [selectedFilter, setSelectedFilter] = React.useState('none');
|
|
28
28
|
const [filterIntensity, setFilterIntensity] = React.useState(1);
|
|
29
|
-
const [filterCategory, setFilterCategory] = React.useState(
|
|
29
|
+
const [filterCategory, setFilterCategory] = React.useState('all');
|
|
30
30
|
const [filterParams] = React.useState({});
|
|
31
31
|
// Adjustments
|
|
32
32
|
const [adjustments, setAdjustments] = React.useState({ ...photoFilters.DEFAULT_ADJUSTMENTS });
|
|
@@ -53,22 +53,22 @@ function usePhotoEditor({ src, playerColor = "#00aaff", onSave, onCancel, initia
|
|
|
53
53
|
// Sticker / emoji
|
|
54
54
|
const [emojiCat, setEmojiCat] = React.useState(photoOverlays.EMOJI_CATALOG[0].id);
|
|
55
55
|
// Text overlay
|
|
56
|
-
const [textDraft, setTextDraft] = React.useState(
|
|
57
|
-
const [textColor, setTextColor] = React.useState(
|
|
56
|
+
const [textDraft, setTextDraft] = React.useState('Tekst');
|
|
57
|
+
const [textColor, setTextColor] = React.useState('#ffffff');
|
|
58
58
|
const [textBold, setTextBold] = React.useState(true);
|
|
59
59
|
const [textItalic, setTextItalic] = React.useState(false);
|
|
60
60
|
const [textOutline, setTextOutline] = React.useState(true);
|
|
61
61
|
const [textFontSize, setTextFontSize] = React.useState(36);
|
|
62
62
|
const [textBg, setTextBg] = React.useState(false);
|
|
63
63
|
// Shape
|
|
64
|
-
const [shapeStroke, setShapeStroke] = React.useState(
|
|
65
|
-
const [shapeFill, setShapeFill] = React.useState(
|
|
64
|
+
const [shapeStroke, setShapeStroke] = React.useState('#ffffff');
|
|
65
|
+
const [shapeFill, setShapeFill] = React.useState('');
|
|
66
66
|
const [shapeStrokeW, setShapeStrokeW] = React.useState(3);
|
|
67
67
|
// Frame
|
|
68
|
-
const [frameColor, setFrameColor] = React.useState(
|
|
68
|
+
const [frameColor, setFrameColor] = React.useState('#ffffff');
|
|
69
69
|
const [frameThick, setFrameThick] = React.useState(3);
|
|
70
70
|
// Drawing
|
|
71
|
-
const [drawColor, setDrawColor] = React.useState(
|
|
71
|
+
const [drawColor, setDrawColor] = React.useState('#ff0000');
|
|
72
72
|
const [drawWidth, setDrawWidth] = React.useState(4);
|
|
73
73
|
const [isDrawing, setIsDrawing] = React.useState(false);
|
|
74
74
|
const [livePoints, setLivePoints] = React.useState([]);
|
|
@@ -83,17 +83,18 @@ function usePhotoEditor({ src, playerColor = "#00aaff", onSave, onCancel, initia
|
|
|
83
83
|
const containerRef = React.useRef(null);
|
|
84
84
|
// ── Derived ──
|
|
85
85
|
const accent = playerColor;
|
|
86
|
-
const accentDim = playerColor +
|
|
87
|
-
const selectedOverlay = React.useMemo(() => { var _a; return (_a = overlays.find(o => o.id === selectedOverlayId)) !== null && _a !== void 0 ? _a : null; }, [overlays, selectedOverlayId]);
|
|
86
|
+
const accentDim = playerColor + '55';
|
|
87
|
+
const selectedOverlay = React.useMemo(() => { var _a; return (_a = overlays.find((o) => o.id === selectedOverlayId)) !== null && _a !== void 0 ? _a : null; }, [overlays, selectedOverlayId]);
|
|
88
88
|
// Tab setter (auto-toggle cropMode)
|
|
89
89
|
const setActiveTab = React.useCallback((tab) => {
|
|
90
90
|
setActiveTabRaw(tab);
|
|
91
|
-
setCropMode(tab ===
|
|
91
|
+
setCropMode(tab === 'crop');
|
|
92
92
|
}, []);
|
|
93
93
|
// ── History ──
|
|
94
94
|
const pushHistory = React.useCallback(() => {
|
|
95
|
-
if (suppressHistoryRef.current)
|
|
95
|
+
if (suppressHistoryRef.current) {
|
|
96
96
|
return;
|
|
97
|
+
}
|
|
97
98
|
const state = {
|
|
98
99
|
selectedFilter,
|
|
99
100
|
filterIntensity,
|
|
@@ -102,11 +103,21 @@ function usePhotoEditor({ src, playerColor = "#00aaff", onSave, onCancel, initia
|
|
|
102
103
|
flipH,
|
|
103
104
|
flipV,
|
|
104
105
|
cropRect: cropRect ? { ...cropRect } : null,
|
|
105
|
-
overlays: overlays.map(o => ({ ...o })),
|
|
106
|
+
overlays: overlays.map((o) => ({ ...o })),
|
|
106
107
|
};
|
|
107
|
-
setHistory(prev => [...prev.slice(0, historyIdx + 1), state]);
|
|
108
|
-
setHistoryIdx(prev => prev + 1);
|
|
109
|
-
}, [
|
|
108
|
+
setHistory((prev) => [...prev.slice(0, historyIdx + 1), state]);
|
|
109
|
+
setHistoryIdx((prev) => prev + 1);
|
|
110
|
+
}, [
|
|
111
|
+
selectedFilter,
|
|
112
|
+
filterIntensity,
|
|
113
|
+
adjustments,
|
|
114
|
+
rotation,
|
|
115
|
+
flipH,
|
|
116
|
+
flipV,
|
|
117
|
+
cropRect,
|
|
118
|
+
overlays,
|
|
119
|
+
historyIdx,
|
|
120
|
+
]);
|
|
110
121
|
const restoreState = React.useCallback((s) => {
|
|
111
122
|
suppressHistoryRef.current = true;
|
|
112
123
|
setSelectedFilter(s.selectedFilter);
|
|
@@ -116,9 +127,11 @@ function usePhotoEditor({ src, playerColor = "#00aaff", onSave, onCancel, initia
|
|
|
116
127
|
setFlipH(s.flipH);
|
|
117
128
|
setFlipV(s.flipV);
|
|
118
129
|
setCropRect(s.cropRect ? { ...s.cropRect } : null);
|
|
119
|
-
setOverlays(s.overlays.map(o => ({ ...o })));
|
|
130
|
+
setOverlays(s.overlays.map((o) => ({ ...o })));
|
|
120
131
|
setSelectedOverlayId(null);
|
|
121
|
-
setTimeout(() => {
|
|
132
|
+
setTimeout(() => {
|
|
133
|
+
suppressHistoryRef.current = false;
|
|
134
|
+
}, 50);
|
|
122
135
|
}, []);
|
|
123
136
|
const undo = React.useCallback(() => {
|
|
124
137
|
if (historyIdx > 0) {
|
|
@@ -147,12 +160,13 @@ function usePhotoEditor({ src, playerColor = "#00aaff", onSave, onCancel, initia
|
|
|
147
160
|
img.src = URL.createObjectURL(src);
|
|
148
161
|
}
|
|
149
162
|
else {
|
|
150
|
-
img.crossOrigin =
|
|
163
|
+
img.crossOrigin = 'anonymous';
|
|
151
164
|
img.src = src;
|
|
152
165
|
}
|
|
153
166
|
return () => {
|
|
154
|
-
if (img.src.startsWith(
|
|
167
|
+
if (img.src.startsWith('blob:')) {
|
|
155
168
|
URL.revokeObjectURL(img.src);
|
|
169
|
+
}
|
|
156
170
|
};
|
|
157
171
|
}, [src]);
|
|
158
172
|
// Push initial history once image loads
|
|
@@ -168,11 +182,15 @@ function usePhotoEditor({ src, playerColor = "#00aaff", onSave, onCancel, initia
|
|
|
168
182
|
setRotation(prev.rotation);
|
|
169
183
|
setFlipH(prev.flipH);
|
|
170
184
|
setFlipV(prev.flipV);
|
|
171
|
-
if (prev.cropRect)
|
|
185
|
+
if (prev.cropRect) {
|
|
172
186
|
setCropRect(prev.cropRect);
|
|
173
|
-
|
|
187
|
+
}
|
|
188
|
+
if (prev.overlays) {
|
|
174
189
|
setOverlays(prev.overlays);
|
|
175
|
-
|
|
190
|
+
}
|
|
191
|
+
setTimeout(() => {
|
|
192
|
+
suppressHistoryRef.current = false;
|
|
193
|
+
}, 50);
|
|
176
194
|
}
|
|
177
195
|
}
|
|
178
196
|
pushHistory();
|
|
@@ -181,30 +199,52 @@ function usePhotoEditor({ src, playerColor = "#00aaff", onSave, onCancel, initia
|
|
|
181
199
|
}, [image]);
|
|
182
200
|
// ── Render main canvas ──
|
|
183
201
|
const renderMain = React.useCallback(() => {
|
|
184
|
-
if (!image || !mainCanvasRef.current)
|
|
202
|
+
if (!image || !mainCanvasRef.current) {
|
|
185
203
|
return;
|
|
204
|
+
}
|
|
186
205
|
photoFilters.renderToCanvas(mainCanvasRef.current, image, selectedFilter, { ...filterParams, intensity: filterIntensity }, adjustments, cropMode ? null : cropRect, rotation, flipH, flipV);
|
|
187
206
|
if (overlays.length > 0 || livePoints.length > 1) {
|
|
188
|
-
const ctx = mainCanvasRef.current.getContext(
|
|
207
|
+
const ctx = mainCanvasRef.current.getContext('2d');
|
|
189
208
|
if (ctx) {
|
|
190
209
|
const cw = mainCanvasRef.current.width;
|
|
191
210
|
const ch = mainCanvasRef.current.height;
|
|
192
|
-
if (overlays.length > 0)
|
|
211
|
+
if (overlays.length > 0) {
|
|
193
212
|
photoOverlays.renderAllOverlays(ctx, overlays, cw, ch);
|
|
194
|
-
|
|
213
|
+
}
|
|
214
|
+
if (livePoints.length > 1) {
|
|
195
215
|
photoOverlays.renderLiveStroke(ctx, livePoints, drawColor, drawWidth, cw, ch);
|
|
216
|
+
}
|
|
196
217
|
}
|
|
197
218
|
}
|
|
198
|
-
}, [
|
|
199
|
-
|
|
219
|
+
}, [
|
|
220
|
+
image,
|
|
221
|
+
selectedFilter,
|
|
222
|
+
filterParams,
|
|
223
|
+
filterIntensity,
|
|
224
|
+
adjustments,
|
|
225
|
+
cropRect,
|
|
226
|
+
cropMode,
|
|
227
|
+
rotation,
|
|
228
|
+
flipH,
|
|
229
|
+
flipV,
|
|
230
|
+
overlays,
|
|
231
|
+
livePoints,
|
|
232
|
+
drawColor,
|
|
233
|
+
drawWidth,
|
|
234
|
+
]);
|
|
235
|
+
React.useEffect(() => {
|
|
236
|
+
renderMain();
|
|
237
|
+
}, [renderMain]);
|
|
200
238
|
// Render compare canvas (original)
|
|
201
239
|
React.useEffect(() => {
|
|
202
|
-
if (!image || !compareCanvasRef.current || !showCompare)
|
|
240
|
+
if (!image || !compareCanvasRef.current || !showCompare) {
|
|
203
241
|
return;
|
|
242
|
+
}
|
|
204
243
|
const canvas = compareCanvasRef.current;
|
|
205
|
-
const ctx = canvas.getContext(
|
|
206
|
-
if (!ctx)
|
|
244
|
+
const ctx = canvas.getContext('2d');
|
|
245
|
+
if (!ctx) {
|
|
207
246
|
return;
|
|
247
|
+
}
|
|
208
248
|
const crop = cropRect !== null && cropRect !== void 0 ? cropRect : { x: 0, y: 0, w: image.naturalWidth, h: image.naturalHeight };
|
|
209
249
|
canvas.width = crop.w;
|
|
210
250
|
canvas.height = crop.h;
|
|
@@ -212,24 +252,27 @@ function usePhotoEditor({ src, playerColor = "#00aaff", onSave, onCancel, initia
|
|
|
212
252
|
}, [image, showCompare, cropRect]);
|
|
213
253
|
// ── Filter thumbnails ──
|
|
214
254
|
const filteredList = React.useMemo(() => {
|
|
215
|
-
if (filterCategory ===
|
|
255
|
+
if (filterCategory === 'all') {
|
|
216
256
|
return photoFilters.PHOTO_FILTERS;
|
|
217
|
-
|
|
257
|
+
}
|
|
258
|
+
return photoFilters.PHOTO_FILTERS.filter((f) => f.category === filterCategory || f.id === 'none');
|
|
218
259
|
}, [filterCategory]);
|
|
219
260
|
const generateThumbnail = React.useCallback((canvas, filter) => {
|
|
220
|
-
if (!image)
|
|
261
|
+
if (!image) {
|
|
221
262
|
return;
|
|
263
|
+
}
|
|
222
264
|
const size = 64;
|
|
223
265
|
canvas.width = size;
|
|
224
266
|
canvas.height = size;
|
|
225
|
-
const ctx = canvas.getContext(
|
|
226
|
-
if (!ctx)
|
|
267
|
+
const ctx = canvas.getContext('2d', { willReadFrequently: true });
|
|
268
|
+
if (!ctx) {
|
|
227
269
|
return;
|
|
270
|
+
}
|
|
228
271
|
const s = Math.min(image.naturalWidth, image.naturalHeight);
|
|
229
272
|
const sx = (image.naturalWidth - s) / 2;
|
|
230
273
|
const sy = (image.naturalHeight - s) / 2;
|
|
231
274
|
ctx.drawImage(image, sx, sy, s, s, 0, 0, size, size);
|
|
232
|
-
if (filter.id !==
|
|
275
|
+
if (filter.id !== 'none') {
|
|
233
276
|
const imgData = ctx.getImageData(0, 0, size, size);
|
|
234
277
|
const filtered = filter.apply(imgData, { intensity: 1 });
|
|
235
278
|
ctx.putImageData(filtered, 0, 0);
|
|
@@ -237,8 +280,9 @@ function usePhotoEditor({ src, playerColor = "#00aaff", onSave, onCancel, initia
|
|
|
237
280
|
}, [image]);
|
|
238
281
|
// ── Crop interaction ──
|
|
239
282
|
const getCanvasScale = React.useCallback(() => {
|
|
240
|
-
if (!mainCanvasRef.current || !containerRef.current || !image)
|
|
283
|
+
if (!mainCanvasRef.current || !containerRef.current || !image) {
|
|
241
284
|
return { sx: 1, sy: 1, ox: 0, oy: 0 };
|
|
285
|
+
}
|
|
242
286
|
const rect = mainCanvasRef.current.getBoundingClientRect();
|
|
243
287
|
const cw = mainCanvasRef.current.width;
|
|
244
288
|
const ch = mainCanvasRef.current.height;
|
|
@@ -251,31 +295,32 @@ function usePhotoEditor({ src, playerColor = "#00aaff", onSave, onCancel, initia
|
|
|
251
295
|
setCropStart({ mx: e.clientX, my: e.clientY, rect: { ...cropRect } });
|
|
252
296
|
}, [cropRect]);
|
|
253
297
|
React.useEffect(() => {
|
|
254
|
-
if (!cropDragging || !cropStart || !cropRect || !image)
|
|
298
|
+
if (!cropDragging || !cropStart || !cropRect || !image) {
|
|
255
299
|
return;
|
|
300
|
+
}
|
|
256
301
|
const handleMove = (e) => {
|
|
257
302
|
const scale = getCanvasScale();
|
|
258
303
|
const dx = (e.clientX - cropStart.mx) * scale.sx;
|
|
259
304
|
const dy = (e.clientY - cropStart.my) * scale.sy;
|
|
260
305
|
const r = { ...cropStart.rect };
|
|
261
306
|
const minSize = 20;
|
|
262
|
-
if (cropDragging ===
|
|
307
|
+
if (cropDragging === 'move') {
|
|
263
308
|
r.x = Math.max(0, Math.min(image.naturalWidth - r.w, r.x + dx));
|
|
264
309
|
r.y = Math.max(0, Math.min(image.naturalHeight - r.h, r.y + dy));
|
|
265
310
|
}
|
|
266
311
|
else {
|
|
267
|
-
if (cropDragging.includes(
|
|
312
|
+
if (cropDragging.includes('w')) {
|
|
268
313
|
r.x += dx;
|
|
269
314
|
r.w -= dx;
|
|
270
315
|
}
|
|
271
|
-
if (cropDragging.includes(
|
|
316
|
+
if (cropDragging.includes('e')) {
|
|
272
317
|
r.w += dx;
|
|
273
318
|
}
|
|
274
|
-
if (cropDragging.includes(
|
|
319
|
+
if (cropDragging.includes('n')) {
|
|
275
320
|
r.y += dy;
|
|
276
321
|
r.h -= dy;
|
|
277
322
|
}
|
|
278
|
-
if (cropDragging.includes(
|
|
323
|
+
if (cropDragging.includes('s')) {
|
|
279
324
|
r.h += dy;
|
|
280
325
|
}
|
|
281
326
|
if (r.w < minSize) {
|
|
@@ -285,7 +330,7 @@ function usePhotoEditor({ src, playerColor = "#00aaff", onSave, onCancel, initia
|
|
|
285
330
|
r.h = minSize;
|
|
286
331
|
}
|
|
287
332
|
if (cropAspect) {
|
|
288
|
-
if (cropDragging.includes(
|
|
333
|
+
if (cropDragging.includes('w') || cropDragging.includes('e')) {
|
|
289
334
|
r.h = r.w / cropAspect;
|
|
290
335
|
}
|
|
291
336
|
else {
|
|
@@ -305,82 +350,87 @@ function usePhotoEditor({ src, playerColor = "#00aaff", onSave, onCancel, initia
|
|
|
305
350
|
setCropStart(null);
|
|
306
351
|
pushHistory();
|
|
307
352
|
};
|
|
308
|
-
window.addEventListener(
|
|
309
|
-
window.addEventListener(
|
|
353
|
+
window.addEventListener('mousemove', handleMove);
|
|
354
|
+
window.addEventListener('mouseup', handleUp);
|
|
310
355
|
return () => {
|
|
311
|
-
window.removeEventListener(
|
|
312
|
-
window.removeEventListener(
|
|
356
|
+
window.removeEventListener('mousemove', handleMove);
|
|
357
|
+
window.removeEventListener('mouseup', handleUp);
|
|
313
358
|
};
|
|
314
359
|
}, [cropDragging, cropStart, cropRect, image, cropAspect, getCanvasScale, pushHistory]);
|
|
315
360
|
// Compare slider drag
|
|
316
361
|
React.useEffect(() => {
|
|
317
|
-
if (!compareDragging)
|
|
362
|
+
if (!compareDragging) {
|
|
318
363
|
return;
|
|
364
|
+
}
|
|
319
365
|
const handleMove = (e) => {
|
|
320
|
-
if (!containerRef.current)
|
|
366
|
+
if (!containerRef.current) {
|
|
321
367
|
return;
|
|
368
|
+
}
|
|
322
369
|
const rect = containerRef.current.getBoundingClientRect();
|
|
323
370
|
const pct = Math.max(0, Math.min(100, ((e.clientX - rect.left) / rect.width) * 100));
|
|
324
371
|
setComparePosition(pct);
|
|
325
372
|
};
|
|
326
373
|
const handleUp = () => setCompareDragging(false);
|
|
327
|
-
window.addEventListener(
|
|
328
|
-
window.addEventListener(
|
|
374
|
+
window.addEventListener('mousemove', handleMove);
|
|
375
|
+
window.addEventListener('mouseup', handleUp);
|
|
329
376
|
return () => {
|
|
330
|
-
window.removeEventListener(
|
|
331
|
-
window.removeEventListener(
|
|
377
|
+
window.removeEventListener('mousemove', handleMove);
|
|
378
|
+
window.removeEventListener('mouseup', handleUp);
|
|
332
379
|
};
|
|
333
380
|
}, [compareDragging]);
|
|
334
381
|
// ── Keyboard shortcuts ──
|
|
335
382
|
React.useEffect(() => {
|
|
336
383
|
const handleKey = (e) => {
|
|
337
|
-
if (e.ctrlKey && e.key ===
|
|
384
|
+
if (e.ctrlKey && e.key === 'z') {
|
|
338
385
|
e.preventDefault();
|
|
339
386
|
undo();
|
|
340
387
|
}
|
|
341
|
-
if (e.ctrlKey && e.key ===
|
|
388
|
+
if (e.ctrlKey && e.key === 'y') {
|
|
342
389
|
e.preventDefault();
|
|
343
390
|
redo();
|
|
344
391
|
}
|
|
345
392
|
};
|
|
346
|
-
window.addEventListener(
|
|
347
|
-
return () => window.removeEventListener(
|
|
393
|
+
window.addEventListener('keydown', handleKey);
|
|
394
|
+
return () => window.removeEventListener('keydown', handleKey);
|
|
348
395
|
}, [undo, redo]);
|
|
349
396
|
// ── Adjustments ──
|
|
350
397
|
const handleAdjChange = React.useCallback((key, value) => {
|
|
351
|
-
setAdjustments(prev => ({ ...prev, [key]: value }));
|
|
398
|
+
setAdjustments((prev) => ({ ...prev, [key]: value }));
|
|
352
399
|
}, []);
|
|
353
400
|
const handleAdjChangeEnd = React.useCallback(() => pushHistory(), [pushHistory]);
|
|
354
401
|
// ── Overlay helpers ──
|
|
355
402
|
const addOverlay = React.useCallback((ov) => {
|
|
356
|
-
setOverlays(prev => [...prev, ov]);
|
|
403
|
+
setOverlays((prev) => [...prev, ov]);
|
|
357
404
|
setSelectedOverlayId(ov.id);
|
|
358
405
|
setTimeout(() => pushHistory(), 30);
|
|
359
406
|
}, [pushHistory]);
|
|
360
407
|
const updateOverlay = React.useCallback((id, patch) => {
|
|
361
|
-
setOverlays(prev => prev.map(o => o.id === id ? { ...o, ...patch } : o));
|
|
408
|
+
setOverlays((prev) => prev.map((o) => (o.id === id ? { ...o, ...patch } : o)));
|
|
362
409
|
}, []);
|
|
363
410
|
const deleteOverlay = React.useCallback((id) => {
|
|
364
|
-
setOverlays(prev => prev.filter(o => o.id !== id));
|
|
365
|
-
if (selectedOverlayId === id)
|
|
411
|
+
setOverlays((prev) => prev.filter((o) => o.id !== id));
|
|
412
|
+
if (selectedOverlayId === id) {
|
|
366
413
|
setSelectedOverlayId(null);
|
|
414
|
+
}
|
|
367
415
|
setTimeout(() => pushHistory(), 30);
|
|
368
416
|
}, [selectedOverlayId, pushHistory]);
|
|
369
417
|
const moveOverlayForward = React.useCallback((id) => {
|
|
370
|
-
setOverlays(prev => {
|
|
371
|
-
const idx = prev.findIndex(o => o.id === id);
|
|
372
|
-
if (idx < 0 || idx >= prev.length - 1)
|
|
418
|
+
setOverlays((prev) => {
|
|
419
|
+
const idx = prev.findIndex((o) => o.id === id);
|
|
420
|
+
if (idx < 0 || idx >= prev.length - 1) {
|
|
373
421
|
return prev;
|
|
422
|
+
}
|
|
374
423
|
const copy = [...prev];
|
|
375
424
|
[copy[idx], copy[idx + 1]] = [copy[idx + 1], copy[idx]];
|
|
376
425
|
return copy;
|
|
377
426
|
});
|
|
378
427
|
}, []);
|
|
379
428
|
const moveOverlayBack = React.useCallback((id) => {
|
|
380
|
-
setOverlays(prev => {
|
|
381
|
-
const idx = prev.findIndex(o => o.id === id);
|
|
382
|
-
if (idx <= 0)
|
|
429
|
+
setOverlays((prev) => {
|
|
430
|
+
const idx = prev.findIndex((o) => o.id === id);
|
|
431
|
+
if (idx <= 0) {
|
|
383
432
|
return prev;
|
|
433
|
+
}
|
|
384
434
|
const copy = [...prev];
|
|
385
435
|
[copy[idx - 1], copy[idx]] = [copy[idx], copy[idx - 1]];
|
|
386
436
|
return copy;
|
|
@@ -388,8 +438,9 @@ function usePhotoEditor({ src, playerColor = "#00aaff", onSave, onCancel, initia
|
|
|
388
438
|
}, []);
|
|
389
439
|
// ── Canvas fraction from mouse event ──
|
|
390
440
|
const getCanvasFraction = React.useCallback((e) => {
|
|
391
|
-
if (!mainCanvasRef.current)
|
|
441
|
+
if (!mainCanvasRef.current) {
|
|
392
442
|
return { fx: 0.5, fy: 0.5 };
|
|
443
|
+
}
|
|
393
444
|
const rect = mainCanvasRef.current.getBoundingClientRect();
|
|
394
445
|
return {
|
|
395
446
|
fx: Math.max(0, Math.min(1, (e.clientX - rect.left) / rect.width)),
|
|
@@ -399,10 +450,11 @@ function usePhotoEditor({ src, playerColor = "#00aaff", onSave, onCancel, initia
|
|
|
399
450
|
// ── Canvas mouse handlers ──
|
|
400
451
|
const handleCanvasMouseDown = React.useCallback((e) => {
|
|
401
452
|
var _a, _b, _c, _d;
|
|
402
|
-
if (cropMode)
|
|
453
|
+
if (cropMode) {
|
|
403
454
|
return;
|
|
455
|
+
}
|
|
404
456
|
const { fx, fy } = getCanvasFraction(e);
|
|
405
|
-
if (activeTab ===
|
|
457
|
+
if (activeTab === 'draw') {
|
|
406
458
|
e.preventDefault();
|
|
407
459
|
setIsDrawing(true);
|
|
408
460
|
setLivePoints([[fx, fy]]);
|
|
@@ -424,7 +476,7 @@ function usePhotoEditor({ src, playerColor = "#00aaff", onSave, onCancel, initia
|
|
|
424
476
|
const handleCanvasMouseMove = React.useCallback((e) => {
|
|
425
477
|
const { fx, fy } = getCanvasFraction(e);
|
|
426
478
|
if (isDrawing) {
|
|
427
|
-
setLivePoints(prev => [...prev, [fx, fy]]);
|
|
479
|
+
setLivePoints((prev) => [...prev, [fx, fy]]);
|
|
428
480
|
return;
|
|
429
481
|
}
|
|
430
482
|
if (overlayDragging && overlayDragStart && selectedOverlayId) {
|
|
@@ -435,19 +487,31 @@ function usePhotoEditor({ src, playerColor = "#00aaff", onSave, onCancel, initia
|
|
|
435
487
|
y: Math.max(0, Math.min(1, overlayDragStart.oy + dy)),
|
|
436
488
|
});
|
|
437
489
|
}
|
|
438
|
-
}, [
|
|
490
|
+
}, [
|
|
491
|
+
getCanvasFraction,
|
|
492
|
+
isDrawing,
|
|
493
|
+
overlayDragging,
|
|
494
|
+
overlayDragStart,
|
|
495
|
+
selectedOverlayId,
|
|
496
|
+
updateOverlay,
|
|
497
|
+
]);
|
|
439
498
|
const handleCanvasMouseUp = React.useCallback(() => {
|
|
440
499
|
if (isDrawing && livePoints.length > 1) {
|
|
441
|
-
const stroke = {
|
|
500
|
+
const stroke = {
|
|
501
|
+
points: [...livePoints],
|
|
502
|
+
color: drawColor,
|
|
503
|
+
width: drawWidth,
|
|
504
|
+
opacity: 1,
|
|
505
|
+
};
|
|
442
506
|
if (!drawingOverlayRef.current) {
|
|
443
507
|
const dOv = photoOverlays.createDrawingOverlay();
|
|
444
508
|
dOv.strokes.push(stroke);
|
|
445
509
|
drawingOverlayRef.current = dOv;
|
|
446
|
-
setOverlays(prev => [...prev, dOv]);
|
|
510
|
+
setOverlays((prev) => [...prev, dOv]);
|
|
447
511
|
}
|
|
448
512
|
else {
|
|
449
513
|
const id = drawingOverlayRef.current.id;
|
|
450
|
-
setOverlays(prev => prev.map(o => o.id === id && o.type ===
|
|
514
|
+
setOverlays((prev) => prev.map((o) => o.id === id && o.type === 'drawing'
|
|
451
515
|
? { ...o, strokes: [...o.strokes, stroke] }
|
|
452
516
|
: o));
|
|
453
517
|
}
|
|
@@ -466,21 +530,46 @@ function usePhotoEditor({ src, playerColor = "#00aaff", onSave, onCancel, initia
|
|
|
466
530
|
}, [isDrawing, livePoints, drawColor, drawWidth, overlayDragging, pushHistory]);
|
|
467
531
|
// ── Actions ──
|
|
468
532
|
const buildExportParams = React.useCallback(() => {
|
|
469
|
-
if (!image)
|
|
533
|
+
if (!image) {
|
|
470
534
|
return null;
|
|
471
|
-
|
|
472
|
-
|
|
535
|
+
}
|
|
536
|
+
return {
|
|
537
|
+
image,
|
|
538
|
+
selectedFilter,
|
|
539
|
+
filterParams,
|
|
540
|
+
filterIntensity,
|
|
541
|
+
adjustments,
|
|
542
|
+
cropRect,
|
|
543
|
+
rotation,
|
|
544
|
+
flipH,
|
|
545
|
+
flipV,
|
|
546
|
+
overlays,
|
|
547
|
+
};
|
|
548
|
+
}, [
|
|
549
|
+
image,
|
|
550
|
+
selectedFilter,
|
|
551
|
+
filterParams,
|
|
552
|
+
filterIntensity,
|
|
553
|
+
adjustments,
|
|
554
|
+
cropRect,
|
|
555
|
+
rotation,
|
|
556
|
+
flipH,
|
|
557
|
+
flipV,
|
|
558
|
+
overlays,
|
|
559
|
+
]);
|
|
473
560
|
const handleSave = React.useCallback(async () => {
|
|
474
|
-
if (!image || !mainCanvasRef.current)
|
|
561
|
+
if (!image || !mainCanvasRef.current) {
|
|
475
562
|
return;
|
|
476
|
-
|
|
563
|
+
}
|
|
564
|
+
const exportCanvas = document.createElement('canvas');
|
|
477
565
|
photoFilters.renderToCanvas(exportCanvas, image, selectedFilter, { ...filterParams, intensity: filterIntensity }, adjustments, cropRect, rotation, flipH, flipV);
|
|
478
566
|
if (overlays.length > 0) {
|
|
479
|
-
const ctx = exportCanvas.getContext(
|
|
480
|
-
if (ctx)
|
|
567
|
+
const ctx = exportCanvas.getContext('2d');
|
|
568
|
+
if (ctx) {
|
|
481
569
|
photoOverlays.renderAllOverlays(ctx, overlays, exportCanvas.width, exportCanvas.height);
|
|
570
|
+
}
|
|
482
571
|
}
|
|
483
|
-
const file = await photoFilters.canvasToFile(exportCanvas,
|
|
572
|
+
const file = await photoFilters.canvasToFile(exportCanvas, 'player-photo.jpg', 0.92);
|
|
484
573
|
const editorState = photoOverlays.serializeEditorState({
|
|
485
574
|
filter: selectedFilter,
|
|
486
575
|
filterIntensity,
|
|
@@ -492,9 +581,21 @@ function usePhotoEditor({ src, playerColor = "#00aaff", onSave, onCancel, initia
|
|
|
492
581
|
overlays,
|
|
493
582
|
});
|
|
494
583
|
onSave(file, editorState);
|
|
495
|
-
}, [
|
|
584
|
+
}, [
|
|
585
|
+
image,
|
|
586
|
+
selectedFilter,
|
|
587
|
+
filterParams,
|
|
588
|
+
filterIntensity,
|
|
589
|
+
adjustments,
|
|
590
|
+
cropRect,
|
|
591
|
+
rotation,
|
|
592
|
+
flipH,
|
|
593
|
+
flipV,
|
|
594
|
+
overlays,
|
|
595
|
+
onSave,
|
|
596
|
+
]);
|
|
496
597
|
const handleReset = React.useCallback(() => {
|
|
497
|
-
setSelectedFilter(
|
|
598
|
+
setSelectedFilter('none');
|
|
498
599
|
setFilterIntensity(1);
|
|
499
600
|
setAdjustments({ ...photoFilters.DEFAULT_ADJUSTMENTS });
|
|
500
601
|
setRotation(0);
|
|
@@ -511,25 +612,30 @@ function usePhotoEditor({ src, playerColor = "#00aaff", onSave, onCancel, initia
|
|
|
511
612
|
}, [image, pushHistory]);
|
|
512
613
|
const handleDownload = React.useCallback(async () => {
|
|
513
614
|
const p = buildExportParams();
|
|
514
|
-
if (!p)
|
|
615
|
+
if (!p) {
|
|
515
616
|
return;
|
|
617
|
+
}
|
|
516
618
|
const blob = await photoEditorActions.getExportBlob(p);
|
|
517
|
-
if (blob)
|
|
619
|
+
if (blob) {
|
|
518
620
|
photoEditorActions.handleDownloadBlob(blob);
|
|
621
|
+
}
|
|
519
622
|
}, [buildExportParams]);
|
|
520
623
|
const handleCopyToClipboard = React.useCallback(async () => {
|
|
521
624
|
const p = buildExportParams();
|
|
522
|
-
if (!p)
|
|
625
|
+
if (!p) {
|
|
523
626
|
return;
|
|
627
|
+
}
|
|
524
628
|
await photoEditorActions.handleCopyImageToClipboard(p);
|
|
525
629
|
}, [buildExportParams]);
|
|
526
630
|
const handleShareNative = React.useCallback(async () => {
|
|
527
631
|
const p = buildExportParams();
|
|
528
|
-
if (!p)
|
|
632
|
+
if (!p) {
|
|
529
633
|
return;
|
|
634
|
+
}
|
|
530
635
|
const blob = await photoEditorActions.getExportBlob(p);
|
|
531
|
-
if (blob)
|
|
636
|
+
if (blob) {
|
|
532
637
|
await photoEditorActions.handleNativeShare(blob);
|
|
638
|
+
}
|
|
533
639
|
}, [buildExportParams]);
|
|
534
640
|
// ── Return ──
|
|
535
641
|
return {
|