@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,871 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* photoFilters.ts — Canvas-based photo filter engine.
|
|
3
|
+
*
|
|
4
|
+
* Pure functions that operate on ImageData pixel arrays.
|
|
5
|
+
* Each filter takes ImageData + optional params and returns a new ImageData.
|
|
6
|
+
* Composable via `applyFilterChain`.
|
|
7
|
+
*/
|
|
8
|
+
const DEFAULT_ADJUSTMENTS = {
|
|
9
|
+
brightness: 0,
|
|
10
|
+
contrast: 0,
|
|
11
|
+
saturation: 0,
|
|
12
|
+
temperature: 0,
|
|
13
|
+
tint: 0,
|
|
14
|
+
exposure: 0,
|
|
15
|
+
highlights: 0,
|
|
16
|
+
shadows: 0,
|
|
17
|
+
sharpness: 0,
|
|
18
|
+
vignette: 0,
|
|
19
|
+
grain: 0,
|
|
20
|
+
blur: 0,
|
|
21
|
+
};
|
|
22
|
+
// ── Pixel helpers ──
|
|
23
|
+
function clamp(v) {
|
|
24
|
+
return v < 0 ? 0 : v > 255 ? 255 : v | 0;
|
|
25
|
+
}
|
|
26
|
+
function lerpColor(a, b, t) {
|
|
27
|
+
return clamp(a + (b - a) * t);
|
|
28
|
+
}
|
|
29
|
+
/** Create a working copy of ImageData */
|
|
30
|
+
function cloneImageData(src) {
|
|
31
|
+
return new ImageData(new Uint8ClampedArray(src.data), src.width, src.height);
|
|
32
|
+
}
|
|
33
|
+
/** Mix original and filtered based on intensity */
|
|
34
|
+
function blendIntensity(original, filtered, intensity) {
|
|
35
|
+
if (intensity >= 1)
|
|
36
|
+
return filtered;
|
|
37
|
+
if (intensity <= 0)
|
|
38
|
+
return cloneImageData(original);
|
|
39
|
+
const out = cloneImageData(original);
|
|
40
|
+
const od = out.data;
|
|
41
|
+
const fd = filtered.data;
|
|
42
|
+
for (let i = 0; i < od.length; i += 4) {
|
|
43
|
+
od[i] = lerpColor(od[i], fd[i], intensity);
|
|
44
|
+
od[i + 1] = lerpColor(od[i + 1], fd[i + 1], intensity);
|
|
45
|
+
od[i + 2] = lerpColor(od[i + 2], fd[i + 2], intensity);
|
|
46
|
+
}
|
|
47
|
+
return out;
|
|
48
|
+
}
|
|
49
|
+
// ── Core filter functions ──
|
|
50
|
+
function grayscale(data) {
|
|
51
|
+
const out = cloneImageData(data);
|
|
52
|
+
const d = out.data;
|
|
53
|
+
for (let i = 0; i < d.length; i += 4) {
|
|
54
|
+
const gray = 0.299 * d[i] + 0.587 * d[i + 1] + 0.114 * d[i + 2];
|
|
55
|
+
d[i] = d[i + 1] = d[i + 2] = gray;
|
|
56
|
+
}
|
|
57
|
+
return out;
|
|
58
|
+
}
|
|
59
|
+
function sepia(data) {
|
|
60
|
+
const out = cloneImageData(data);
|
|
61
|
+
const d = out.data;
|
|
62
|
+
for (let i = 0; i < d.length; i += 4) {
|
|
63
|
+
const r = d[i], g = d[i + 1], b = d[i + 2];
|
|
64
|
+
d[i] = clamp(r * 0.393 + g * 0.769 + b * 0.189);
|
|
65
|
+
d[i + 1] = clamp(r * 0.349 + g * 0.686 + b * 0.168);
|
|
66
|
+
d[i + 2] = clamp(r * 0.272 + g * 0.534 + b * 0.131);
|
|
67
|
+
}
|
|
68
|
+
return out;
|
|
69
|
+
}
|
|
70
|
+
function invert(data) {
|
|
71
|
+
const out = cloneImageData(data);
|
|
72
|
+
const d = out.data;
|
|
73
|
+
for (let i = 0; i < d.length; i += 4) {
|
|
74
|
+
d[i] = 255 - d[i];
|
|
75
|
+
d[i + 1] = 255 - d[i + 1];
|
|
76
|
+
d[i + 2] = 255 - d[i + 2];
|
|
77
|
+
}
|
|
78
|
+
return out;
|
|
79
|
+
}
|
|
80
|
+
function adjustBrightness(data, amount) {
|
|
81
|
+
const out = cloneImageData(data);
|
|
82
|
+
const d = out.data;
|
|
83
|
+
const adj = (amount / 100) * 128;
|
|
84
|
+
for (let i = 0; i < d.length; i += 4) {
|
|
85
|
+
d[i] = clamp(d[i] + adj);
|
|
86
|
+
d[i + 1] = clamp(d[i + 1] + adj);
|
|
87
|
+
d[i + 2] = clamp(d[i + 2] + adj);
|
|
88
|
+
}
|
|
89
|
+
return out;
|
|
90
|
+
}
|
|
91
|
+
function adjustContrast(data, amount) {
|
|
92
|
+
const out = cloneImageData(data);
|
|
93
|
+
const d = out.data;
|
|
94
|
+
const factor = (259 * (amount + 255)) / (255 * (259 - amount));
|
|
95
|
+
for (let i = 0; i < d.length; i += 4) {
|
|
96
|
+
d[i] = clamp(factor * (d[i] - 128) + 128);
|
|
97
|
+
d[i + 1] = clamp(factor * (d[i + 1] - 128) + 128);
|
|
98
|
+
d[i + 2] = clamp(factor * (d[i + 2] - 128) + 128);
|
|
99
|
+
}
|
|
100
|
+
return out;
|
|
101
|
+
}
|
|
102
|
+
function adjustSaturation(data, amount) {
|
|
103
|
+
const out = cloneImageData(data);
|
|
104
|
+
const d = out.data;
|
|
105
|
+
const sat = 1 + amount / 100;
|
|
106
|
+
for (let i = 0; i < d.length; i += 4) {
|
|
107
|
+
const gray = 0.2126 * d[i] + 0.7152 * d[i + 1] + 0.0722 * d[i + 2];
|
|
108
|
+
d[i] = clamp(gray + sat * (d[i] - gray));
|
|
109
|
+
d[i + 1] = clamp(gray + sat * (d[i + 1] - gray));
|
|
110
|
+
d[i + 2] = clamp(gray + sat * (d[i + 2] - gray));
|
|
111
|
+
}
|
|
112
|
+
return out;
|
|
113
|
+
}
|
|
114
|
+
function adjustTemperature(data, amount) {
|
|
115
|
+
const out = cloneImageData(data);
|
|
116
|
+
const d = out.data;
|
|
117
|
+
const adj = amount * 0.8;
|
|
118
|
+
for (let i = 0; i < d.length; i += 4) {
|
|
119
|
+
d[i] = clamp(d[i] + adj); // red
|
|
120
|
+
d[i + 2] = clamp(d[i + 2] - adj); // blue (inverse)
|
|
121
|
+
}
|
|
122
|
+
return out;
|
|
123
|
+
}
|
|
124
|
+
function adjustTint(data, amount) {
|
|
125
|
+
const out = cloneImageData(data);
|
|
126
|
+
const d = out.data;
|
|
127
|
+
const adj = amount * 0.5;
|
|
128
|
+
for (let i = 0; i < d.length; i += 4) {
|
|
129
|
+
d[i + 1] = clamp(d[i + 1] - adj); // decrease green for magenta, increase for green
|
|
130
|
+
}
|
|
131
|
+
return out;
|
|
132
|
+
}
|
|
133
|
+
function adjustExposure(data, amount) {
|
|
134
|
+
const out = cloneImageData(data);
|
|
135
|
+
const d = out.data;
|
|
136
|
+
const factor = Math.pow(2, amount / 50);
|
|
137
|
+
for (let i = 0; i < d.length; i += 4) {
|
|
138
|
+
d[i] = clamp(d[i] * factor);
|
|
139
|
+
d[i + 1] = clamp(d[i + 1] * factor);
|
|
140
|
+
d[i + 2] = clamp(d[i + 2] * factor);
|
|
141
|
+
}
|
|
142
|
+
return out;
|
|
143
|
+
}
|
|
144
|
+
function adjustHighlights(data, amount) {
|
|
145
|
+
const out = cloneImageData(data);
|
|
146
|
+
const d = out.data;
|
|
147
|
+
const adj = amount / 100;
|
|
148
|
+
for (let i = 0; i < d.length; i += 4) {
|
|
149
|
+
const lum = (d[i] + d[i + 1] + d[i + 2]) / 3;
|
|
150
|
+
if (lum > 128) {
|
|
151
|
+
const factor = ((lum - 128) / 127) * adj * 40;
|
|
152
|
+
d[i] = clamp(d[i] + factor);
|
|
153
|
+
d[i + 1] = clamp(d[i + 1] + factor);
|
|
154
|
+
d[i + 2] = clamp(d[i + 2] + factor);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
return out;
|
|
158
|
+
}
|
|
159
|
+
function adjustShadows(data, amount) {
|
|
160
|
+
const out = cloneImageData(data);
|
|
161
|
+
const d = out.data;
|
|
162
|
+
const adj = amount / 100;
|
|
163
|
+
for (let i = 0; i < d.length; i += 4) {
|
|
164
|
+
const lum = (d[i] + d[i + 1] + d[i + 2]) / 3;
|
|
165
|
+
if (lum < 128) {
|
|
166
|
+
const factor = ((128 - lum) / 128) * adj * 40;
|
|
167
|
+
d[i] = clamp(d[i] + factor);
|
|
168
|
+
d[i + 1] = clamp(d[i + 1] + factor);
|
|
169
|
+
d[i + 2] = clamp(d[i + 2] + factor);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
return out;
|
|
173
|
+
}
|
|
174
|
+
function posterize(data, levels = 4) {
|
|
175
|
+
const out = cloneImageData(data);
|
|
176
|
+
const d = out.data;
|
|
177
|
+
const step = 255 / (levels - 1);
|
|
178
|
+
for (let i = 0; i < d.length; i += 4) {
|
|
179
|
+
d[i] = clamp(Math.round(d[i] / step) * step);
|
|
180
|
+
d[i + 1] = clamp(Math.round(d[i + 1] / step) * step);
|
|
181
|
+
d[i + 2] = clamp(Math.round(d[i + 2] / step) * step);
|
|
182
|
+
}
|
|
183
|
+
return out;
|
|
184
|
+
}
|
|
185
|
+
function solarize(data) {
|
|
186
|
+
const out = cloneImageData(data);
|
|
187
|
+
const d = out.data;
|
|
188
|
+
for (let i = 0; i < d.length; i += 4) {
|
|
189
|
+
d[i] = d[i] > 128 ? 255 - d[i] : d[i];
|
|
190
|
+
d[i + 1] = d[i + 1] > 128 ? 255 - d[i + 1] : d[i + 1];
|
|
191
|
+
d[i + 2] = d[i + 2] > 128 ? 255 - d[i + 2] : d[i + 2];
|
|
192
|
+
}
|
|
193
|
+
return out;
|
|
194
|
+
}
|
|
195
|
+
function channelShift(data) {
|
|
196
|
+
const out = cloneImageData(data);
|
|
197
|
+
const d = out.data;
|
|
198
|
+
for (let i = 0; i < d.length; i += 4) {
|
|
199
|
+
const r = d[i], g = d[i + 1], b = d[i + 2];
|
|
200
|
+
d[i] = g; // R ← G
|
|
201
|
+
d[i + 1] = b; // G ← B
|
|
202
|
+
d[i + 2] = r; // B ← R
|
|
203
|
+
}
|
|
204
|
+
return out;
|
|
205
|
+
}
|
|
206
|
+
function cyberpunk(data) {
|
|
207
|
+
const out = cloneImageData(data);
|
|
208
|
+
const d = out.data;
|
|
209
|
+
for (let i = 0; i < d.length; i += 4) {
|
|
210
|
+
const lum = 0.299 * d[i] + 0.587 * d[i + 1] + 0.114 * d[i + 2];
|
|
211
|
+
d[i] = clamp(lum * 0.2 + d[i] * 0.8 + 30); // boost red
|
|
212
|
+
d[i + 1] = clamp(lum * 0.5 + d[i + 1] * 0.15 - 10); // crush green
|
|
213
|
+
d[i + 2] = clamp(lum * 0.3 + d[i + 2] * 0.9 + 50); // heavy blue
|
|
214
|
+
}
|
|
215
|
+
return out;
|
|
216
|
+
}
|
|
217
|
+
function retroWave(data) {
|
|
218
|
+
const out = cloneImageData(data);
|
|
219
|
+
const d = out.data;
|
|
220
|
+
for (let i = 0; i < d.length; i += 4) {
|
|
221
|
+
d[i] = clamp(d[i] * 1.1 + 20);
|
|
222
|
+
d[i + 1] = clamp(d[i + 1] * 0.6 - 10);
|
|
223
|
+
d[i + 2] = clamp(d[i + 2] * 1.3 + 30);
|
|
224
|
+
}
|
|
225
|
+
return adjustContrast(out, 30);
|
|
226
|
+
}
|
|
227
|
+
function vintageFilm(data) {
|
|
228
|
+
let out = cloneImageData(data);
|
|
229
|
+
const d = out.data;
|
|
230
|
+
// warm tone overlay
|
|
231
|
+
for (let i = 0; i < d.length; i += 4) {
|
|
232
|
+
d[i] = clamp(d[i] * 1.08 + 8);
|
|
233
|
+
d[i + 1] = clamp(d[i + 1] * 0.95 + 5);
|
|
234
|
+
d[i + 2] = clamp(d[i + 2] * 0.85 - 5);
|
|
235
|
+
}
|
|
236
|
+
out = adjustContrast(out, -15);
|
|
237
|
+
return adjustSaturation(out, -20);
|
|
238
|
+
}
|
|
239
|
+
function kodachrome(data) {
|
|
240
|
+
const out = cloneImageData(data);
|
|
241
|
+
const d = out.data;
|
|
242
|
+
for (let i = 0; i < d.length; i += 4) {
|
|
243
|
+
const r = d[i], g = d[i + 1], b = d[i + 2];
|
|
244
|
+
d[i] = clamp(r * 1.129 + g * 0.097 + b * 0.035 - 12);
|
|
245
|
+
d[i + 1] = clamp(r * 0.019 + g * 0.955 + b * 0.041 + 8);
|
|
246
|
+
d[i + 2] = clamp(r * 0.016 + g * 0.033 + b * 0.837 + 28);
|
|
247
|
+
}
|
|
248
|
+
return out;
|
|
249
|
+
}
|
|
250
|
+
function polaroid(data) {
|
|
251
|
+
const out = cloneImageData(data);
|
|
252
|
+
const d = out.data;
|
|
253
|
+
for (let i = 0; i < d.length; i += 4) {
|
|
254
|
+
const r = d[i], g = d[i + 1], b = d[i + 2];
|
|
255
|
+
d[i] = clamp(r * 1.438 - g * 0.062 - b * 0.062 + 10);
|
|
256
|
+
d[i + 1] = clamp(-r * 0.122 + g * 1.378 - b * 0.122 + 6);
|
|
257
|
+
d[i + 2] = clamp(-r * 0.016 - g * 0.016 + b * 1.483 - 12);
|
|
258
|
+
}
|
|
259
|
+
return out;
|
|
260
|
+
}
|
|
261
|
+
function technicolor(data) {
|
|
262
|
+
const out = cloneImageData(data);
|
|
263
|
+
const d = out.data;
|
|
264
|
+
for (let i = 0; i < d.length; i += 4) {
|
|
265
|
+
const r = d[i], g = d[i + 1], b = d[i + 2];
|
|
266
|
+
d[i] = clamp(r * 1.913 - g * 0.282 - b * 0.023);
|
|
267
|
+
d[i + 1] = clamp(-r * 0.204 + g * 1.397 - b * 0.018);
|
|
268
|
+
d[i + 2] = clamp(-r * 0.199 - g * 0.291 + b * 1.765);
|
|
269
|
+
}
|
|
270
|
+
return out;
|
|
271
|
+
}
|
|
272
|
+
function brownie(data) {
|
|
273
|
+
const out = cloneImageData(data);
|
|
274
|
+
const d = out.data;
|
|
275
|
+
for (let i = 0; i < d.length; i += 4) {
|
|
276
|
+
const r = d[i], g = d[i + 1], b = d[i + 2];
|
|
277
|
+
d[i] = clamp(r * 0.599 + g * 0.345 + b * 0.272);
|
|
278
|
+
d[i + 1] = clamp(r * 0.168 + g * 0.706 + b * 0.131);
|
|
279
|
+
d[i + 2] = clamp(r * 0.131 + g * 0.168 + b * 0.706);
|
|
280
|
+
}
|
|
281
|
+
return out;
|
|
282
|
+
}
|
|
283
|
+
function duotone(data, params) {
|
|
284
|
+
const out = cloneImageData(data);
|
|
285
|
+
const d = out.data;
|
|
286
|
+
const dark = hexToRgb((params === null || params === void 0 ? void 0 : params.darkColor) || '#001f3f');
|
|
287
|
+
const light = hexToRgb((params === null || params === void 0 ? void 0 : params.lightColor) || '#ff851b');
|
|
288
|
+
for (let i = 0; i < d.length; i += 4) {
|
|
289
|
+
const lum = (0.299 * d[i] + 0.587 * d[i + 1] + 0.114 * d[i + 2]) / 255;
|
|
290
|
+
d[i] = clamp(dark[0] + (light[0] - dark[0]) * lum);
|
|
291
|
+
d[i + 1] = clamp(dark[1] + (light[1] - dark[1]) * lum);
|
|
292
|
+
d[i + 2] = clamp(dark[2] + (light[2] - dark[2]) * lum);
|
|
293
|
+
}
|
|
294
|
+
return out;
|
|
295
|
+
}
|
|
296
|
+
function threshold(data, level = 128) {
|
|
297
|
+
const out = cloneImageData(data);
|
|
298
|
+
const d = out.data;
|
|
299
|
+
for (let i = 0; i < d.length; i += 4) {
|
|
300
|
+
const lum = 0.299 * d[i] + 0.587 * d[i + 1] + 0.114 * d[i + 2];
|
|
301
|
+
const v = lum >= level ? 255 : 0;
|
|
302
|
+
d[i] = d[i + 1] = d[i + 2] = v;
|
|
303
|
+
}
|
|
304
|
+
return out;
|
|
305
|
+
}
|
|
306
|
+
function emboss(data) {
|
|
307
|
+
return convolve(data, [
|
|
308
|
+
-2, -1, 0,
|
|
309
|
+
-1, 1, 1,
|
|
310
|
+
0, 1, 2,
|
|
311
|
+
]);
|
|
312
|
+
}
|
|
313
|
+
function edgeDetect(data) {
|
|
314
|
+
return convolve(data, [
|
|
315
|
+
-1, -1, -1,
|
|
316
|
+
-1, 8, -1,
|
|
317
|
+
-1, -1, -1,
|
|
318
|
+
]);
|
|
319
|
+
}
|
|
320
|
+
function sharpen(data, amount = 1) {
|
|
321
|
+
const k = amount;
|
|
322
|
+
return convolve(data, [
|
|
323
|
+
0, -k, 0,
|
|
324
|
+
-k, 1 + 4 * k, -k,
|
|
325
|
+
0, -k, 0,
|
|
326
|
+
]);
|
|
327
|
+
}
|
|
328
|
+
function comicBook(data) {
|
|
329
|
+
const edges = edgeDetect(data);
|
|
330
|
+
const poster = posterize(data, 5);
|
|
331
|
+
const out = cloneImageData(poster);
|
|
332
|
+
const d = out.data;
|
|
333
|
+
const ed = edges.data;
|
|
334
|
+
for (let i = 0; i < d.length; i += 4) {
|
|
335
|
+
const edgeLum = (ed[i] + ed[i + 1] + ed[i + 2]) / 3;
|
|
336
|
+
if (edgeLum > 30) {
|
|
337
|
+
d[i] = d[i + 1] = d[i + 2] = 0; // black edge lines
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
return adjustSaturation(out, 40);
|
|
341
|
+
}
|
|
342
|
+
function heatMap(data) {
|
|
343
|
+
const out = cloneImageData(data);
|
|
344
|
+
const d = out.data;
|
|
345
|
+
for (let i = 0; i < d.length; i += 4) {
|
|
346
|
+
const lum = (0.299 * d[i] + 0.587 * d[i + 1] + 0.114 * d[i + 2]) / 255;
|
|
347
|
+
// heatmap: blue → cyan → green → yellow → red
|
|
348
|
+
if (lum < 0.25) {
|
|
349
|
+
d[i] = 0;
|
|
350
|
+
d[i + 1] = clamp(lum * 4 * 255);
|
|
351
|
+
d[i + 2] = 255;
|
|
352
|
+
}
|
|
353
|
+
else if (lum < 0.5) {
|
|
354
|
+
d[i] = 0;
|
|
355
|
+
d[i + 1] = 255;
|
|
356
|
+
d[i + 2] = clamp((1 - (lum - 0.25) * 4) * 255);
|
|
357
|
+
}
|
|
358
|
+
else if (lum < 0.75) {
|
|
359
|
+
d[i] = clamp((lum - 0.5) * 4 * 255);
|
|
360
|
+
d[i + 1] = 255;
|
|
361
|
+
d[i + 2] = 0;
|
|
362
|
+
}
|
|
363
|
+
else {
|
|
364
|
+
d[i] = 255;
|
|
365
|
+
d[i + 1] = clamp((1 - (lum - 0.75) * 4) * 255);
|
|
366
|
+
d[i + 2] = 0;
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
return out;
|
|
370
|
+
}
|
|
371
|
+
function nightVision(data) {
|
|
372
|
+
const out = cloneImageData(data);
|
|
373
|
+
const d = out.data;
|
|
374
|
+
for (let i = 0; i < d.length; i += 4) {
|
|
375
|
+
const lum = 0.299 * d[i] + 0.587 * d[i + 1] + 0.114 * d[i + 2];
|
|
376
|
+
d[i] = 0;
|
|
377
|
+
d[i + 1] = clamp(lum * 1.4 + 10);
|
|
378
|
+
d[i + 2] = 0;
|
|
379
|
+
}
|
|
380
|
+
return out;
|
|
381
|
+
}
|
|
382
|
+
function xRay(data) {
|
|
383
|
+
let out = invert(data);
|
|
384
|
+
out = grayscale(out);
|
|
385
|
+
return adjustContrast(out, 40);
|
|
386
|
+
}
|
|
387
|
+
function crossProcess(data) {
|
|
388
|
+
const out = cloneImageData(data);
|
|
389
|
+
const d = out.data;
|
|
390
|
+
for (let i = 0; i < d.length; i += 4) {
|
|
391
|
+
// S-curve on green, inverse on blue
|
|
392
|
+
d[i] = clamp(d[i] * 1.1 + 10);
|
|
393
|
+
d[i + 1] = clamp(Math.pow(d[i + 1] / 255, 0.85) * 280);
|
|
394
|
+
d[i + 2] = clamp(255 - (255 - d[i + 2]) * 0.7);
|
|
395
|
+
}
|
|
396
|
+
return out;
|
|
397
|
+
}
|
|
398
|
+
function lomoLeaks(data) {
|
|
399
|
+
const out = cloneImageData(data);
|
|
400
|
+
const d = out.data;
|
|
401
|
+
const w = data.width, h = data.height;
|
|
402
|
+
for (let y = 0; y < h; y++) {
|
|
403
|
+
for (let x = 0; x < w; x++) {
|
|
404
|
+
const i = (y * w + x) * 4;
|
|
405
|
+
// Warm light leak from top-left
|
|
406
|
+
const dist = Math.sqrt(x * x + y * y) / Math.sqrt(w * w + h * h);
|
|
407
|
+
const leak = Math.max(0, 1 - dist * 1.8) * 60;
|
|
408
|
+
d[i] = clamp(d[i] + leak * 1.5);
|
|
409
|
+
d[i + 1] = clamp(d[i + 1] + leak * 0.8);
|
|
410
|
+
d[i + 2] = clamp(d[i + 2] - leak * 0.3);
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
return adjustSaturation(out, 15);
|
|
414
|
+
}
|
|
415
|
+
function fadeOut(data) {
|
|
416
|
+
let out = cloneImageData(data);
|
|
417
|
+
out = adjustContrast(out, -30);
|
|
418
|
+
const d = out.data;
|
|
419
|
+
for (let i = 0; i < d.length; i += 4) {
|
|
420
|
+
d[i] = clamp(d[i] + 25);
|
|
421
|
+
d[i + 1] = clamp(d[i + 1] + 20);
|
|
422
|
+
d[i + 2] = clamp(d[i + 2] + 30);
|
|
423
|
+
}
|
|
424
|
+
return adjustSaturation(out, -30);
|
|
425
|
+
}
|
|
426
|
+
function glitch(data) {
|
|
427
|
+
const out = cloneImageData(data);
|
|
428
|
+
const d = out.data;
|
|
429
|
+
const w = data.width;
|
|
430
|
+
// Shift some rows horizontally by random amounts
|
|
431
|
+
for (let y = 0; y < data.height; y++) {
|
|
432
|
+
if (Math.random() > 0.92) {
|
|
433
|
+
const shift = Math.floor(Math.random() * 30 - 15);
|
|
434
|
+
for (let x = 0; x < w; x++) {
|
|
435
|
+
const srcX = ((x + shift) % w + w) % w;
|
|
436
|
+
const di = (y * w + x) * 4;
|
|
437
|
+
const si = (y * w + srcX) * 4;
|
|
438
|
+
// Red channel from shifted position
|
|
439
|
+
d[di] = data.data[si];
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
return out;
|
|
444
|
+
}
|
|
445
|
+
function pixelate(data, blockSize = 8) {
|
|
446
|
+
const out = cloneImageData(data);
|
|
447
|
+
const d = out.data;
|
|
448
|
+
const w = data.width, h = data.height;
|
|
449
|
+
for (let by = 0; by < h; by += blockSize) {
|
|
450
|
+
for (let bx = 0; bx < w; bx += blockSize) {
|
|
451
|
+
let rSum = 0, gSum = 0, bSum = 0, count = 0;
|
|
452
|
+
for (let dy = 0; dy < blockSize && by + dy < h; dy++) {
|
|
453
|
+
for (let dx = 0; dx < blockSize && bx + dx < w; dx++) {
|
|
454
|
+
const i = ((by + dy) * w + (bx + dx)) * 4;
|
|
455
|
+
rSum += d[i];
|
|
456
|
+
gSum += d[i + 1];
|
|
457
|
+
bSum += d[i + 2];
|
|
458
|
+
count++;
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
const rAvg = rSum / count, gAvg = gSum / count, bAvg = bSum / count;
|
|
462
|
+
for (let dy = 0; dy < blockSize && by + dy < h; dy++) {
|
|
463
|
+
for (let dx = 0; dx < blockSize && bx + dx < w; dx++) {
|
|
464
|
+
const i = ((by + dy) * w + (bx + dx)) * 4;
|
|
465
|
+
d[i] = rAvg;
|
|
466
|
+
d[i + 1] = gAvg;
|
|
467
|
+
d[i + 2] = bAvg;
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
return out;
|
|
473
|
+
}
|
|
474
|
+
function oilPainting(data, radius = 3) {
|
|
475
|
+
const out = cloneImageData(data);
|
|
476
|
+
const d = out.data;
|
|
477
|
+
const src = data.data;
|
|
478
|
+
const w = data.width, h = data.height;
|
|
479
|
+
const levels = 20;
|
|
480
|
+
for (let y = 0; y < h; y++) {
|
|
481
|
+
for (let x = 0; x < w; x++) {
|
|
482
|
+
const counts = new Int32Array(levels);
|
|
483
|
+
const rSum = new Float64Array(levels);
|
|
484
|
+
const gSum = new Float64Array(levels);
|
|
485
|
+
const bSum = new Float64Array(levels);
|
|
486
|
+
for (let ky = -radius; ky <= radius; ky++) {
|
|
487
|
+
for (let kx = -radius; kx <= radius; kx++) {
|
|
488
|
+
const ny = Math.min(h - 1, Math.max(0, y + ky));
|
|
489
|
+
const nx = Math.min(w - 1, Math.max(0, x + kx));
|
|
490
|
+
const ni = (ny * w + nx) * 4;
|
|
491
|
+
const lum = Math.floor(((src[ni] + src[ni + 1] + src[ni + 2]) / 3) * levels / 256);
|
|
492
|
+
const li = Math.min(lum, levels - 1);
|
|
493
|
+
counts[li]++;
|
|
494
|
+
rSum[li] += src[ni];
|
|
495
|
+
gSum[li] += src[ni + 1];
|
|
496
|
+
bSum[li] += src[ni + 2];
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
let maxCount = 0, maxIdx = 0;
|
|
500
|
+
for (let l = 0; l < levels; l++) {
|
|
501
|
+
if (counts[l] > maxCount) {
|
|
502
|
+
maxCount = counts[l];
|
|
503
|
+
maxIdx = l;
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
const i = (y * w + x) * 4;
|
|
507
|
+
d[i] = rSum[maxIdx] / maxCount;
|
|
508
|
+
d[i + 1] = gSum[maxIdx] / maxCount;
|
|
509
|
+
d[i + 2] = bSum[maxIdx] / maxCount;
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
return out;
|
|
513
|
+
}
|
|
514
|
+
function tiltShift(data) {
|
|
515
|
+
// Simple blur for top and bottom thirds
|
|
516
|
+
const out = cloneImageData(data);
|
|
517
|
+
const d = out.data;
|
|
518
|
+
const src = data.data;
|
|
519
|
+
const w = data.width, h = data.height;
|
|
520
|
+
const centerY = h / 2;
|
|
521
|
+
const focusHalf = h * 0.15;
|
|
522
|
+
for (let y = 0; y < h; y++) {
|
|
523
|
+
const dist = Math.abs(y - centerY);
|
|
524
|
+
const blurRadius = dist < focusHalf ? 0 : Math.min(6, Math.floor((dist - focusHalf) / (h * 0.1)));
|
|
525
|
+
if (blurRadius === 0)
|
|
526
|
+
continue;
|
|
527
|
+
for (let x = 0; x < w; x++) {
|
|
528
|
+
let rSum = 0, gSum = 0, bSum = 0, count = 0;
|
|
529
|
+
for (let ky = -blurRadius; ky <= blurRadius; ky++) {
|
|
530
|
+
for (let kx = -blurRadius; kx <= blurRadius; kx++) {
|
|
531
|
+
const ny = Math.min(h - 1, Math.max(0, y + ky));
|
|
532
|
+
const nx = Math.min(w - 1, Math.max(0, x + kx));
|
|
533
|
+
const si = (ny * w + nx) * 4;
|
|
534
|
+
rSum += src[si];
|
|
535
|
+
gSum += src[si + 1];
|
|
536
|
+
bSum += src[si + 2];
|
|
537
|
+
count++;
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
const i = (y * w + x) * 4;
|
|
541
|
+
d[i] = rSum / count;
|
|
542
|
+
d[i + 1] = gSum / count;
|
|
543
|
+
d[i + 2] = bSum / count;
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
return adjustSaturation(out, 20);
|
|
547
|
+
}
|
|
548
|
+
function pencilSketch(data) {
|
|
549
|
+
const gray = grayscale(data);
|
|
550
|
+
const inv = invert(gray);
|
|
551
|
+
// Simple Gaussian-like blur on inverted
|
|
552
|
+
const blurred = boxBlur(inv, 8);
|
|
553
|
+
const out = cloneImageData(gray);
|
|
554
|
+
const d = out.data;
|
|
555
|
+
const bd = blurred.data;
|
|
556
|
+
// Color dodge blend
|
|
557
|
+
for (let i = 0; i < d.length; i += 4) {
|
|
558
|
+
const base = d[i];
|
|
559
|
+
const blend = bd[i];
|
|
560
|
+
const r = blend === 255 ? 255 : clamp((base * 256) / (255 - blend));
|
|
561
|
+
d[i] = d[i + 1] = d[i + 2] = r;
|
|
562
|
+
}
|
|
563
|
+
return out;
|
|
564
|
+
}
|
|
565
|
+
function watercolor(data) {
|
|
566
|
+
let out = boxBlur(data, 3);
|
|
567
|
+
out = adjustSaturation(out, 30);
|
|
568
|
+
out = adjustContrast(out, -10);
|
|
569
|
+
// Slight edge darkening
|
|
570
|
+
const edges = edgeDetect(data);
|
|
571
|
+
const d = out.data;
|
|
572
|
+
const ed = edges.data;
|
|
573
|
+
for (let i = 0; i < d.length; i += 4) {
|
|
574
|
+
const edgeLum = (ed[i] + ed[i + 1] + ed[i + 2]) / 3;
|
|
575
|
+
const darken = Math.min(edgeLum * 0.15, 25);
|
|
576
|
+
d[i] = clamp(d[i] - darken);
|
|
577
|
+
d[i + 1] = clamp(d[i + 1] - darken);
|
|
578
|
+
d[i + 2] = clamp(d[i + 2] - darken);
|
|
579
|
+
}
|
|
580
|
+
return out;
|
|
581
|
+
}
|
|
582
|
+
function dreamyGlow(data) {
|
|
583
|
+
const blurred = boxBlur(data, 6);
|
|
584
|
+
const out = cloneImageData(data);
|
|
585
|
+
const d = out.data;
|
|
586
|
+
const bd = blurred.data;
|
|
587
|
+
// Screen blend
|
|
588
|
+
for (let i = 0; i < d.length; i += 4) {
|
|
589
|
+
d[i] = clamp(255 - ((255 - d[i]) * (255 - bd[i])) / 255);
|
|
590
|
+
d[i + 1] = clamp(255 - ((255 - d[i + 1]) * (255 - bd[i + 1])) / 255);
|
|
591
|
+
d[i + 2] = clamp(255 - ((255 - d[i + 2]) * (255 - bd[i + 2])) / 255);
|
|
592
|
+
}
|
|
593
|
+
return adjustSaturation(out, 15);
|
|
594
|
+
}
|
|
595
|
+
function frostedGlass(data) {
|
|
596
|
+
const out = cloneImageData(data);
|
|
597
|
+
const d = out.data;
|
|
598
|
+
const src = data.data;
|
|
599
|
+
const w = data.width, h = data.height;
|
|
600
|
+
const radius = 4;
|
|
601
|
+
for (let y = 0; y < h; y++) {
|
|
602
|
+
for (let x = 0; x < w; x++) {
|
|
603
|
+
const ox = x + Math.floor(Math.random() * radius * 2 - radius);
|
|
604
|
+
const oy = y + Math.floor(Math.random() * radius * 2 - radius);
|
|
605
|
+
const nx = Math.min(w - 1, Math.max(0, ox));
|
|
606
|
+
const ny = Math.min(h - 1, Math.max(0, oy));
|
|
607
|
+
const di = (y * w + x) * 4;
|
|
608
|
+
const si = (ny * w + nx) * 4;
|
|
609
|
+
d[di] = src[si];
|
|
610
|
+
d[di + 1] = src[si + 1];
|
|
611
|
+
d[di + 2] = src[si + 2];
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
return out;
|
|
615
|
+
}
|
|
616
|
+
function pop(data) {
|
|
617
|
+
let out = adjustSaturation(data, 50);
|
|
618
|
+
out = adjustContrast(out, 20);
|
|
619
|
+
return adjustBrightness(out, 5);
|
|
620
|
+
}
|
|
621
|
+
function moody(data) {
|
|
622
|
+
let out = adjustSaturation(data, -25);
|
|
623
|
+
out = adjustContrast(out, 15);
|
|
624
|
+
out = adjustTemperature(out, -15);
|
|
625
|
+
return adjustBrightness(out, -10);
|
|
626
|
+
}
|
|
627
|
+
function golden(data) {
|
|
628
|
+
const out = cloneImageData(data);
|
|
629
|
+
const d = out.data;
|
|
630
|
+
for (let i = 0; i < d.length; i += 4) {
|
|
631
|
+
const lum = (d[i] + d[i + 1] + d[i + 2]) / 3;
|
|
632
|
+
d[i] = clamp(lum * 0.4 + d[i] * 0.7 + 20);
|
|
633
|
+
d[i + 1] = clamp(lum * 0.3 + d[i + 1] * 0.6 + 10);
|
|
634
|
+
d[i + 2] = clamp(lum * 0.1 + d[i + 2] * 0.3 - 10);
|
|
635
|
+
}
|
|
636
|
+
return adjustContrast(out, 10);
|
|
637
|
+
}
|
|
638
|
+
function radioactive(data) {
|
|
639
|
+
const out = cloneImageData(data);
|
|
640
|
+
const d = out.data;
|
|
641
|
+
for (let i = 0; i < d.length; i += 4) {
|
|
642
|
+
d[i] = clamp(d[i] * 0.3);
|
|
643
|
+
d[i + 1] = clamp(d[i + 1] * 1.6 + 30);
|
|
644
|
+
d[i + 2] = clamp(d[i + 2] * 0.2);
|
|
645
|
+
}
|
|
646
|
+
return out;
|
|
647
|
+
}
|
|
648
|
+
function arctic(data) {
|
|
649
|
+
let out = adjustTemperature(data, -50);
|
|
650
|
+
out = adjustSaturation(out, -15);
|
|
651
|
+
out = adjustBrightness(out, 10);
|
|
652
|
+
return adjustContrast(out, 10);
|
|
653
|
+
}
|
|
654
|
+
function sunset(data) {
|
|
655
|
+
const out = cloneImageData(data);
|
|
656
|
+
const d = out.data;
|
|
657
|
+
for (let i = 0; i < d.length; i += 4) {
|
|
658
|
+
d[i] = clamp(d[i] * 1.15 + 15);
|
|
659
|
+
d[i + 1] = clamp(d[i + 1] * 0.85 + 5);
|
|
660
|
+
d[i + 2] = clamp(d[i + 2] * 0.65 - 10);
|
|
661
|
+
}
|
|
662
|
+
return adjustContrast(out, 10);
|
|
663
|
+
}
|
|
664
|
+
// ── Convolution helper ──
|
|
665
|
+
function convolve(data, kernel) {
|
|
666
|
+
const out = cloneImageData(data);
|
|
667
|
+
const d = out.data;
|
|
668
|
+
const src = data.data;
|
|
669
|
+
const w = data.width, h = data.height;
|
|
670
|
+
const size = Math.sqrt(kernel.length) | 0;
|
|
671
|
+
const half = (size >> 1);
|
|
672
|
+
for (let y = 0; y < h; y++) {
|
|
673
|
+
for (let x = 0; x < w; x++) {
|
|
674
|
+
let r = 0, g = 0, b = 0;
|
|
675
|
+
for (let ky = 0; ky < size; ky++) {
|
|
676
|
+
for (let kx = 0; kx < size; kx++) {
|
|
677
|
+
const ny = Math.min(h - 1, Math.max(0, y + ky - half));
|
|
678
|
+
const nx = Math.min(w - 1, Math.max(0, x + kx - half));
|
|
679
|
+
const weight = kernel[ky * size + kx];
|
|
680
|
+
const si = (ny * w + nx) * 4;
|
|
681
|
+
r += src[si] * weight;
|
|
682
|
+
g += src[si + 1] * weight;
|
|
683
|
+
b += src[si + 2] * weight;
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
const i = (y * w + x) * 4;
|
|
687
|
+
d[i] = clamp(r);
|
|
688
|
+
d[i + 1] = clamp(g);
|
|
689
|
+
d[i + 2] = clamp(b);
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
return out;
|
|
693
|
+
}
|
|
694
|
+
function boxBlur(data, radius) {
|
|
695
|
+
const size = radius * 2 + 1;
|
|
696
|
+
const weight = 1 / (size * size);
|
|
697
|
+
const kernel = new Array(size * size).fill(weight);
|
|
698
|
+
return convolve(data, kernel);
|
|
699
|
+
}
|
|
700
|
+
function hexToRgb(hex) {
|
|
701
|
+
const h = hex.replace('#', '');
|
|
702
|
+
return [
|
|
703
|
+
parseInt(h.substring(0, 2), 16),
|
|
704
|
+
parseInt(h.substring(2, 4), 16),
|
|
705
|
+
parseInt(h.substring(4, 6), 16),
|
|
706
|
+
];
|
|
707
|
+
}
|
|
708
|
+
// ── Canvas helpers for vignette & grain (applied via context) ──
|
|
709
|
+
function applyVignette(ctx, w, h, amount) {
|
|
710
|
+
if (amount <= 0)
|
|
711
|
+
return;
|
|
712
|
+
const cx = w / 2, cy = h / 2;
|
|
713
|
+
const radius = Math.max(w, h) * 0.7;
|
|
714
|
+
const grad = ctx.createRadialGradient(cx, cy, radius * 0.4, cx, cy, radius);
|
|
715
|
+
grad.addColorStop(0, 'rgba(0,0,0,0)');
|
|
716
|
+
grad.addColorStop(1, `rgba(0,0,0,${amount / 100 * 0.7})`);
|
|
717
|
+
ctx.fillStyle = grad;
|
|
718
|
+
ctx.fillRect(0, 0, w, h);
|
|
719
|
+
}
|
|
720
|
+
function applyGrain(ctx, w, h, amount) {
|
|
721
|
+
if (amount <= 0)
|
|
722
|
+
return;
|
|
723
|
+
const imageData = ctx.getImageData(0, 0, w, h);
|
|
724
|
+
const d = imageData.data;
|
|
725
|
+
const intensity = amount / 100 * 50;
|
|
726
|
+
for (let i = 0; i < d.length; i += 4) {
|
|
727
|
+
const noise = (Math.random() - 0.5) * intensity;
|
|
728
|
+
d[i] = clamp(d[i] + noise);
|
|
729
|
+
d[i + 1] = clamp(d[i + 1] + noise);
|
|
730
|
+
d[i + 2] = clamp(d[i + 2] + noise);
|
|
731
|
+
}
|
|
732
|
+
ctx.putImageData(imageData, 0, 0);
|
|
733
|
+
}
|
|
734
|
+
// ── Filter catalog ──
|
|
735
|
+
const PHOTO_FILTERS = [
|
|
736
|
+
// Color
|
|
737
|
+
{ id: 'none', name: 'Oryginał', category: 'color', icon: '🔲', apply: (d) => cloneImageData(d) },
|
|
738
|
+
{ id: 'grayscale', name: 'Cz/B', category: 'color', icon: '⬛', apply: (d, p) => { var _a; return blendIntensity(d, grayscale(d), (_a = p === null || p === void 0 ? void 0 : p.intensity) !== null && _a !== void 0 ? _a : 1); } },
|
|
739
|
+
{ id: 'sepia', name: 'Sepia', category: 'color', icon: '🟤', apply: (d, p) => { var _a; return blendIntensity(d, sepia(d), (_a = p === null || p === void 0 ? void 0 : p.intensity) !== null && _a !== void 0 ? _a : 1); } },
|
|
740
|
+
{ id: 'invert', name: 'Negatyw', category: 'color', icon: '🔄', apply: (d, p) => { var _a; return blendIntensity(d, invert(d), (_a = p === null || p === void 0 ? void 0 : p.intensity) !== null && _a !== void 0 ? _a : 1); } },
|
|
741
|
+
{ id: 'duotone', name: 'Duotone', category: 'color', icon: '🎨', apply: (d, p) => { var _a; return blendIntensity(d, duotone(d, p), (_a = p === null || p === void 0 ? void 0 : p.intensity) !== null && _a !== void 0 ? _a : 1); } },
|
|
742
|
+
{ id: 'channelShift', name: 'Channel Shift', category: 'color', icon: '🌈', apply: (d, p) => { var _a; return blendIntensity(d, channelShift(d), (_a = p === null || p === void 0 ? void 0 : p.intensity) !== null && _a !== void 0 ? _a : 1); } },
|
|
743
|
+
{ id: 'threshold', name: 'Próg', category: 'color', icon: '⚫', apply: (d, p) => { var _a; return blendIntensity(d, threshold(d), (_a = p === null || p === void 0 ? void 0 : p.intensity) !== null && _a !== void 0 ? _a : 1); } },
|
|
744
|
+
{ id: 'pop', name: 'Pop', category: 'color', icon: '💥', apply: (d, p) => { var _a; return blendIntensity(d, pop(d), (_a = p === null || p === void 0 ? void 0 : p.intensity) !== null && _a !== void 0 ? _a : 1); } },
|
|
745
|
+
// Light
|
|
746
|
+
{ id: 'dreamyGlow', name: 'Dreamy Glow', category: 'light', icon: '✨', apply: (d, p) => { var _a; return blendIntensity(d, dreamyGlow(d), (_a = p === null || p === void 0 ? void 0 : p.intensity) !== null && _a !== void 0 ? _a : 1); } },
|
|
747
|
+
{ id: 'lomoLeaks', name: 'Light Leaks', category: 'light', icon: '☀️', apply: (d, p) => { var _a; return blendIntensity(d, lomoLeaks(d), (_a = p === null || p === void 0 ? void 0 : p.intensity) !== null && _a !== void 0 ? _a : 1); } },
|
|
748
|
+
{ id: 'fadeOut', name: 'Fade', category: 'light', icon: '🌫️', apply: (d, p) => { var _a; return blendIntensity(d, fadeOut(d), (_a = p === null || p === void 0 ? void 0 : p.intensity) !== null && _a !== void 0 ? _a : 1); } },
|
|
749
|
+
{ id: 'golden', name: 'Golden', category: 'light', icon: '🌟', apply: (d, p) => { var _a; return blendIntensity(d, golden(d), (_a = p === null || p === void 0 ? void 0 : p.intensity) !== null && _a !== void 0 ? _a : 1); } },
|
|
750
|
+
{ id: 'sunset', name: 'Sunset', category: 'light', icon: '🌅', apply: (d, p) => { var _a; return blendIntensity(d, sunset(d), (_a = p === null || p === void 0 ? void 0 : p.intensity) !== null && _a !== void 0 ? _a : 1); } },
|
|
751
|
+
{ id: 'moody', name: 'Moody', category: 'light', icon: '🌑', apply: (d, p) => { var _a; return blendIntensity(d, moody(d), (_a = p === null || p === void 0 ? void 0 : p.intensity) !== null && _a !== void 0 ? _a : 1); } },
|
|
752
|
+
{ id: 'arctic', name: 'Arctic', category: 'light', icon: '❄️', apply: (d, p) => { var _a; return blendIntensity(d, arctic(d), (_a = p === null || p === void 0 ? void 0 : p.intensity) !== null && _a !== void 0 ? _a : 1); } },
|
|
753
|
+
// Vintage
|
|
754
|
+
{ id: 'vintageFilm', name: 'Vintage Film', category: 'vintage', icon: '🎞️', apply: (d, p) => { var _a; return blendIntensity(d, vintageFilm(d), (_a = p === null || p === void 0 ? void 0 : p.intensity) !== null && _a !== void 0 ? _a : 1); } },
|
|
755
|
+
{ id: 'kodachrome', name: 'Kodachrome', category: 'vintage', icon: '📷', apply: (d, p) => { var _a; return blendIntensity(d, kodachrome(d), (_a = p === null || p === void 0 ? void 0 : p.intensity) !== null && _a !== void 0 ? _a : 1); } },
|
|
756
|
+
{ id: 'polaroid', name: 'Polaroid', category: 'vintage', icon: '📸', apply: (d, p) => { var _a; return blendIntensity(d, polaroid(d), (_a = p === null || p === void 0 ? void 0 : p.intensity) !== null && _a !== void 0 ? _a : 1); } },
|
|
757
|
+
{ id: 'technicolor', name: 'Technicolor', category: 'vintage', icon: '🎬', apply: (d, p) => { var _a; return blendIntensity(d, technicolor(d), (_a = p === null || p === void 0 ? void 0 : p.intensity) !== null && _a !== void 0 ? _a : 1); } },
|
|
758
|
+
{ id: 'brownie', name: 'Brownie', category: 'vintage', icon: '🍫', apply: (d, p) => { var _a; return blendIntensity(d, brownie(d), (_a = p === null || p === void 0 ? void 0 : p.intensity) !== null && _a !== void 0 ? _a : 1); } },
|
|
759
|
+
{ id: 'crossProcess', name: 'Cross Process', category: 'vintage', icon: '🧪', apply: (d, p) => { var _a; return blendIntensity(d, crossProcess(d), (_a = p === null || p === void 0 ? void 0 : p.intensity) !== null && _a !== void 0 ? _a : 1); } },
|
|
760
|
+
// Artistic
|
|
761
|
+
{ id: 'pencilSketch', name: 'Ołówek', category: 'artistic', icon: '✏️', apply: (d, p) => { var _a; return blendIntensity(d, pencilSketch(d), (_a = p === null || p === void 0 ? void 0 : p.intensity) !== null && _a !== void 0 ? _a : 1); } },
|
|
762
|
+
{ id: 'oilPainting', name: 'Olej', category: 'artistic', icon: '🎨', apply: (d, p) => { var _a; return blendIntensity(d, oilPainting(d), (_a = p === null || p === void 0 ? void 0 : p.intensity) !== null && _a !== void 0 ? _a : 1); } },
|
|
763
|
+
{ id: 'watercolor', name: 'Akwarela', category: 'artistic', icon: '🖌️', apply: (d, p) => { var _a; return blendIntensity(d, watercolor(d), (_a = p === null || p === void 0 ? void 0 : p.intensity) !== null && _a !== void 0 ? _a : 1); } },
|
|
764
|
+
{ id: 'comicBook', name: 'Komiks', category: 'artistic', icon: '💬', apply: (d, p) => { var _a; return blendIntensity(d, comicBook(d), (_a = p === null || p === void 0 ? void 0 : p.intensity) !== null && _a !== void 0 ? _a : 1); } },
|
|
765
|
+
{ id: 'posterize', name: 'Plakat', category: 'artistic', icon: '🖼️', apply: (d, p) => { var _a; return blendIntensity(d, posterize(d, 5), (_a = p === null || p === void 0 ? void 0 : p.intensity) !== null && _a !== void 0 ? _a : 1); } },
|
|
766
|
+
{ id: 'emboss', name: 'Płaskorzeźba', category: 'artistic', icon: '🗿', apply: (d, p) => { var _a; return blendIntensity(d, emboss(d), (_a = p === null || p === void 0 ? void 0 : p.intensity) !== null && _a !== void 0 ? _a : 1); } },
|
|
767
|
+
{ id: 'edgeDetect', name: 'Krawędzie', category: 'artistic', icon: '🔍', apply: (d, p) => { var _a; return blendIntensity(d, edgeDetect(d), (_a = p === null || p === void 0 ? void 0 : p.intensity) !== null && _a !== void 0 ? _a : 1); } },
|
|
768
|
+
{ id: 'tiltShift', name: 'Tilt Shift', category: 'artistic', icon: '🔭', apply: (d, p) => { var _a; return blendIntensity(d, tiltShift(d), (_a = p === null || p === void 0 ? void 0 : p.intensity) !== null && _a !== void 0 ? _a : 1); } },
|
|
769
|
+
// Fun
|
|
770
|
+
{ id: 'cyberpunk', name: 'Cyberpunk', category: 'fun', icon: '🤖', apply: (d, p) => { var _a; return blendIntensity(d, cyberpunk(d), (_a = p === null || p === void 0 ? void 0 : p.intensity) !== null && _a !== void 0 ? _a : 1); } },
|
|
771
|
+
{ id: 'retroWave', name: 'Retrowave', category: 'fun', icon: '🕹️', apply: (d, p) => { var _a; return blendIntensity(d, retroWave(d), (_a = p === null || p === void 0 ? void 0 : p.intensity) !== null && _a !== void 0 ? _a : 1); } },
|
|
772
|
+
{ id: 'nightVision', name: 'Night Vision', category: 'fun', icon: '🌙', apply: (d, p) => { var _a; return blendIntensity(d, nightVision(d), (_a = p === null || p === void 0 ? void 0 : p.intensity) !== null && _a !== void 0 ? _a : 1); } },
|
|
773
|
+
{ id: 'xRay', name: 'X-Ray', category: 'fun', icon: '☠️', apply: (d, p) => { var _a; return blendIntensity(d, xRay(d), (_a = p === null || p === void 0 ? void 0 : p.intensity) !== null && _a !== void 0 ? _a : 1); } },
|
|
774
|
+
{ id: 'heatMap', name: 'Heat Map', category: 'fun', icon: '🔥', apply: (d, p) => { var _a; return blendIntensity(d, heatMap(d), (_a = p === null || p === void 0 ? void 0 : p.intensity) !== null && _a !== void 0 ? _a : 1); } },
|
|
775
|
+
{ id: 'radioactive', name: 'Radioactive', category: 'fun', icon: '☢️', apply: (d, p) => { var _a; return blendIntensity(d, radioactive(d), (_a = p === null || p === void 0 ? void 0 : p.intensity) !== null && _a !== void 0 ? _a : 1); } },
|
|
776
|
+
{ id: 'glitch', name: 'Glitch', category: 'fun', icon: '📺', apply: (d, p) => { var _a; return blendIntensity(d, glitch(d), (_a = p === null || p === void 0 ? void 0 : p.intensity) !== null && _a !== void 0 ? _a : 1); } },
|
|
777
|
+
{ id: 'pixelate', name: 'Piksele', category: 'fun', icon: '🟩', apply: (d, p) => { var _a; return blendIntensity(d, pixelate(d), (_a = p === null || p === void 0 ? void 0 : p.intensity) !== null && _a !== void 0 ? _a : 1); } },
|
|
778
|
+
{ id: 'frostedGlass', name: 'Matowe szkło', category: 'fun', icon: '🧊', apply: (d, p) => { var _a; return blendIntensity(d, frostedGlass(d), (_a = p === null || p === void 0 ? void 0 : p.intensity) !== null && _a !== void 0 ? _a : 1); } },
|
|
779
|
+
{ id: 'solarize', name: 'Solaryzacja', category: 'fun', icon: '🌞', apply: (d, p) => { var _a; return blendIntensity(d, solarize(d), (_a = p === null || p === void 0 ? void 0 : p.intensity) !== null && _a !== void 0 ? _a : 1); } },
|
|
780
|
+
];
|
|
781
|
+
/** Get filter by ID */
|
|
782
|
+
function getFilter(id) {
|
|
783
|
+
return PHOTO_FILTERS.find(f => f.id === id);
|
|
784
|
+
}
|
|
785
|
+
/** Apply adjustments to ImageData */
|
|
786
|
+
function applyAdjustments(data, adj) {
|
|
787
|
+
let out = data;
|
|
788
|
+
if (adj.exposure && adj.exposure !== 0)
|
|
789
|
+
out = adjustExposure(out, adj.exposure);
|
|
790
|
+
if (adj.brightness && adj.brightness !== 0)
|
|
791
|
+
out = adjustBrightness(out, adj.brightness);
|
|
792
|
+
if (adj.contrast && adj.contrast !== 0)
|
|
793
|
+
out = adjustContrast(out, adj.contrast);
|
|
794
|
+
if (adj.saturation && adj.saturation !== 0)
|
|
795
|
+
out = adjustSaturation(out, adj.saturation);
|
|
796
|
+
if (adj.temperature && adj.temperature !== 0)
|
|
797
|
+
out = adjustTemperature(out, adj.temperature);
|
|
798
|
+
if (adj.tint && adj.tint !== 0)
|
|
799
|
+
out = adjustTint(out, adj.tint);
|
|
800
|
+
if (adj.highlights && adj.highlights !== 0)
|
|
801
|
+
out = adjustHighlights(out, adj.highlights);
|
|
802
|
+
if (adj.shadows && adj.shadows !== 0)
|
|
803
|
+
out = adjustShadows(out, adj.shadows);
|
|
804
|
+
if (adj.sharpness && adj.sharpness > 0)
|
|
805
|
+
out = sharpen(out, adj.sharpness / 100);
|
|
806
|
+
return out;
|
|
807
|
+
}
|
|
808
|
+
/** Full pipeline: filter + adjustments → canvas, then vignette & grain via context */
|
|
809
|
+
function renderToCanvas(canvas, sourceImage, filterId, filterParams, adjustments, cropRect, rotation, flipH, flipV) {
|
|
810
|
+
const ctx = canvas.getContext('2d', { willReadFrequently: true });
|
|
811
|
+
if (!ctx)
|
|
812
|
+
return;
|
|
813
|
+
// Source dimensions
|
|
814
|
+
const sw = sourceImage.naturalWidth;
|
|
815
|
+
const sh = sourceImage.naturalHeight;
|
|
816
|
+
// Crop region (in source pixels)
|
|
817
|
+
const crop = cropRect !== null && cropRect !== void 0 ? cropRect : { x: 0, y: 0, w: sw, h: sh };
|
|
818
|
+
// Rotation affects output dimensions
|
|
819
|
+
const rot = ((rotation !== null && rotation !== void 0 ? rotation : 0) % 360 + 360) % 360;
|
|
820
|
+
const swapped = rot === 90 || rot === 270;
|
|
821
|
+
const outW = swapped ? crop.h : crop.w;
|
|
822
|
+
const outH = swapped ? crop.w : crop.h;
|
|
823
|
+
canvas.width = outW;
|
|
824
|
+
canvas.height = outH;
|
|
825
|
+
ctx.save();
|
|
826
|
+
ctx.translate(outW / 2, outH / 2);
|
|
827
|
+
if (rot)
|
|
828
|
+
ctx.rotate((rot * Math.PI) / 180);
|
|
829
|
+
if (flipH)
|
|
830
|
+
ctx.scale(-1, 1);
|
|
831
|
+
if (flipV)
|
|
832
|
+
ctx.scale(1, -1);
|
|
833
|
+
ctx.drawImage(sourceImage, crop.x, crop.y, crop.w, crop.h, -crop.w / 2, -crop.h / 2, crop.w, crop.h);
|
|
834
|
+
ctx.restore();
|
|
835
|
+
// Apply filter
|
|
836
|
+
if (filterId && filterId !== 'none') {
|
|
837
|
+
const filter = getFilter(filterId);
|
|
838
|
+
if (filter) {
|
|
839
|
+
const imgData = ctx.getImageData(0, 0, outW, outH);
|
|
840
|
+
const filtered = filter.apply(imgData, filterParams);
|
|
841
|
+
ctx.putImageData(filtered, 0, 0);
|
|
842
|
+
}
|
|
843
|
+
}
|
|
844
|
+
// Apply adjustments
|
|
845
|
+
const hasAdj = Object.values(adjustments).some(v => v !== 0 && v !== undefined);
|
|
846
|
+
if (hasAdj) {
|
|
847
|
+
const imgData = ctx.getImageData(0, 0, outW, outH);
|
|
848
|
+
const adjusted = applyAdjustments(imgData, adjustments);
|
|
849
|
+
ctx.putImageData(adjusted, 0, 0);
|
|
850
|
+
}
|
|
851
|
+
// Vignette & grain (applied via context drawing)
|
|
852
|
+
if (adjustments.vignette && adjustments.vignette > 0) {
|
|
853
|
+
applyVignette(ctx, outW, outH, adjustments.vignette);
|
|
854
|
+
}
|
|
855
|
+
if (adjustments.grain && adjustments.grain > 0) {
|
|
856
|
+
applyGrain(ctx, outW, outH, adjustments.grain);
|
|
857
|
+
}
|
|
858
|
+
}
|
|
859
|
+
/** Export canvas as File (for upload) */
|
|
860
|
+
function canvasToFile(canvas, filename = 'photo.jpg', quality = 0.92) {
|
|
861
|
+
return new Promise((resolve, reject) => {
|
|
862
|
+
canvas.toBlob(blob => {
|
|
863
|
+
if (!blob)
|
|
864
|
+
return reject(new Error('Canvas toBlob failed'));
|
|
865
|
+
resolve(new File([blob], filename, { type: 'image/jpeg' }));
|
|
866
|
+
}, 'image/jpeg', quality);
|
|
867
|
+
});
|
|
868
|
+
}
|
|
869
|
+
|
|
870
|
+
export { DEFAULT_ADJUSTMENTS, PHOTO_FILTERS, applyAdjustments, applyGrain, applyVignette, canvasToFile, getFilter, renderToCanvas };
|
|
871
|
+
//# sourceMappingURL=photoFilters.js.map
|