@nice2dev/ui-graphics 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +84 -0
- package/LICENSE +21 -0
- package/README.md +339 -0
- package/dist/cjs/animation/AnimatedPerson.js +153 -0
- package/dist/cjs/animation/AnimatedPerson.js.map +1 -0
- package/dist/cjs/animation/AnimationEditor.js +106 -0
- package/dist/cjs/animation/AnimationEditor.js.map +1 -0
- package/dist/cjs/animation/Audience.js +59 -0
- package/dist/cjs/animation/Audience.js.map +1 -0
- package/dist/cjs/animation/BodyRenderer.js +33 -0
- package/dist/cjs/animation/BodyRenderer.js.map +1 -0
- package/dist/cjs/animation/animationHelper.js +272 -0
- package/dist/cjs/animation/animationHelper.js.map +1 -0
- package/dist/cjs/animation/characterTypes.js +75 -0
- package/dist/cjs/animation/characterTypes.js.map +1 -0
- package/dist/cjs/animation/choreoDSL.js +190 -0
- package/dist/cjs/animation/choreoDSL.js.map +1 -0
- package/dist/cjs/animation/choreography.js +41 -0
- package/dist/cjs/animation/choreography.js.map +1 -0
- package/dist/cjs/animation/karaokeIntegration.js +98 -0
- package/dist/cjs/animation/karaokeIntegration.js.map +1 -0
- package/dist/cjs/animation/lottieExport.js +128 -0
- package/dist/cjs/animation/lottieExport.js.map +1 -0
- package/dist/cjs/animation/motionPath.js +196 -0
- package/dist/cjs/animation/motionPath.js.map +1 -0
- package/dist/cjs/animation/physics.js +201 -0
- package/dist/cjs/animation/physics.js.map +1 -0
- package/dist/cjs/animation/rig/RigPlayer.js +63 -0
- package/dist/cjs/animation/rig/RigPlayer.js.map +1 -0
- package/dist/cjs/animation/rig/RiggedBody.js +30 -0
- package/dist/cjs/animation/rig/RiggedBody.js.map +1 -0
- package/dist/cjs/animation/rig/choreoRigBridge.js +63 -0
- package/dist/cjs/animation/rig/choreoRigBridge.js.map +1 -0
- package/dist/cjs/animation/rig/ik.js +22 -0
- package/dist/cjs/animation/rig/ik.js.map +1 -0
- package/dist/cjs/animation/rig/poseOps.js +49 -0
- package/dist/cjs/animation/rig/poseOps.js.map +1 -0
- package/dist/cjs/animation/rig/presets.js +60 -0
- package/dist/cjs/animation/rig/presets.js.map +1 -0
- package/dist/cjs/animation/rig/rigMath.js +41 -0
- package/dist/cjs/animation/rig/rigMath.js.map +1 -0
- package/dist/cjs/animation/rig/rigTypes.js +44 -0
- package/dist/cjs/animation/rig/rigTypes.js.map +1 -0
- package/dist/cjs/animation/shapes/arms.js +15 -0
- package/dist/cjs/animation/shapes/arms.js.map +1 -0
- package/dist/cjs/animation/shapes/eyes.js +52 -0
- package/dist/cjs/animation/shapes/eyes.js.map +1 -0
- package/dist/cjs/animation/shapes/hair.js +55 -0
- package/dist/cjs/animation/shapes/hair.js.map +1 -0
- package/dist/cjs/animation/shapes/heads.js +62 -0
- package/dist/cjs/animation/shapes/heads.js.map +1 -0
- package/dist/cjs/animation/shapes/headwear.js +44 -0
- package/dist/cjs/animation/shapes/headwear.js.map +1 -0
- package/dist/cjs/animation/shapes/legs.js +15 -0
- package/dist/cjs/animation/shapes/legs.js.map +1 -0
- package/dist/cjs/animation/shapes/mouths.js +53 -0
- package/dist/cjs/animation/shapes/mouths.js.map +1 -0
- package/dist/cjs/animation/shapes/noses.js +31 -0
- package/dist/cjs/animation/shapes/noses.js.map +1 -0
- package/dist/cjs/animation/shapes/outfits.js +43 -0
- package/dist/cjs/animation/shapes/outfits.js.map +1 -0
- package/dist/cjs/animation/shapes/torsos.js +13 -0
- package/dist/cjs/animation/shapes/torsos.js.map +1 -0
- package/dist/cjs/animation/spineExport.js +132 -0
- package/dist/cjs/animation/spineExport.js.map +1 -0
- package/dist/cjs/core/LocalUI.js +54 -0
- package/dist/cjs/core/LocalUI.js.map +1 -0
- package/dist/cjs/core/collaboration.js +259 -0
- package/dist/cjs/core/collaboration.js.map +1 -0
- package/dist/cjs/core/colorBlindness.js +97 -0
- package/dist/cjs/core/colorBlindness.js.map +1 -0
- package/dist/cjs/core/dragDrop.js +168 -0
- package/dist/cjs/core/dragDrop.js.map +1 -0
- package/dist/cjs/core/fixes.js +185 -0
- package/dist/cjs/core/fixes.js.map +1 -0
- package/dist/cjs/core/gridGuides.js +245 -0
- package/dist/cjs/core/gridGuides.js.map +1 -0
- package/dist/cjs/core/historyVisual.js +124 -0
- package/dist/cjs/core/historyVisual.js.map +1 -0
- package/dist/cjs/core/i18n.js +16 -0
- package/dist/cjs/core/i18n.js.map +1 -0
- package/dist/cjs/core/integrations.js +261 -0
- package/dist/cjs/core/integrations.js.map +1 -0
- package/dist/cjs/core/minimap.js +142 -0
- package/dist/cjs/core/minimap.js.map +1 -0
- package/dist/cjs/core/plugins.js +129 -0
- package/dist/cjs/core/plugins.js.map +1 -0
- package/dist/cjs/core/rtl.js +102 -0
- package/dist/cjs/core/rtl.js.map +1 -0
- package/dist/cjs/core/shortcuts.js +205 -0
- package/dist/cjs/core/shortcuts.js.map +1 -0
- package/dist/cjs/core/theme.js +171 -0
- package/dist/cjs/core/theme.js.map +1 -0
- package/dist/cjs/font/NiceFontEditor.js +193 -0
- package/dist/cjs/font/NiceFontEditor.js.map +1 -0
- package/dist/cjs/game/GameAsset2dEditor.js +371 -0
- package/dist/cjs/game/GameAsset2dEditor.js.map +1 -0
- package/dist/cjs/game/GameAsset2dEditor.module.css.js +6 -0
- package/dist/cjs/game/GameAsset2dEditor.module.css.js.map +1 -0
- package/dist/cjs/game/gameAssetTypes.js +20 -0
- package/dist/cjs/game/gameAssetTypes.js.map +1 -0
- package/dist/cjs/game/gameAssetUtils.js +475 -0
- package/dist/cjs/game/gameAssetUtils.js.map +1 -0
- package/dist/cjs/game/useGameAssetEditor.js +761 -0
- package/dist/cjs/game/useGameAssetEditor.js.map +1 -0
- package/dist/cjs/icon/NiceIconEditor.js +249 -0
- package/dist/cjs/icon/NiceIconEditor.js.map +1 -0
- package/dist/cjs/index.js +264 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/nice2dev-ui/dist/index.js +32070 -0
- package/dist/cjs/nice2dev-ui/dist/index.js.map +1 -0
- package/dist/cjs/nice2dev-ui-graphics.css +1 -0
- package/dist/cjs/photo/FilterThumb.js +29 -0
- package/dist/cjs/photo/FilterThumb.js.map +1 -0
- package/dist/cjs/photo/PhotoEditor.js +20 -0
- package/dist/cjs/photo/PhotoEditor.js.map +1 -0
- package/dist/cjs/photo/PhotoEditor.module.css.js +6 -0
- package/dist/cjs/photo/PhotoEditor.module.css.js.map +1 -0
- package/dist/cjs/photo/PhotoEditorCanvas.js +59 -0
- package/dist/cjs/photo/PhotoEditorCanvas.js.map +1 -0
- package/dist/cjs/photo/PhotoEditorLeftPanel.js +174 -0
- package/dist/cjs/photo/PhotoEditorLeftPanel.js.map +1 -0
- package/dist/cjs/photo/PhotoEditorToolbar.js +15 -0
- package/dist/cjs/photo/PhotoEditorToolbar.js.map +1 -0
- package/dist/cjs/photo/photoEditorActions.js +80 -0
- package/dist/cjs/photo/photoEditorActions.js.map +1 -0
- package/dist/cjs/photo/photoEditorTypes.js +40 -0
- package/dist/cjs/photo/photoEditorTypes.js.map +1 -0
- package/dist/cjs/photo/photoFilters.js +880 -0
- package/dist/cjs/photo/photoFilters.js.map +1 -0
- package/dist/cjs/photo/photoOverlays.js +651 -0
- package/dist/cjs/photo/photoOverlays.js.map +1 -0
- package/dist/cjs/photo/photoSelection.js +547 -0
- package/dist/cjs/photo/photoSelection.js.map +1 -0
- package/dist/cjs/photo/usePhotoEditor.js +640 -0
- package/dist/cjs/photo/usePhotoEditor.js.map +1 -0
- package/dist/cjs/pixel/HSVPicker.js +173 -0
- package/dist/cjs/pixel/HSVPicker.js.map +1 -0
- package/dist/cjs/pixel/PixelEditor.js +28 -0
- package/dist/cjs/pixel/PixelEditor.js.map +1 -0
- package/dist/cjs/pixel/PixelEditor.module.css.js +6 -0
- package/dist/cjs/pixel/PixelEditor.module.css.js.map +1 -0
- package/dist/cjs/pixel/PixelEditorCanvas.js +15 -0
- package/dist/cjs/pixel/PixelEditorCanvas.js.map +1 -0
- package/dist/cjs/pixel/PixelEditorMenuBar.js +11 -0
- package/dist/cjs/pixel/PixelEditorMenuBar.js.map +1 -0
- package/dist/cjs/pixel/PixelEditorRightPanel.js +15 -0
- package/dist/cjs/pixel/PixelEditorRightPanel.js.map +1 -0
- package/dist/cjs/pixel/PixelEditorStatusBar.js +15 -0
- package/dist/cjs/pixel/PixelEditorStatusBar.js.map +1 -0
- package/dist/cjs/pixel/PixelEditorTimeline.js +11 -0
- package/dist/cjs/pixel/PixelEditorTimeline.js.map +1 -0
- package/dist/cjs/pixel/PixelEditorToolbar.js +16 -0
- package/dist/cjs/pixel/PixelEditorToolbar.js.map +1 -0
- package/dist/cjs/pixel/asepriteFormat.js +512 -0
- package/dist/cjs/pixel/asepriteFormat.js.map +1 -0
- package/dist/cjs/pixel/pixelEditorExports.js +471 -0
- package/dist/cjs/pixel/pixelEditorExports.js.map +1 -0
- package/dist/cjs/pixel/pixelEditorTypes.js +102 -0
- package/dist/cjs/pixel/pixelEditorTypes.js.map +1 -0
- package/dist/cjs/pixel/pixelEditorUtils.js +664 -0
- package/dist/cjs/pixel/pixelEditorUtils.js.map +1 -0
- package/dist/cjs/pixel/usePixelEditor.js +1112 -0
- package/dist/cjs/pixel/usePixelEditor.js.map +1 -0
- package/dist/cjs/texture/Nice3DTexturePainter.js +236 -0
- package/dist/cjs/texture/Nice3DTexturePainter.js.map +1 -0
- package/dist/cjs/ui/NiceUIDesigner.js +191 -0
- package/dist/cjs/ui/NiceUIDesigner.js.map +1 -0
- package/dist/cjs/vector/VectorEditor.js +31 -0
- package/dist/cjs/vector/VectorEditor.js.map +1 -0
- package/dist/cjs/vector/VectorEditor.module.css.js +6 -0
- package/dist/cjs/vector/VectorEditor.module.css.js.map +1 -0
- package/dist/cjs/vector/VectorEditorMenuBar.js +16 -0
- package/dist/cjs/vector/VectorEditorMenuBar.js.map +1 -0
- package/dist/cjs/vector/VectorEditorRightPanel.js +126 -0
- package/dist/cjs/vector/VectorEditorRightPanel.js.map +1 -0
- package/dist/cjs/vector/VectorEditorShapeRenderer.js +55 -0
- package/dist/cjs/vector/VectorEditorShapeRenderer.js.map +1 -0
- package/dist/cjs/vector/VectorEditorStatusBar.js +14 -0
- package/dist/cjs/vector/VectorEditorStatusBar.js.map +1 -0
- package/dist/cjs/vector/useVectorEditor.js +613 -0
- package/dist/cjs/vector/useVectorEditor.js.map +1 -0
- package/dist/cjs/vector/vectorBooleanOps.js +511 -0
- package/dist/cjs/vector/vectorBooleanOps.js.map +1 -0
- package/dist/cjs/vector/vectorEditorExport.js +159 -0
- package/dist/cjs/vector/vectorEditorExport.js.map +1 -0
- package/dist/cjs/vector/vectorEditorImport.js +150 -0
- package/dist/cjs/vector/vectorEditorImport.js.map +1 -0
- package/dist/cjs/vector/vectorEditorTypes.js +72 -0
- package/dist/cjs/vector/vectorEditorTypes.js.map +1 -0
- package/dist/cjs/vector/vectorGradients.js +201 -0
- package/dist/cjs/vector/vectorGradients.js.map +1 -0
- package/dist/esm/animation/AnimatedPerson.js +151 -0
- package/dist/esm/animation/AnimatedPerson.js.map +1 -0
- package/dist/esm/animation/AnimationEditor.js +104 -0
- package/dist/esm/animation/AnimationEditor.js.map +1 -0
- package/dist/esm/animation/Audience.js +57 -0
- package/dist/esm/animation/Audience.js.map +1 -0
- package/dist/esm/animation/BodyRenderer.js +28 -0
- package/dist/esm/animation/BodyRenderer.js.map +1 -0
- package/dist/esm/animation/animationHelper.js +268 -0
- package/dist/esm/animation/animationHelper.js.map +1 -0
- package/dist/esm/animation/characterTypes.js +70 -0
- package/dist/esm/animation/characterTypes.js.map +1 -0
- package/dist/esm/animation/choreoDSL.js +182 -0
- package/dist/esm/animation/choreoDSL.js.map +1 -0
- package/dist/esm/animation/choreography.js +36 -0
- package/dist/esm/animation/choreography.js.map +1 -0
- package/dist/esm/animation/karaokeIntegration.js +91 -0
- package/dist/esm/animation/karaokeIntegration.js.map +1 -0
- package/dist/esm/animation/lottieExport.js +123 -0
- package/dist/esm/animation/lottieExport.js.map +1 -0
- package/dist/esm/animation/motionPath.js +185 -0
- package/dist/esm/animation/motionPath.js.map +1 -0
- package/dist/esm/animation/physics.js +192 -0
- package/dist/esm/animation/physics.js.map +1 -0
- package/dist/esm/animation/rig/RigPlayer.js +61 -0
- package/dist/esm/animation/rig/RigPlayer.js.map +1 -0
- package/dist/esm/animation/rig/RiggedBody.js +28 -0
- package/dist/esm/animation/rig/RiggedBody.js.map +1 -0
- package/dist/esm/animation/rig/choreoRigBridge.js +60 -0
- package/dist/esm/animation/rig/choreoRigBridge.js.map +1 -0
- package/dist/esm/animation/rig/ik.js +20 -0
- package/dist/esm/animation/rig/ik.js.map +1 -0
- package/dist/esm/animation/rig/poseOps.js +45 -0
- package/dist/esm/animation/rig/poseOps.js.map +1 -0
- package/dist/esm/animation/rig/presets.js +53 -0
- package/dist/esm/animation/rig/presets.js.map +1 -0
- package/dist/esm/animation/rig/rigMath.js +37 -0
- package/dist/esm/animation/rig/rigMath.js.map +1 -0
- package/dist/esm/animation/rig/rigTypes.js +40 -0
- package/dist/esm/animation/rig/rigTypes.js.map +1 -0
- package/dist/esm/animation/shapes/arms.js +13 -0
- package/dist/esm/animation/shapes/arms.js.map +1 -0
- package/dist/esm/animation/shapes/eyes.js +45 -0
- package/dist/esm/animation/shapes/eyes.js.map +1 -0
- package/dist/esm/animation/shapes/hair.js +46 -0
- package/dist/esm/animation/shapes/hair.js.map +1 -0
- package/dist/esm/animation/shapes/heads.js +52 -0
- package/dist/esm/animation/shapes/heads.js.map +1 -0
- package/dist/esm/animation/shapes/headwear.js +36 -0
- package/dist/esm/animation/shapes/headwear.js.map +1 -0
- package/dist/esm/animation/shapes/legs.js +13 -0
- package/dist/esm/animation/shapes/legs.js.map +1 -0
- package/dist/esm/animation/shapes/mouths.js +45 -0
- package/dist/esm/animation/shapes/mouths.js.map +1 -0
- package/dist/esm/animation/shapes/noses.js +23 -0
- package/dist/esm/animation/shapes/noses.js.map +1 -0
- package/dist/esm/animation/shapes/outfits.js +37 -0
- package/dist/esm/animation/shapes/outfits.js.map +1 -0
- package/dist/esm/animation/shapes/torsos.js +11 -0
- package/dist/esm/animation/shapes/torsos.js.map +1 -0
- package/dist/esm/animation/spineExport.js +128 -0
- package/dist/esm/animation/spineExport.js.map +1 -0
- package/dist/esm/core/LocalUI.js +50 -0
- package/dist/esm/core/LocalUI.js.map +1 -0
- package/dist/esm/core/collaboration.js +252 -0
- package/dist/esm/core/collaboration.js.map +1 -0
- package/dist/esm/core/colorBlindness.js +90 -0
- package/dist/esm/core/colorBlindness.js.map +1 -0
- package/dist/esm/core/dragDrop.js +165 -0
- package/dist/esm/core/dragDrop.js.map +1 -0
- package/dist/esm/core/fixes.js +179 -0
- package/dist/esm/core/fixes.js.map +1 -0
- package/dist/esm/core/gridGuides.js +232 -0
- package/dist/esm/core/gridGuides.js.map +1 -0
- package/dist/esm/core/historyVisual.js +121 -0
- package/dist/esm/core/historyVisual.js.map +1 -0
- package/dist/esm/core/i18n.js +13 -0
- package/dist/esm/core/i18n.js.map +1 -0
- package/dist/esm/core/integrations.js +254 -0
- package/dist/esm/core/integrations.js.map +1 -0
- package/dist/esm/core/minimap.js +139 -0
- package/dist/esm/core/minimap.js.map +1 -0
- package/dist/esm/core/plugins.js +124 -0
- package/dist/esm/core/plugins.js.map +1 -0
- package/dist/esm/core/rtl.js +95 -0
- package/dist/esm/core/rtl.js.map +1 -0
- package/dist/esm/core/shortcuts.js +200 -0
- package/dist/esm/core/shortcuts.js.map +1 -0
- package/dist/esm/core/theme.js +162 -0
- package/dist/esm/core/theme.js.map +1 -0
- package/dist/esm/font/NiceFontEditor.js +189 -0
- package/dist/esm/font/NiceFontEditor.js.map +1 -0
- package/dist/esm/game/GameAsset2dEditor.js +369 -0
- package/dist/esm/game/GameAsset2dEditor.js.map +1 -0
- package/dist/esm/game/GameAsset2dEditor.module.css.js +4 -0
- package/dist/esm/game/GameAsset2dEditor.module.css.js.map +1 -0
- package/dist/esm/game/gameAssetTypes.js +18 -0
- package/dist/esm/game/gameAssetTypes.js.map +1 -0
- package/dist/esm/game/gameAssetUtils.js +456 -0
- package/dist/esm/game/gameAssetUtils.js.map +1 -0
- package/dist/esm/game/useGameAssetEditor.js +759 -0
- package/dist/esm/game/useGameAssetEditor.js.map +1 -0
- package/dist/esm/icon/NiceIconEditor.js +246 -0
- package/dist/esm/icon/NiceIconEditor.js.map +1 -0
- package/dist/esm/index.js +59 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/nice2dev-ui/dist/index.js +31720 -0
- package/dist/esm/nice2dev-ui/dist/index.js.map +1 -0
- package/dist/esm/nice2dev-ui-graphics.css +1 -0
- package/dist/esm/photo/FilterThumb.js +27 -0
- package/dist/esm/photo/FilterThumb.js.map +1 -0
- package/dist/esm/photo/PhotoEditor.js +18 -0
- package/dist/esm/photo/PhotoEditor.js.map +1 -0
- package/dist/esm/photo/PhotoEditor.module.css.js +4 -0
- package/dist/esm/photo/PhotoEditor.module.css.js.map +1 -0
- package/dist/esm/photo/PhotoEditorCanvas.js +57 -0
- package/dist/esm/photo/PhotoEditorCanvas.js.map +1 -0
- package/dist/esm/photo/PhotoEditorLeftPanel.js +172 -0
- package/dist/esm/photo/PhotoEditorLeftPanel.js.map +1 -0
- package/dist/esm/photo/PhotoEditorToolbar.js +13 -0
- package/dist/esm/photo/PhotoEditorToolbar.js.map +1 -0
- package/dist/esm/photo/photoEditorActions.js +75 -0
- package/dist/esm/photo/photoEditorActions.js.map +1 -0
- package/dist/esm/photo/photoEditorTypes.js +36 -0
- package/dist/esm/photo/photoEditorTypes.js.map +1 -0
- package/dist/esm/photo/photoFilters.js +871 -0
- package/dist/esm/photo/photoFilters.js.map +1 -0
- package/dist/esm/photo/photoOverlays.js +636 -0
- package/dist/esm/photo/photoOverlays.js.map +1 -0
- package/dist/esm/photo/photoSelection.js +535 -0
- package/dist/esm/photo/photoSelection.js.map +1 -0
- package/dist/esm/photo/usePhotoEditor.js +638 -0
- package/dist/esm/photo/usePhotoEditor.js.map +1 -0
- package/dist/esm/pixel/HSVPicker.js +171 -0
- package/dist/esm/pixel/HSVPicker.js.map +1 -0
- package/dist/esm/pixel/PixelEditor.js +26 -0
- package/dist/esm/pixel/PixelEditor.js.map +1 -0
- package/dist/esm/pixel/PixelEditor.module.css.js +4 -0
- package/dist/esm/pixel/PixelEditor.module.css.js.map +1 -0
- package/dist/esm/pixel/PixelEditorCanvas.js +13 -0
- package/dist/esm/pixel/PixelEditorCanvas.js.map +1 -0
- package/dist/esm/pixel/PixelEditorMenuBar.js +9 -0
- package/dist/esm/pixel/PixelEditorMenuBar.js.map +1 -0
- package/dist/esm/pixel/PixelEditorRightPanel.js +13 -0
- package/dist/esm/pixel/PixelEditorRightPanel.js.map +1 -0
- package/dist/esm/pixel/PixelEditorStatusBar.js +13 -0
- package/dist/esm/pixel/PixelEditorStatusBar.js.map +1 -0
- package/dist/esm/pixel/PixelEditorTimeline.js +9 -0
- package/dist/esm/pixel/PixelEditorTimeline.js.map +1 -0
- package/dist/esm/pixel/PixelEditorToolbar.js +14 -0
- package/dist/esm/pixel/PixelEditorToolbar.js.map +1 -0
- package/dist/esm/pixel/asepriteFormat.js +505 -0
- package/dist/esm/pixel/asepriteFormat.js.map +1 -0
- package/dist/esm/pixel/pixelEditorExports.js +461 -0
- package/dist/esm/pixel/pixelEditorExports.js.map +1 -0
- package/dist/esm/pixel/pixelEditorTypes.js +90 -0
- package/dist/esm/pixel/pixelEditorTypes.js.map +1 -0
- package/dist/esm/pixel/pixelEditorUtils.js +631 -0
- package/dist/esm/pixel/pixelEditorUtils.js.map +1 -0
- package/dist/esm/pixel/usePixelEditor.js +1110 -0
- package/dist/esm/pixel/usePixelEditor.js.map +1 -0
- package/dist/esm/texture/Nice3DTexturePainter.js +233 -0
- package/dist/esm/texture/Nice3DTexturePainter.js.map +1 -0
- package/dist/esm/ui/NiceUIDesigner.js +187 -0
- package/dist/esm/ui/NiceUIDesigner.js.map +1 -0
- package/dist/esm/vector/VectorEditor.js +29 -0
- package/dist/esm/vector/VectorEditor.js.map +1 -0
- package/dist/esm/vector/VectorEditor.module.css.js +4 -0
- package/dist/esm/vector/VectorEditor.module.css.js.map +1 -0
- package/dist/esm/vector/VectorEditorMenuBar.js +14 -0
- package/dist/esm/vector/VectorEditorMenuBar.js.map +1 -0
- package/dist/esm/vector/VectorEditorRightPanel.js +124 -0
- package/dist/esm/vector/VectorEditorRightPanel.js.map +1 -0
- package/dist/esm/vector/VectorEditorShapeRenderer.js +53 -0
- package/dist/esm/vector/VectorEditorShapeRenderer.js.map +1 -0
- package/dist/esm/vector/VectorEditorStatusBar.js +12 -0
- package/dist/esm/vector/VectorEditorStatusBar.js.map +1 -0
- package/dist/esm/vector/useVectorEditor.js +611 -0
- package/dist/esm/vector/useVectorEditor.js.map +1 -0
- package/dist/esm/vector/vectorBooleanOps.js +507 -0
- package/dist/esm/vector/vectorBooleanOps.js.map +1 -0
- package/dist/esm/vector/vectorEditorExport.js +152 -0
- package/dist/esm/vector/vectorEditorExport.js.map +1 -0
- package/dist/esm/vector/vectorEditorImport.js +148 -0
- package/dist/esm/vector/vectorEditorImport.js.map +1 -0
- package/dist/esm/vector/vectorEditorTypes.js +63 -0
- package/dist/esm/vector/vectorEditorTypes.js.map +1 -0
- package/dist/esm/vector/vectorGradients.js +193 -0
- package/dist/esm/vector/vectorGradients.js.map +1 -0
- package/dist/types/__benchmarks__/bench.d.ts +13 -0
- package/dist/types/__tests__/setup.d.ts +4 -0
- package/dist/types/animation/AnimatedPerson.d.ts +14 -0
- package/dist/types/animation/AnimationEditor.d.ts +20 -0
- package/dist/types/animation/Audience.d.ts +11 -0
- package/dist/types/animation/BodyRenderer.d.ts +12 -0
- package/dist/types/animation/animationHelper.d.ts +28 -0
- package/dist/types/animation/characterTypes.d.ts +37 -0
- package/dist/types/animation/choreoDSL.d.ts +88 -0
- package/dist/types/animation/choreography.d.ts +8 -0
- package/dist/types/animation/karaokeIntegration.d.ts +31 -0
- package/dist/types/animation/lottieExport.d.ts +77 -0
- package/dist/types/animation/motionPath.d.ts +60 -0
- package/dist/types/animation/physics.d.ts +73 -0
- package/dist/types/animation/rig/RigPlayer.d.ts +32 -0
- package/dist/types/animation/rig/RiggedBody.d.ts +19 -0
- package/dist/types/animation/rig/choreoRigBridge.d.ts +9 -0
- package/dist/types/animation/rig/ik.d.ts +8 -0
- package/dist/types/animation/rig/poseOps.d.ts +14 -0
- package/dist/types/animation/rig/presets.d.ts +13 -0
- package/dist/types/animation/rig/rigMath.d.ts +7 -0
- package/dist/types/animation/rig/rigTypes.d.ts +38 -0
- package/dist/types/animation/shapes/arms.d.ts +10 -0
- package/dist/types/animation/shapes/eyes.d.ts +17 -0
- package/dist/types/animation/shapes/hair.d.ts +17 -0
- package/dist/types/animation/shapes/heads.d.ts +18 -0
- package/dist/types/animation/shapes/headwear.d.ts +16 -0
- package/dist/types/animation/shapes/legs.d.ts +10 -0
- package/dist/types/animation/shapes/mouths.d.ts +17 -0
- package/dist/types/animation/shapes/noses.d.ts +17 -0
- package/dist/types/animation/shapes/outfits.d.ts +14 -0
- package/dist/types/animation/shapes/torsos.d.ts +9 -0
- package/dist/types/animation/spineExport.d.ts +66 -0
- package/dist/types/core/LocalUI.d.ts +21 -0
- package/dist/types/core/collaboration.d.ts +164 -0
- package/dist/types/core/colorBlindness.d.ts +24 -0
- package/dist/types/core/dragDrop.d.ts +46 -0
- package/dist/types/core/fixes.d.ts +80 -0
- package/dist/types/core/gridGuides.d.ts +70 -0
- package/dist/types/core/historyVisual.d.ts +915 -0
- package/dist/types/core/i18n.d.ts +27 -0
- package/dist/types/core/integrations.d.ts +103 -0
- package/dist/types/core/minimap.d.ts +49 -0
- package/dist/types/core/plugins.d.ts +111 -0
- package/dist/types/core/rtl.d.ts +32 -0
- package/dist/types/core/shortcuts.d.ts +150 -0
- package/dist/types/core/theme.d.ts +78 -0
- package/dist/types/core/useGamepad.d.ts +64 -0
- package/dist/types/core/usePointerPressure.d.ts +88 -0
- package/dist/types/font/NiceFontEditor.d.ts +62 -0
- package/dist/types/game/AnimationPreviewPlayer.d.ts +29 -0
- package/dist/types/game/CollisionEditor.d.ts +101 -0
- package/dist/types/game/GameAsset2dEditor.d.ts +17 -0
- package/dist/types/game/GameAssetExportPanel.d.ts +20 -0
- package/dist/types/game/IsometricEditor.d.ts +22 -0
- package/dist/types/game/IsometricTilePanel.d.ts +18 -0
- package/dist/types/game/gameAssetExport.d.ts +160 -0
- package/dist/types/game/gameAssetTypes.d.ts +238 -0
- package/dist/types/game/gameAssetUtils.d.ts +23 -0
- package/dist/types/game/index.d.ts +8 -0
- package/dist/types/game/isometricTiles.d.ts +250 -0
- package/dist/types/game/useAnimationPreview.d.ts +63 -0
- package/dist/types/game/useCollisionEditor.d.ts +96 -0
- package/dist/types/game/useGameAssetEditor.d.ts +79 -0
- package/dist/types/game/useGameAssetExport.d.ts +82 -0
- package/dist/types/icon/NiceIconEditor.d.ts +79 -0
- package/dist/types/index.d.ts +85 -0
- package/dist/types/photo/BatchProcessingPanel.d.ts +13 -0
- package/dist/types/photo/FaceDetectionPanel.d.ts +18 -0
- package/dist/types/photo/FilterThumb.d.ts +14 -0
- package/dist/types/photo/PerspectiveCorrectionPanel.d.ts +17 -0
- package/dist/types/photo/PhotoEditor.d.ts +2 -0
- package/dist/types/photo/PhotoEditorCanvas.d.ts +14 -0
- package/dist/types/photo/PhotoEditorLeftPanel.d.ts +13 -0
- package/dist/types/photo/PhotoEditorToolbar.d.ts +13 -0
- package/dist/types/photo/RawFilePanel.d.ts +14 -0
- package/dist/types/photo/StyleTransferPanel.d.ts +15 -0
- package/dist/types/photo/aiStyleTransfer.d.ts +58 -0
- package/dist/types/photo/batchProcessing.d.ts +95 -0
- package/dist/types/photo/faceDetection.d.ts +103 -0
- package/dist/types/photo/index.d.ts +17 -0
- package/dist/types/photo/perspectiveCorrection.d.ts +134 -0
- package/dist/types/photo/photoEditorActions.d.ts +40 -0
- package/dist/types/photo/photoEditorTypes.d.ts +34 -0
- package/dist/types/photo/photoFilters.d.ts +55 -0
- package/dist/types/photo/photoOverlays.d.ts +126 -0
- package/dist/types/photo/photoSelection.d.ts +56 -0
- package/dist/types/photo/rawFileSupport.d.ts +124 -0
- package/dist/types/photo/usePhotoEditor.d.ts +123 -0
- package/dist/types/pixel/HSVPicker.d.ts +11 -0
- package/dist/types/pixel/PaletteExtractorPanel.d.ts +16 -0
- package/dist/types/pixel/PixelEditor.d.ts +17 -0
- package/dist/types/pixel/PixelEditorCanvas.d.ts +10 -0
- package/dist/types/pixel/PixelEditorMenuBar.d.ts +11 -0
- package/dist/types/pixel/PixelEditorRightPanel.d.ts +11 -0
- package/dist/types/pixel/PixelEditorStatusBar.d.ts +11 -0
- package/dist/types/pixel/PixelEditorTimeline.d.ts +11 -0
- package/dist/types/pixel/PixelEditorToolbar.d.ts +11 -0
- package/dist/types/pixel/TileMapPanel.d.ts +14 -0
- package/dist/types/pixel/asepriteFormat.d.ts +62 -0
- package/dist/types/pixel/paletteExtractor.d.ts +73 -0
- package/dist/types/pixel/pixelEditorExports.d.ts +31 -0
- package/dist/types/pixel/pixelEditorTypes.d.ts +51 -0
- package/dist/types/pixel/pixelEditorUtils.d.ts +136 -0
- package/dist/types/pixel/tileMapMode.d.ts +122 -0
- package/dist/types/pixel/usePixelEditor.d.ts +114 -0
- package/dist/types/texture/Nice3DTexturePainter.d.ts +55 -0
- package/dist/types/ui/NiceUIDesigner.d.ts +43 -0
- package/dist/types/vector/PathSimplificationPanel.d.ts +15 -0
- package/dist/types/vector/PdfExportPanel.d.ts +20 -0
- package/dist/types/vector/TextOnPathPanel.d.ts +26 -0
- package/dist/types/vector/VectorEditor.d.ts +32 -0
- package/dist/types/vector/VectorEditorMenuBar.d.ts +8 -0
- package/dist/types/vector/VectorEditorRightPanel.d.ts +7 -0
- package/dist/types/vector/VectorEditorShapeRenderer.d.ts +9 -0
- package/dist/types/vector/VectorEditorStatusBar.d.ts +9 -0
- package/dist/types/vector/VectorFilterPanel.d.ts +19 -0
- package/dist/types/vector/VectorPatternPanel.d.ts +21 -0
- package/dist/types/vector/pathSimplification.d.ts +135 -0
- package/dist/types/vector/pdfExport.d.ts +65 -0
- package/dist/types/vector/textOnPath.d.ts +145 -0
- package/dist/types/vector/useVectorEditor.d.ts +90 -0
- package/dist/types/vector/vectorBooleanOps.d.ts +22 -0
- package/dist/types/vector/vectorEditorExport.d.ts +8 -0
- package/dist/types/vector/vectorEditorImport.d.ts +7 -0
- package/dist/types/vector/vectorEditorTypes.d.ts +47 -0
- package/dist/types/vector/vectorGradients.d.ts +64 -0
- package/dist/types/vector/vectorPatternFills.d.ts +101 -0
- package/dist/types/vector/vectorSvgFilters.d.ts +134 -0
- package/package.json +93 -0
|
@@ -0,0 +1,640 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var i18n = require('../core/i18n.js');
|
|
5
|
+
var photoFilters = require('./photoFilters.js');
|
|
6
|
+
var photoOverlays = require('./photoOverlays.js');
|
|
7
|
+
var photoEditorActions = require('./photoEditorActions.js');
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* usePhotoEditor.ts — Custom hook encapsulating all PhotoEditor state & logic.
|
|
11
|
+
*
|
|
12
|
+
* Extracts ~500 lines of state, effects, callbacks, and memoised values
|
|
13
|
+
* out of the god-component so that the main component file is pure composition.
|
|
14
|
+
*/
|
|
15
|
+
// ── Hook ──
|
|
16
|
+
function usePhotoEditor({ src, playerColor = "#00aaff", onSave, onCancel, initialState }) {
|
|
17
|
+
const { t: _t } = i18n.useNiceTranslation();
|
|
18
|
+
const t = (key, def) => _t(key, def);
|
|
19
|
+
// ── State ──
|
|
20
|
+
// Image
|
|
21
|
+
const [image, setImage] = React.useState(null);
|
|
22
|
+
const [loading, setLoading] = React.useState(true);
|
|
23
|
+
// Tabs
|
|
24
|
+
const [activeTab, setActiveTabRaw] = React.useState("filters");
|
|
25
|
+
const [cropMode, setCropMode] = React.useState(false);
|
|
26
|
+
// Filter
|
|
27
|
+
const [selectedFilter, setSelectedFilter] = React.useState("none");
|
|
28
|
+
const [filterIntensity, setFilterIntensity] = React.useState(1);
|
|
29
|
+
const [filterCategory, setFilterCategory] = React.useState("all");
|
|
30
|
+
const [filterParams] = React.useState({});
|
|
31
|
+
// Adjustments
|
|
32
|
+
const [adjustments, setAdjustments] = React.useState({ ...photoFilters.DEFAULT_ADJUSTMENTS });
|
|
33
|
+
// Transform
|
|
34
|
+
const [rotation, setRotation] = React.useState(0);
|
|
35
|
+
const [flipH, setFlipH] = React.useState(false);
|
|
36
|
+
const [flipV, setFlipV] = React.useState(false);
|
|
37
|
+
// Crop
|
|
38
|
+
const [cropRect, setCropRect] = React.useState(null);
|
|
39
|
+
const [cropAspect, setCropAspect] = React.useState(null);
|
|
40
|
+
const [cropDragging, setCropDragging] = React.useState(null);
|
|
41
|
+
const [cropStart, setCropStart] = React.useState(null);
|
|
42
|
+
// Compare
|
|
43
|
+
const [showCompare, setShowCompare] = React.useState(false);
|
|
44
|
+
const [comparePosition, setComparePosition] = React.useState(50);
|
|
45
|
+
const [compareDragging, setCompareDragging] = React.useState(false);
|
|
46
|
+
// Zoom
|
|
47
|
+
const [zoom, setZoom] = React.useState(1);
|
|
48
|
+
// Overlays
|
|
49
|
+
const [overlays, setOverlays] = React.useState([]);
|
|
50
|
+
const [selectedOverlayId, setSelectedOverlayId] = React.useState(null);
|
|
51
|
+
const [overlayDragging, setOverlayDragging] = React.useState(false);
|
|
52
|
+
const [overlayDragStart, setOverlayDragStart] = React.useState(null);
|
|
53
|
+
// Sticker / emoji
|
|
54
|
+
const [emojiCat, setEmojiCat] = React.useState(photoOverlays.EMOJI_CATALOG[0].id);
|
|
55
|
+
// Text overlay
|
|
56
|
+
const [textDraft, setTextDraft] = React.useState("Tekst");
|
|
57
|
+
const [textColor, setTextColor] = React.useState("#ffffff");
|
|
58
|
+
const [textBold, setTextBold] = React.useState(true);
|
|
59
|
+
const [textItalic, setTextItalic] = React.useState(false);
|
|
60
|
+
const [textOutline, setTextOutline] = React.useState(true);
|
|
61
|
+
const [textFontSize, setTextFontSize] = React.useState(36);
|
|
62
|
+
const [textBg, setTextBg] = React.useState(false);
|
|
63
|
+
// Shape
|
|
64
|
+
const [shapeStroke, setShapeStroke] = React.useState("#ffffff");
|
|
65
|
+
const [shapeFill, setShapeFill] = React.useState("");
|
|
66
|
+
const [shapeStrokeW, setShapeStrokeW] = React.useState(3);
|
|
67
|
+
// Frame
|
|
68
|
+
const [frameColor, setFrameColor] = React.useState("#ffffff");
|
|
69
|
+
const [frameThick, setFrameThick] = React.useState(3);
|
|
70
|
+
// Drawing
|
|
71
|
+
const [drawColor, setDrawColor] = React.useState("#ff0000");
|
|
72
|
+
const [drawWidth, setDrawWidth] = React.useState(4);
|
|
73
|
+
const [isDrawing, setIsDrawing] = React.useState(false);
|
|
74
|
+
const [livePoints, setLivePoints] = React.useState([]);
|
|
75
|
+
const drawingOverlayRef = React.useRef(null);
|
|
76
|
+
// History
|
|
77
|
+
const [history, setHistory] = React.useState([]);
|
|
78
|
+
const [historyIdx, setHistoryIdx] = React.useState(-1);
|
|
79
|
+
const suppressHistoryRef = React.useRef(false);
|
|
80
|
+
// Canvas refs
|
|
81
|
+
const mainCanvasRef = React.useRef(null);
|
|
82
|
+
const compareCanvasRef = React.useRef(null);
|
|
83
|
+
const containerRef = React.useRef(null);
|
|
84
|
+
// ── Derived ──
|
|
85
|
+
const accent = playerColor;
|
|
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
|
+
// Tab setter (auto-toggle cropMode)
|
|
89
|
+
const setActiveTab = React.useCallback((tab) => {
|
|
90
|
+
setActiveTabRaw(tab);
|
|
91
|
+
setCropMode(tab === "crop");
|
|
92
|
+
}, []);
|
|
93
|
+
// ── History ──
|
|
94
|
+
const pushHistory = React.useCallback(() => {
|
|
95
|
+
if (suppressHistoryRef.current)
|
|
96
|
+
return;
|
|
97
|
+
const state = {
|
|
98
|
+
selectedFilter,
|
|
99
|
+
filterIntensity,
|
|
100
|
+
adjustments: { ...adjustments },
|
|
101
|
+
rotation,
|
|
102
|
+
flipH,
|
|
103
|
+
flipV,
|
|
104
|
+
cropRect: cropRect ? { ...cropRect } : null,
|
|
105
|
+
overlays: overlays.map(o => ({ ...o })),
|
|
106
|
+
};
|
|
107
|
+
setHistory(prev => [...prev.slice(0, historyIdx + 1), state]);
|
|
108
|
+
setHistoryIdx(prev => prev + 1);
|
|
109
|
+
}, [selectedFilter, filterIntensity, adjustments, rotation, flipH, flipV, cropRect, overlays, historyIdx]);
|
|
110
|
+
const restoreState = React.useCallback((s) => {
|
|
111
|
+
suppressHistoryRef.current = true;
|
|
112
|
+
setSelectedFilter(s.selectedFilter);
|
|
113
|
+
setFilterIntensity(s.filterIntensity);
|
|
114
|
+
setAdjustments({ ...s.adjustments });
|
|
115
|
+
setRotation(s.rotation);
|
|
116
|
+
setFlipH(s.flipH);
|
|
117
|
+
setFlipV(s.flipV);
|
|
118
|
+
setCropRect(s.cropRect ? { ...s.cropRect } : null);
|
|
119
|
+
setOverlays(s.overlays.map(o => ({ ...o })));
|
|
120
|
+
setSelectedOverlayId(null);
|
|
121
|
+
setTimeout(() => { suppressHistoryRef.current = false; }, 50);
|
|
122
|
+
}, []);
|
|
123
|
+
const undo = React.useCallback(() => {
|
|
124
|
+
if (historyIdx > 0) {
|
|
125
|
+
const newIdx = historyIdx - 1;
|
|
126
|
+
setHistoryIdx(newIdx);
|
|
127
|
+
restoreState(history[newIdx]);
|
|
128
|
+
}
|
|
129
|
+
}, [historyIdx, history, restoreState]);
|
|
130
|
+
const redo = React.useCallback(() => {
|
|
131
|
+
if (historyIdx < history.length - 1) {
|
|
132
|
+
const newIdx = historyIdx + 1;
|
|
133
|
+
setHistoryIdx(newIdx);
|
|
134
|
+
restoreState(history[newIdx]);
|
|
135
|
+
}
|
|
136
|
+
}, [historyIdx, history, restoreState]);
|
|
137
|
+
// ── Load image ──
|
|
138
|
+
React.useEffect(() => {
|
|
139
|
+
const img = new Image();
|
|
140
|
+
img.onload = () => {
|
|
141
|
+
setImage(img);
|
|
142
|
+
setLoading(false);
|
|
143
|
+
setCropRect({ x: 0, y: 0, w: img.naturalWidth, h: img.naturalHeight });
|
|
144
|
+
};
|
|
145
|
+
img.onerror = () => setLoading(false);
|
|
146
|
+
if (src instanceof File || src instanceof Blob) {
|
|
147
|
+
img.src = URL.createObjectURL(src);
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
img.crossOrigin = "anonymous";
|
|
151
|
+
img.src = src;
|
|
152
|
+
}
|
|
153
|
+
return () => {
|
|
154
|
+
if (img.src.startsWith("blob:"))
|
|
155
|
+
URL.revokeObjectURL(img.src);
|
|
156
|
+
};
|
|
157
|
+
}, [src]);
|
|
158
|
+
// Push initial history once image loads
|
|
159
|
+
React.useEffect(() => {
|
|
160
|
+
if (image && history.length === 0) {
|
|
161
|
+
if (initialState) {
|
|
162
|
+
const prev = photoOverlays.deserializeEditorState(initialState);
|
|
163
|
+
if (prev) {
|
|
164
|
+
suppressHistoryRef.current = true;
|
|
165
|
+
setSelectedFilter(prev.filter);
|
|
166
|
+
setFilterIntensity(prev.filterIntensity);
|
|
167
|
+
setAdjustments({ ...prev.adjustments });
|
|
168
|
+
setRotation(prev.rotation);
|
|
169
|
+
setFlipH(prev.flipH);
|
|
170
|
+
setFlipV(prev.flipV);
|
|
171
|
+
if (prev.cropRect)
|
|
172
|
+
setCropRect(prev.cropRect);
|
|
173
|
+
if (prev.overlays)
|
|
174
|
+
setOverlays(prev.overlays);
|
|
175
|
+
setTimeout(() => { suppressHistoryRef.current = false; }, 50);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
pushHistory();
|
|
179
|
+
}
|
|
180
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
181
|
+
}, [image]);
|
|
182
|
+
// ── Render main canvas ──
|
|
183
|
+
const renderMain = React.useCallback(() => {
|
|
184
|
+
if (!image || !mainCanvasRef.current)
|
|
185
|
+
return;
|
|
186
|
+
photoFilters.renderToCanvas(mainCanvasRef.current, image, selectedFilter, { ...filterParams, intensity: filterIntensity }, adjustments, cropMode ? null : cropRect, rotation, flipH, flipV);
|
|
187
|
+
if (overlays.length > 0 || livePoints.length > 1) {
|
|
188
|
+
const ctx = mainCanvasRef.current.getContext("2d");
|
|
189
|
+
if (ctx) {
|
|
190
|
+
const cw = mainCanvasRef.current.width;
|
|
191
|
+
const ch = mainCanvasRef.current.height;
|
|
192
|
+
if (overlays.length > 0)
|
|
193
|
+
photoOverlays.renderAllOverlays(ctx, overlays, cw, ch);
|
|
194
|
+
if (livePoints.length > 1)
|
|
195
|
+
photoOverlays.renderLiveStroke(ctx, livePoints, drawColor, drawWidth, cw, ch);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}, [image, selectedFilter, filterParams, filterIntensity, adjustments, cropRect, cropMode, rotation, flipH, flipV, overlays, livePoints, drawColor, drawWidth]);
|
|
199
|
+
React.useEffect(() => { renderMain(); }, [renderMain]);
|
|
200
|
+
// Render compare canvas (original)
|
|
201
|
+
React.useEffect(() => {
|
|
202
|
+
if (!image || !compareCanvasRef.current || !showCompare)
|
|
203
|
+
return;
|
|
204
|
+
const canvas = compareCanvasRef.current;
|
|
205
|
+
const ctx = canvas.getContext("2d");
|
|
206
|
+
if (!ctx)
|
|
207
|
+
return;
|
|
208
|
+
const crop = cropRect !== null && cropRect !== void 0 ? cropRect : { x: 0, y: 0, w: image.naturalWidth, h: image.naturalHeight };
|
|
209
|
+
canvas.width = crop.w;
|
|
210
|
+
canvas.height = crop.h;
|
|
211
|
+
ctx.drawImage(image, crop.x, crop.y, crop.w, crop.h, 0, 0, crop.w, crop.h);
|
|
212
|
+
}, [image, showCompare, cropRect]);
|
|
213
|
+
// ── Filter thumbnails ──
|
|
214
|
+
const filteredList = React.useMemo(() => {
|
|
215
|
+
if (filterCategory === "all")
|
|
216
|
+
return photoFilters.PHOTO_FILTERS;
|
|
217
|
+
return photoFilters.PHOTO_FILTERS.filter(f => f.category === filterCategory || f.id === "none");
|
|
218
|
+
}, [filterCategory]);
|
|
219
|
+
const generateThumbnail = React.useCallback((canvas, filter) => {
|
|
220
|
+
if (!image)
|
|
221
|
+
return;
|
|
222
|
+
const size = 64;
|
|
223
|
+
canvas.width = size;
|
|
224
|
+
canvas.height = size;
|
|
225
|
+
const ctx = canvas.getContext("2d", { willReadFrequently: true });
|
|
226
|
+
if (!ctx)
|
|
227
|
+
return;
|
|
228
|
+
const s = Math.min(image.naturalWidth, image.naturalHeight);
|
|
229
|
+
const sx = (image.naturalWidth - s) / 2;
|
|
230
|
+
const sy = (image.naturalHeight - s) / 2;
|
|
231
|
+
ctx.drawImage(image, sx, sy, s, s, 0, 0, size, size);
|
|
232
|
+
if (filter.id !== "none") {
|
|
233
|
+
const imgData = ctx.getImageData(0, 0, size, size);
|
|
234
|
+
const filtered = filter.apply(imgData, { intensity: 1 });
|
|
235
|
+
ctx.putImageData(filtered, 0, 0);
|
|
236
|
+
}
|
|
237
|
+
}, [image]);
|
|
238
|
+
// ── Crop interaction ──
|
|
239
|
+
const getCanvasScale = React.useCallback(() => {
|
|
240
|
+
if (!mainCanvasRef.current || !containerRef.current || !image)
|
|
241
|
+
return { sx: 1, sy: 1, ox: 0, oy: 0 };
|
|
242
|
+
const rect = mainCanvasRef.current.getBoundingClientRect();
|
|
243
|
+
const cw = mainCanvasRef.current.width;
|
|
244
|
+
const ch = mainCanvasRef.current.height;
|
|
245
|
+
return { sx: cw / rect.width, sy: ch / rect.height, ox: rect.left, oy: rect.top };
|
|
246
|
+
}, [image]);
|
|
247
|
+
const handleCropMouseDown = React.useCallback((e, handle) => {
|
|
248
|
+
e.preventDefault();
|
|
249
|
+
e.stopPropagation();
|
|
250
|
+
setCropDragging(handle);
|
|
251
|
+
setCropStart({ mx: e.clientX, my: e.clientY, rect: { ...cropRect } });
|
|
252
|
+
}, [cropRect]);
|
|
253
|
+
React.useEffect(() => {
|
|
254
|
+
if (!cropDragging || !cropStart || !cropRect || !image)
|
|
255
|
+
return;
|
|
256
|
+
const handleMove = (e) => {
|
|
257
|
+
const scale = getCanvasScale();
|
|
258
|
+
const dx = (e.clientX - cropStart.mx) * scale.sx;
|
|
259
|
+
const dy = (e.clientY - cropStart.my) * scale.sy;
|
|
260
|
+
const r = { ...cropStart.rect };
|
|
261
|
+
const minSize = 20;
|
|
262
|
+
if (cropDragging === "move") {
|
|
263
|
+
r.x = Math.max(0, Math.min(image.naturalWidth - r.w, r.x + dx));
|
|
264
|
+
r.y = Math.max(0, Math.min(image.naturalHeight - r.h, r.y + dy));
|
|
265
|
+
}
|
|
266
|
+
else {
|
|
267
|
+
if (cropDragging.includes("w")) {
|
|
268
|
+
r.x += dx;
|
|
269
|
+
r.w -= dx;
|
|
270
|
+
}
|
|
271
|
+
if (cropDragging.includes("e")) {
|
|
272
|
+
r.w += dx;
|
|
273
|
+
}
|
|
274
|
+
if (cropDragging.includes("n")) {
|
|
275
|
+
r.y += dy;
|
|
276
|
+
r.h -= dy;
|
|
277
|
+
}
|
|
278
|
+
if (cropDragging.includes("s")) {
|
|
279
|
+
r.h += dy;
|
|
280
|
+
}
|
|
281
|
+
if (r.w < minSize) {
|
|
282
|
+
r.w = minSize;
|
|
283
|
+
}
|
|
284
|
+
if (r.h < minSize) {
|
|
285
|
+
r.h = minSize;
|
|
286
|
+
}
|
|
287
|
+
if (cropAspect) {
|
|
288
|
+
if (cropDragging.includes("w") || cropDragging.includes("e")) {
|
|
289
|
+
r.h = r.w / cropAspect;
|
|
290
|
+
}
|
|
291
|
+
else {
|
|
292
|
+
r.w = r.h * cropAspect;
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
r.x = Math.max(0, r.x);
|
|
296
|
+
r.y = Math.max(0, r.y);
|
|
297
|
+
r.w = Math.min(r.w, image.naturalWidth - r.x);
|
|
298
|
+
r.h = Math.min(r.h, image.naturalHeight - r.y);
|
|
299
|
+
}
|
|
300
|
+
setCropRect(r);
|
|
301
|
+
setCropStart({ mx: e.clientX, my: e.clientY, rect: r });
|
|
302
|
+
};
|
|
303
|
+
const handleUp = () => {
|
|
304
|
+
setCropDragging(null);
|
|
305
|
+
setCropStart(null);
|
|
306
|
+
pushHistory();
|
|
307
|
+
};
|
|
308
|
+
window.addEventListener("mousemove", handleMove);
|
|
309
|
+
window.addEventListener("mouseup", handleUp);
|
|
310
|
+
return () => {
|
|
311
|
+
window.removeEventListener("mousemove", handleMove);
|
|
312
|
+
window.removeEventListener("mouseup", handleUp);
|
|
313
|
+
};
|
|
314
|
+
}, [cropDragging, cropStart, cropRect, image, cropAspect, getCanvasScale, pushHistory]);
|
|
315
|
+
// Compare slider drag
|
|
316
|
+
React.useEffect(() => {
|
|
317
|
+
if (!compareDragging)
|
|
318
|
+
return;
|
|
319
|
+
const handleMove = (e) => {
|
|
320
|
+
if (!containerRef.current)
|
|
321
|
+
return;
|
|
322
|
+
const rect = containerRef.current.getBoundingClientRect();
|
|
323
|
+
const pct = Math.max(0, Math.min(100, ((e.clientX - rect.left) / rect.width) * 100));
|
|
324
|
+
setComparePosition(pct);
|
|
325
|
+
};
|
|
326
|
+
const handleUp = () => setCompareDragging(false);
|
|
327
|
+
window.addEventListener("mousemove", handleMove);
|
|
328
|
+
window.addEventListener("mouseup", handleUp);
|
|
329
|
+
return () => {
|
|
330
|
+
window.removeEventListener("mousemove", handleMove);
|
|
331
|
+
window.removeEventListener("mouseup", handleUp);
|
|
332
|
+
};
|
|
333
|
+
}, [compareDragging]);
|
|
334
|
+
// ── Keyboard shortcuts ──
|
|
335
|
+
React.useEffect(() => {
|
|
336
|
+
const handleKey = (e) => {
|
|
337
|
+
if (e.ctrlKey && e.key === "z") {
|
|
338
|
+
e.preventDefault();
|
|
339
|
+
undo();
|
|
340
|
+
}
|
|
341
|
+
if (e.ctrlKey && e.key === "y") {
|
|
342
|
+
e.preventDefault();
|
|
343
|
+
redo();
|
|
344
|
+
}
|
|
345
|
+
};
|
|
346
|
+
window.addEventListener("keydown", handleKey);
|
|
347
|
+
return () => window.removeEventListener("keydown", handleKey);
|
|
348
|
+
}, [undo, redo]);
|
|
349
|
+
// ── Adjustments ──
|
|
350
|
+
const handleAdjChange = React.useCallback((key, value) => {
|
|
351
|
+
setAdjustments(prev => ({ ...prev, [key]: value }));
|
|
352
|
+
}, []);
|
|
353
|
+
const handleAdjChangeEnd = React.useCallback(() => pushHistory(), [pushHistory]);
|
|
354
|
+
// ── Overlay helpers ──
|
|
355
|
+
const addOverlay = React.useCallback((ov) => {
|
|
356
|
+
setOverlays(prev => [...prev, ov]);
|
|
357
|
+
setSelectedOverlayId(ov.id);
|
|
358
|
+
setTimeout(() => pushHistory(), 30);
|
|
359
|
+
}, [pushHistory]);
|
|
360
|
+
const updateOverlay = React.useCallback((id, patch) => {
|
|
361
|
+
setOverlays(prev => prev.map(o => o.id === id ? { ...o, ...patch } : o));
|
|
362
|
+
}, []);
|
|
363
|
+
const deleteOverlay = React.useCallback((id) => {
|
|
364
|
+
setOverlays(prev => prev.filter(o => o.id !== id));
|
|
365
|
+
if (selectedOverlayId === id)
|
|
366
|
+
setSelectedOverlayId(null);
|
|
367
|
+
setTimeout(() => pushHistory(), 30);
|
|
368
|
+
}, [selectedOverlayId, pushHistory]);
|
|
369
|
+
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)
|
|
373
|
+
return prev;
|
|
374
|
+
const copy = [...prev];
|
|
375
|
+
[copy[idx], copy[idx + 1]] = [copy[idx + 1], copy[idx]];
|
|
376
|
+
return copy;
|
|
377
|
+
});
|
|
378
|
+
}, []);
|
|
379
|
+
const moveOverlayBack = React.useCallback((id) => {
|
|
380
|
+
setOverlays(prev => {
|
|
381
|
+
const idx = prev.findIndex(o => o.id === id);
|
|
382
|
+
if (idx <= 0)
|
|
383
|
+
return prev;
|
|
384
|
+
const copy = [...prev];
|
|
385
|
+
[copy[idx - 1], copy[idx]] = [copy[idx], copy[idx - 1]];
|
|
386
|
+
return copy;
|
|
387
|
+
});
|
|
388
|
+
}, []);
|
|
389
|
+
// ── Canvas fraction from mouse event ──
|
|
390
|
+
const getCanvasFraction = React.useCallback((e) => {
|
|
391
|
+
if (!mainCanvasRef.current)
|
|
392
|
+
return { fx: 0.5, fy: 0.5 };
|
|
393
|
+
const rect = mainCanvasRef.current.getBoundingClientRect();
|
|
394
|
+
return {
|
|
395
|
+
fx: Math.max(0, Math.min(1, (e.clientX - rect.left) / rect.width)),
|
|
396
|
+
fy: Math.max(0, Math.min(1, (e.clientY - rect.top) / rect.height)),
|
|
397
|
+
};
|
|
398
|
+
}, []);
|
|
399
|
+
// ── Canvas mouse handlers ──
|
|
400
|
+
const handleCanvasMouseDown = React.useCallback((e) => {
|
|
401
|
+
var _a, _b, _c, _d;
|
|
402
|
+
if (cropMode)
|
|
403
|
+
return;
|
|
404
|
+
const { fx, fy } = getCanvasFraction(e);
|
|
405
|
+
if (activeTab === "draw") {
|
|
406
|
+
e.preventDefault();
|
|
407
|
+
setIsDrawing(true);
|
|
408
|
+
setLivePoints([[fx, fy]]);
|
|
409
|
+
return;
|
|
410
|
+
}
|
|
411
|
+
for (let i = overlays.length - 1; i >= 0; i--) {
|
|
412
|
+
const cw = (_b = (_a = mainCanvasRef.current) === null || _a === void 0 ? void 0 : _a.width) !== null && _b !== void 0 ? _b : 1;
|
|
413
|
+
const ch = (_d = (_c = mainCanvasRef.current) === null || _c === void 0 ? void 0 : _c.height) !== null && _d !== void 0 ? _d : 1;
|
|
414
|
+
if (photoOverlays.hitTestOverlay(overlays[i], fx, fy, cw, ch)) {
|
|
415
|
+
setSelectedOverlayId(overlays[i].id);
|
|
416
|
+
setOverlayDragging(true);
|
|
417
|
+
setOverlayDragStart({ mx: fx, my: fy, ox: overlays[i].x, oy: overlays[i].y });
|
|
418
|
+
e.preventDefault();
|
|
419
|
+
return;
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
setSelectedOverlayId(null);
|
|
423
|
+
}, [cropMode, activeTab, getCanvasFraction, overlays]);
|
|
424
|
+
const handleCanvasMouseMove = React.useCallback((e) => {
|
|
425
|
+
const { fx, fy } = getCanvasFraction(e);
|
|
426
|
+
if (isDrawing) {
|
|
427
|
+
setLivePoints(prev => [...prev, [fx, fy]]);
|
|
428
|
+
return;
|
|
429
|
+
}
|
|
430
|
+
if (overlayDragging && overlayDragStart && selectedOverlayId) {
|
|
431
|
+
const dx = fx - overlayDragStart.mx;
|
|
432
|
+
const dy = fy - overlayDragStart.my;
|
|
433
|
+
updateOverlay(selectedOverlayId, {
|
|
434
|
+
x: Math.max(0, Math.min(1, overlayDragStart.ox + dx)),
|
|
435
|
+
y: Math.max(0, Math.min(1, overlayDragStart.oy + dy)),
|
|
436
|
+
});
|
|
437
|
+
}
|
|
438
|
+
}, [getCanvasFraction, isDrawing, overlayDragging, overlayDragStart, selectedOverlayId, updateOverlay]);
|
|
439
|
+
const handleCanvasMouseUp = React.useCallback(() => {
|
|
440
|
+
if (isDrawing && livePoints.length > 1) {
|
|
441
|
+
const stroke = { points: [...livePoints], color: drawColor, width: drawWidth, opacity: 1 };
|
|
442
|
+
if (!drawingOverlayRef.current) {
|
|
443
|
+
const dOv = photoOverlays.createDrawingOverlay();
|
|
444
|
+
dOv.strokes.push(stroke);
|
|
445
|
+
drawingOverlayRef.current = dOv;
|
|
446
|
+
setOverlays(prev => [...prev, dOv]);
|
|
447
|
+
}
|
|
448
|
+
else {
|
|
449
|
+
const id = drawingOverlayRef.current.id;
|
|
450
|
+
setOverlays(prev => prev.map(o => o.id === id && o.type === "drawing"
|
|
451
|
+
? { ...o, strokes: [...o.strokes, stroke] }
|
|
452
|
+
: o));
|
|
453
|
+
}
|
|
454
|
+
setLivePoints([]);
|
|
455
|
+
setIsDrawing(false);
|
|
456
|
+
pushHistory();
|
|
457
|
+
return;
|
|
458
|
+
}
|
|
459
|
+
setIsDrawing(false);
|
|
460
|
+
setLivePoints([]);
|
|
461
|
+
if (overlayDragging) {
|
|
462
|
+
setOverlayDragging(false);
|
|
463
|
+
setOverlayDragStart(null);
|
|
464
|
+
pushHistory();
|
|
465
|
+
}
|
|
466
|
+
}, [isDrawing, livePoints, drawColor, drawWidth, overlayDragging, pushHistory]);
|
|
467
|
+
// ── Actions ──
|
|
468
|
+
const buildExportParams = React.useCallback(() => {
|
|
469
|
+
if (!image)
|
|
470
|
+
return null;
|
|
471
|
+
return { image, selectedFilter, filterParams, filterIntensity, adjustments, cropRect, rotation, flipH, flipV, overlays };
|
|
472
|
+
}, [image, selectedFilter, filterParams, filterIntensity, adjustments, cropRect, rotation, flipH, flipV, overlays]);
|
|
473
|
+
const handleSave = React.useCallback(async () => {
|
|
474
|
+
if (!image || !mainCanvasRef.current)
|
|
475
|
+
return;
|
|
476
|
+
const exportCanvas = document.createElement("canvas");
|
|
477
|
+
photoFilters.renderToCanvas(exportCanvas, image, selectedFilter, { ...filterParams, intensity: filterIntensity }, adjustments, cropRect, rotation, flipH, flipV);
|
|
478
|
+
if (overlays.length > 0) {
|
|
479
|
+
const ctx = exportCanvas.getContext("2d");
|
|
480
|
+
if (ctx)
|
|
481
|
+
photoOverlays.renderAllOverlays(ctx, overlays, exportCanvas.width, exportCanvas.height);
|
|
482
|
+
}
|
|
483
|
+
const file = await photoFilters.canvasToFile(exportCanvas, "player-photo.jpg", 0.92);
|
|
484
|
+
const editorState = photoOverlays.serializeEditorState({
|
|
485
|
+
filter: selectedFilter,
|
|
486
|
+
filterIntensity,
|
|
487
|
+
adjustments: { ...adjustments },
|
|
488
|
+
rotation,
|
|
489
|
+
flipH,
|
|
490
|
+
flipV,
|
|
491
|
+
cropRect: cropRect ? { ...cropRect } : null,
|
|
492
|
+
overlays,
|
|
493
|
+
});
|
|
494
|
+
onSave(file, editorState);
|
|
495
|
+
}, [image, selectedFilter, filterParams, filterIntensity, adjustments, cropRect, rotation, flipH, flipV, overlays, onSave]);
|
|
496
|
+
const handleReset = React.useCallback(() => {
|
|
497
|
+
setSelectedFilter("none");
|
|
498
|
+
setFilterIntensity(1);
|
|
499
|
+
setAdjustments({ ...photoFilters.DEFAULT_ADJUSTMENTS });
|
|
500
|
+
setRotation(0);
|
|
501
|
+
setFlipH(false);
|
|
502
|
+
setFlipV(false);
|
|
503
|
+
setOverlays([]);
|
|
504
|
+
setSelectedOverlayId(null);
|
|
505
|
+
if (image) {
|
|
506
|
+
setCropRect({ x: 0, y: 0, w: image.naturalWidth, h: image.naturalHeight });
|
|
507
|
+
}
|
|
508
|
+
setCropMode(false);
|
|
509
|
+
setZoom(1);
|
|
510
|
+
pushHistory();
|
|
511
|
+
}, [image, pushHistory]);
|
|
512
|
+
const handleDownload = React.useCallback(async () => {
|
|
513
|
+
const p = buildExportParams();
|
|
514
|
+
if (!p)
|
|
515
|
+
return;
|
|
516
|
+
const blob = await photoEditorActions.getExportBlob(p);
|
|
517
|
+
if (blob)
|
|
518
|
+
photoEditorActions.handleDownloadBlob(blob);
|
|
519
|
+
}, [buildExportParams]);
|
|
520
|
+
const handleCopyToClipboard = React.useCallback(async () => {
|
|
521
|
+
const p = buildExportParams();
|
|
522
|
+
if (!p)
|
|
523
|
+
return;
|
|
524
|
+
await photoEditorActions.handleCopyImageToClipboard(p);
|
|
525
|
+
}, [buildExportParams]);
|
|
526
|
+
const handleShareNative = React.useCallback(async () => {
|
|
527
|
+
const p = buildExportParams();
|
|
528
|
+
if (!p)
|
|
529
|
+
return;
|
|
530
|
+
const blob = await photoEditorActions.getExportBlob(p);
|
|
531
|
+
if (blob)
|
|
532
|
+
await photoEditorActions.handleNativeShare(blob);
|
|
533
|
+
}, [buildExportParams]);
|
|
534
|
+
// ── Return ──
|
|
535
|
+
return {
|
|
536
|
+
t,
|
|
537
|
+
playerColor,
|
|
538
|
+
onCancel,
|
|
539
|
+
accent,
|
|
540
|
+
accentDim,
|
|
541
|
+
image,
|
|
542
|
+
loading,
|
|
543
|
+
activeTab,
|
|
544
|
+
setActiveTab,
|
|
545
|
+
setCropMode,
|
|
546
|
+
selectedFilter,
|
|
547
|
+
setSelectedFilter,
|
|
548
|
+
filterIntensity,
|
|
549
|
+
setFilterIntensity,
|
|
550
|
+
filterCategory,
|
|
551
|
+
setFilterCategory,
|
|
552
|
+
filteredList,
|
|
553
|
+
generateThumbnail,
|
|
554
|
+
adjustments,
|
|
555
|
+
handleAdjChange,
|
|
556
|
+
handleAdjChangeEnd,
|
|
557
|
+
rotation,
|
|
558
|
+
setRotation,
|
|
559
|
+
flipH,
|
|
560
|
+
setFlipH,
|
|
561
|
+
flipV,
|
|
562
|
+
setFlipV,
|
|
563
|
+
zoom,
|
|
564
|
+
setZoom,
|
|
565
|
+
cropMode,
|
|
566
|
+
cropRect,
|
|
567
|
+
setCropRect,
|
|
568
|
+
cropAspect,
|
|
569
|
+
setCropAspect,
|
|
570
|
+
handleCropMouseDown,
|
|
571
|
+
showCompare,
|
|
572
|
+
setShowCompare,
|
|
573
|
+
comparePosition,
|
|
574
|
+
setCompareDragging,
|
|
575
|
+
overlays,
|
|
576
|
+
setOverlays,
|
|
577
|
+
selectedOverlayId,
|
|
578
|
+
setSelectedOverlayId,
|
|
579
|
+
selectedOverlay,
|
|
580
|
+
addOverlay,
|
|
581
|
+
updateOverlay,
|
|
582
|
+
deleteOverlay,
|
|
583
|
+
moveOverlayForward,
|
|
584
|
+
moveOverlayBack,
|
|
585
|
+
emojiCat,
|
|
586
|
+
setEmojiCat,
|
|
587
|
+
textDraft,
|
|
588
|
+
setTextDraft,
|
|
589
|
+
textColor,
|
|
590
|
+
setTextColor,
|
|
591
|
+
textBold,
|
|
592
|
+
setTextBold,
|
|
593
|
+
textItalic,
|
|
594
|
+
setTextItalic,
|
|
595
|
+
textOutline,
|
|
596
|
+
setTextOutline,
|
|
597
|
+
textFontSize,
|
|
598
|
+
setTextFontSize,
|
|
599
|
+
textBg,
|
|
600
|
+
setTextBg,
|
|
601
|
+
shapeStroke,
|
|
602
|
+
setShapeStroke,
|
|
603
|
+
shapeFill,
|
|
604
|
+
setShapeFill,
|
|
605
|
+
shapeStrokeW,
|
|
606
|
+
setShapeStrokeW,
|
|
607
|
+
frameColor,
|
|
608
|
+
setFrameColor,
|
|
609
|
+
frameThick,
|
|
610
|
+
setFrameThick,
|
|
611
|
+
drawColor,
|
|
612
|
+
setDrawColor,
|
|
613
|
+
drawWidth,
|
|
614
|
+
setDrawWidth,
|
|
615
|
+
drawingOverlayRef,
|
|
616
|
+
historyIdx,
|
|
617
|
+
historyLength: history.length,
|
|
618
|
+
undo,
|
|
619
|
+
redo,
|
|
620
|
+
pushHistory,
|
|
621
|
+
handleSave,
|
|
622
|
+
handleReset,
|
|
623
|
+
handleDownload,
|
|
624
|
+
handleCopyToClipboard,
|
|
625
|
+
handleShareNative,
|
|
626
|
+
mainCanvasRef,
|
|
627
|
+
compareCanvasRef,
|
|
628
|
+
containerRef,
|
|
629
|
+
handleCanvasMouseDown,
|
|
630
|
+
handleCanvasMouseMove,
|
|
631
|
+
handleCanvasMouseUp,
|
|
632
|
+
createEmojiOverlay: photoOverlays.createEmojiOverlay,
|
|
633
|
+
createTextOverlay: photoOverlays.createTextOverlay,
|
|
634
|
+
createShapeOverlay: photoOverlays.createShapeOverlay,
|
|
635
|
+
createFrameOverlay: photoOverlays.createFrameOverlay,
|
|
636
|
+
};
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
exports.usePhotoEditor = usePhotoEditor;
|
|
640
|
+
//# sourceMappingURL=usePhotoEditor.js.map
|