react-native-image-editor-skia 0.1.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/LICENSE +21 -0
- package/README.md +202 -0
- package/lib/commonjs/ImageEditor.js +141 -0
- package/lib/commonjs/ImageEditor.js.map +1 -0
- package/lib/commonjs/annotations/AnnotationView.js +42 -0
- package/lib/commonjs/annotations/AnnotationView.js.map +1 -0
- package/lib/commonjs/annotations/ArrowAnnotation.js +29 -0
- package/lib/commonjs/annotations/ArrowAnnotation.js.map +1 -0
- package/lib/commonjs/annotations/CircleAnnotation.js +31 -0
- package/lib/commonjs/annotations/CircleAnnotation.js.map +1 -0
- package/lib/commonjs/annotations/FreehandAnnotation.js +29 -0
- package/lib/commonjs/annotations/FreehandAnnotation.js.map +1 -0
- package/lib/commonjs/annotations/MarkerAnnotation.js +27 -0
- package/lib/commonjs/annotations/MarkerAnnotation.js.map +1 -0
- package/lib/commonjs/annotations/RotatedGroup.js +34 -0
- package/lib/commonjs/annotations/RotatedGroup.js.map +1 -0
- package/lib/commonjs/annotations/TextAnnotation.js +40 -0
- package/lib/commonjs/annotations/TextAnnotation.js.map +1 -0
- package/lib/commonjs/annotations/geometry.js +73 -0
- package/lib/commonjs/annotations/geometry.js.map +1 -0
- package/lib/commonjs/annotations/geometryPure.js +104 -0
- package/lib/commonjs/annotations/geometryPure.js.map +1 -0
- package/lib/commonjs/canvas/AnnotationLayer.js +58 -0
- package/lib/commonjs/canvas/AnnotationLayer.js.map +1 -0
- package/lib/commonjs/canvas/BaseImageLayer.js +27 -0
- package/lib/commonjs/canvas/BaseImageLayer.js.map +1 -0
- package/lib/commonjs/canvas/CropOverlay.js +135 -0
- package/lib/commonjs/canvas/CropOverlay.js.map +1 -0
- package/lib/commonjs/canvas/EditorCanvas.js +91 -0
- package/lib/commonjs/canvas/EditorCanvas.js.map +1 -0
- package/lib/commonjs/canvas/InFlightLayer.js +152 -0
- package/lib/commonjs/canvas/InFlightLayer.js.map +1 -0
- package/lib/commonjs/canvas/SelectionOverlay.js +90 -0
- package/lib/commonjs/canvas/SelectionOverlay.js.map +1 -0
- package/lib/commonjs/constants.js +56 -0
- package/lib/commonjs/constants.js.map +1 -0
- package/lib/commonjs/context/EditorContext.js +132 -0
- package/lib/commonjs/context/EditorContext.js.map +1 -0
- package/lib/commonjs/export/drawScene.js +97 -0
- package/lib/commonjs/export/drawScene.js.map +1 -0
- package/lib/commonjs/export/exportImage.js +92 -0
- package/lib/commonjs/export/exportImage.js.map +1 -0
- package/lib/commonjs/gestures/applyTransform.js +79 -0
- package/lib/commonjs/gestures/applyTransform.js.map +1 -0
- package/lib/commonjs/gestures/createAnnotation.js +73 -0
- package/lib/commonjs/gestures/createAnnotation.js.map +1 -0
- package/lib/commonjs/gestures/handles.js +53 -0
- package/lib/commonjs/gestures/handles.js.map +1 -0
- package/lib/commonjs/gestures/hitTest.js +72 -0
- package/lib/commonjs/gestures/hitTest.js.map +1 -0
- package/lib/commonjs/gestures/useCropGesture.js +149 -0
- package/lib/commonjs/gestures/useCropGesture.js.map +1 -0
- package/lib/commonjs/gestures/useEditorGestures.js +289 -0
- package/lib/commonjs/gestures/useEditorGestures.js.map +1 -0
- package/lib/commonjs/image/disposeRegistry.js +63 -0
- package/lib/commonjs/image/disposeRegistry.js.map +1 -0
- package/lib/commonjs/image/useLoadedImage.js +121 -0
- package/lib/commonjs/image/useLoadedImage.js.map +1 -0
- package/lib/commonjs/index.js +52 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/state/history.js +85 -0
- package/lib/commonjs/state/history.js.map +1 -0
- package/lib/commonjs/state/selectors.js +19 -0
- package/lib/commonjs/state/selectors.js.map +1 -0
- package/lib/commonjs/state/useEditorReducer.js +83 -0
- package/lib/commonjs/state/useEditorReducer.js.map +1 -0
- package/lib/commonjs/toolbar/ColorPicker.js +84 -0
- package/lib/commonjs/toolbar/ColorPicker.js.map +1 -0
- package/lib/commonjs/toolbar/CropControls.js +65 -0
- package/lib/commonjs/toolbar/CropControls.js.map +1 -0
- package/lib/commonjs/toolbar/RotationSlider.js +73 -0
- package/lib/commonjs/toolbar/RotationSlider.js.map +1 -0
- package/lib/commonjs/toolbar/TextInputOverlay.js +108 -0
- package/lib/commonjs/toolbar/TextInputOverlay.js.map +1 -0
- package/lib/commonjs/toolbar/ToolButton.js +56 -0
- package/lib/commonjs/toolbar/ToolButton.js.map +1 -0
- package/lib/commonjs/toolbar/Toolbar.js +137 -0
- package/lib/commonjs/toolbar/Toolbar.js.map +1 -0
- package/lib/commonjs/types.js +47 -0
- package/lib/commonjs/types.js.map +1 -0
- package/lib/commonjs/utils/color.js +37 -0
- package/lib/commonjs/utils/color.js.map +1 -0
- package/lib/commonjs/utils/id.js +14 -0
- package/lib/commonjs/utils/id.js.map +1 -0
- package/lib/commonjs/utils/math.js +277 -0
- package/lib/commonjs/utils/math.js.map +1 -0
- package/lib/module/ImageEditor.js +138 -0
- package/lib/module/ImageEditor.js.map +1 -0
- package/lib/module/annotations/AnnotationView.js +39 -0
- package/lib/module/annotations/AnnotationView.js.map +1 -0
- package/lib/module/annotations/ArrowAnnotation.js +26 -0
- package/lib/module/annotations/ArrowAnnotation.js.map +1 -0
- package/lib/module/annotations/CircleAnnotation.js +27 -0
- package/lib/module/annotations/CircleAnnotation.js.map +1 -0
- package/lib/module/annotations/FreehandAnnotation.js +25 -0
- package/lib/module/annotations/FreehandAnnotation.js.map +1 -0
- package/lib/module/annotations/MarkerAnnotation.js +23 -0
- package/lib/module/annotations/MarkerAnnotation.js.map +1 -0
- package/lib/module/annotations/RotatedGroup.js +29 -0
- package/lib/module/annotations/RotatedGroup.js.map +1 -0
- package/lib/module/annotations/TextAnnotation.js +37 -0
- package/lib/module/annotations/TextAnnotation.js.map +1 -0
- package/lib/module/annotations/geometry.js +56 -0
- package/lib/module/annotations/geometry.js.map +1 -0
- package/lib/module/annotations/geometryPure.js +100 -0
- package/lib/module/annotations/geometryPure.js.map +1 -0
- package/lib/module/canvas/AnnotationLayer.js +55 -0
- package/lib/module/canvas/AnnotationLayer.js.map +1 -0
- package/lib/module/canvas/BaseImageLayer.js +23 -0
- package/lib/module/canvas/BaseImageLayer.js.map +1 -0
- package/lib/module/canvas/CropOverlay.js +131 -0
- package/lib/module/canvas/CropOverlay.js.map +1 -0
- package/lib/module/canvas/EditorCanvas.js +88 -0
- package/lib/module/canvas/EditorCanvas.js.map +1 -0
- package/lib/module/canvas/InFlightLayer.js +149 -0
- package/lib/module/canvas/InFlightLayer.js.map +1 -0
- package/lib/module/canvas/SelectionOverlay.js +85 -0
- package/lib/module/canvas/SelectionOverlay.js.map +1 -0
- package/lib/module/constants.js +52 -0
- package/lib/module/constants.js.map +1 -0
- package/lib/module/context/EditorContext.js +126 -0
- package/lib/module/context/EditorContext.js.map +1 -0
- package/lib/module/export/drawScene.js +93 -0
- package/lib/module/export/drawScene.js.map +1 -0
- package/lib/module/export/exportImage.js +88 -0
- package/lib/module/export/exportImage.js.map +1 -0
- package/lib/module/gestures/applyTransform.js +75 -0
- package/lib/module/gestures/applyTransform.js.map +1 -0
- package/lib/module/gestures/createAnnotation.js +65 -0
- package/lib/module/gestures/createAnnotation.js.map +1 -0
- package/lib/module/gestures/handles.js +49 -0
- package/lib/module/gestures/handles.js.map +1 -0
- package/lib/module/gestures/hitTest.js +69 -0
- package/lib/module/gestures/hitTest.js.map +1 -0
- package/lib/module/gestures/useCropGesture.js +145 -0
- package/lib/module/gestures/useCropGesture.js.map +1 -0
- package/lib/module/gestures/useEditorGestures.js +285 -0
- package/lib/module/gestures/useEditorGestures.js.map +1 -0
- package/lib/module/image/disposeRegistry.js +57 -0
- package/lib/module/image/disposeRegistry.js.map +1 -0
- package/lib/module/image/useLoadedImage.js +117 -0
- package/lib/module/image/useLoadedImage.js.map +1 -0
- package/lib/module/index.js +8 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/state/history.js +76 -0
- package/lib/module/state/history.js.map +1 -0
- package/lib/module/state/selectors.js +14 -0
- package/lib/module/state/selectors.js.map +1 -0
- package/lib/module/state/useEditorReducer.js +79 -0
- package/lib/module/state/useEditorReducer.js.map +1 -0
- package/lib/module/toolbar/ColorPicker.js +80 -0
- package/lib/module/toolbar/ColorPicker.js.map +1 -0
- package/lib/module/toolbar/CropControls.js +62 -0
- package/lib/module/toolbar/CropControls.js.map +1 -0
- package/lib/module/toolbar/RotationSlider.js +69 -0
- package/lib/module/toolbar/RotationSlider.js.map +1 -0
- package/lib/module/toolbar/TextInputOverlay.js +105 -0
- package/lib/module/toolbar/TextInputOverlay.js.map +1 -0
- package/lib/module/toolbar/ToolButton.js +52 -0
- package/lib/module/toolbar/ToolButton.js.map +1 -0
- package/lib/module/toolbar/Toolbar.js +133 -0
- package/lib/module/toolbar/Toolbar.js.map +1 -0
- package/lib/module/types.js +43 -0
- package/lib/module/types.js.map +1 -0
- package/lib/module/utils/color.js +33 -0
- package/lib/module/utils/color.js.map +1 -0
- package/lib/module/utils/id.js +10 -0
- package/lib/module/utils/id.js.map +1 -0
- package/lib/module/utils/math.js +258 -0
- package/lib/module/utils/math.js.map +1 -0
- package/lib/typescript/src/ImageEditor.d.ts +9 -0
- package/lib/typescript/src/ImageEditor.d.ts.map +1 -0
- package/lib/typescript/src/annotations/AnnotationView.d.ts +6 -0
- package/lib/typescript/src/annotations/AnnotationView.d.ts.map +1 -0
- package/lib/typescript/src/annotations/ArrowAnnotation.d.ts +5 -0
- package/lib/typescript/src/annotations/ArrowAnnotation.d.ts.map +1 -0
- package/lib/typescript/src/annotations/CircleAnnotation.d.ts +5 -0
- package/lib/typescript/src/annotations/CircleAnnotation.d.ts.map +1 -0
- package/lib/typescript/src/annotations/FreehandAnnotation.d.ts +5 -0
- package/lib/typescript/src/annotations/FreehandAnnotation.d.ts.map +1 -0
- package/lib/typescript/src/annotations/MarkerAnnotation.d.ts +5 -0
- package/lib/typescript/src/annotations/MarkerAnnotation.d.ts.map +1 -0
- package/lib/typescript/src/annotations/RotatedGroup.d.ts +13 -0
- package/lib/typescript/src/annotations/RotatedGroup.d.ts.map +1 -0
- package/lib/typescript/src/annotations/TextAnnotation.d.ts +10 -0
- package/lib/typescript/src/annotations/TextAnnotation.d.ts.map +1 -0
- package/lib/typescript/src/annotations/geometry.d.ts +11 -0
- package/lib/typescript/src/annotations/geometry.d.ts.map +1 -0
- package/lib/typescript/src/annotations/geometryPure.d.ts +14 -0
- package/lib/typescript/src/annotations/geometryPure.d.ts.map +1 -0
- package/lib/typescript/src/canvas/AnnotationLayer.d.ts +11 -0
- package/lib/typescript/src/canvas/AnnotationLayer.d.ts.map +1 -0
- package/lib/typescript/src/canvas/BaseImageLayer.d.ts +12 -0
- package/lib/typescript/src/canvas/BaseImageLayer.d.ts.map +1 -0
- package/lib/typescript/src/canvas/CropOverlay.d.ts +10 -0
- package/lib/typescript/src/canvas/CropOverlay.d.ts.map +1 -0
- package/lib/typescript/src/canvas/EditorCanvas.d.ts +18 -0
- package/lib/typescript/src/canvas/EditorCanvas.d.ts.map +1 -0
- package/lib/typescript/src/canvas/InFlightLayer.d.ts +12 -0
- package/lib/typescript/src/canvas/InFlightLayer.d.ts.map +1 -0
- package/lib/typescript/src/canvas/SelectionOverlay.d.ts +11 -0
- package/lib/typescript/src/canvas/SelectionOverlay.d.ts.map +1 -0
- package/lib/typescript/src/constants.d.ts +25 -0
- package/lib/typescript/src/constants.d.ts.map +1 -0
- package/lib/typescript/src/context/EditorContext.d.ts +66 -0
- package/lib/typescript/src/context/EditorContext.d.ts.map +1 -0
- package/lib/typescript/src/export/drawScene.d.ts +10 -0
- package/lib/typescript/src/export/drawScene.d.ts.map +1 -0
- package/lib/typescript/src/export/exportImage.d.ts +23 -0
- package/lib/typescript/src/export/exportImage.d.ts.map +1 -0
- package/lib/typescript/src/gestures/applyTransform.d.ts +17 -0
- package/lib/typescript/src/gestures/applyTransform.d.ts.map +1 -0
- package/lib/typescript/src/gestures/createAnnotation.d.ts +11 -0
- package/lib/typescript/src/gestures/createAnnotation.d.ts.map +1 -0
- package/lib/typescript/src/gestures/handles.d.ts +17 -0
- package/lib/typescript/src/gestures/handles.d.ts.map +1 -0
- package/lib/typescript/src/gestures/hitTest.d.ts +9 -0
- package/lib/typescript/src/gestures/hitTest.d.ts.map +1 -0
- package/lib/typescript/src/gestures/useCropGesture.d.ts +7 -0
- package/lib/typescript/src/gestures/useCropGesture.d.ts.map +1 -0
- package/lib/typescript/src/gestures/useEditorGestures.d.ts +8 -0
- package/lib/typescript/src/gestures/useEditorGestures.d.ts.map +1 -0
- package/lib/typescript/src/image/disposeRegistry.d.ts +25 -0
- package/lib/typescript/src/image/disposeRegistry.d.ts.map +1 -0
- package/lib/typescript/src/image/useLoadedImage.d.ts +23 -0
- package/lib/typescript/src/image/useLoadedImage.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +6 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/state/history.d.ts +23 -0
- package/lib/typescript/src/state/history.d.ts.map +1 -0
- package/lib/typescript/src/state/selectors.d.ts +5 -0
- package/lib/typescript/src/state/selectors.d.ts.map +1 -0
- package/lib/typescript/src/state/useEditorReducer.d.ts +32 -0
- package/lib/typescript/src/state/useEditorReducer.d.ts.map +1 -0
- package/lib/typescript/src/toolbar/ColorPicker.d.ts +7 -0
- package/lib/typescript/src/toolbar/ColorPicker.d.ts.map +1 -0
- package/lib/typescript/src/toolbar/CropControls.d.ts +3 -0
- package/lib/typescript/src/toolbar/CropControls.d.ts.map +1 -0
- package/lib/typescript/src/toolbar/RotationSlider.d.ts +8 -0
- package/lib/typescript/src/toolbar/RotationSlider.d.ts.map +1 -0
- package/lib/typescript/src/toolbar/TextInputOverlay.d.ts +9 -0
- package/lib/typescript/src/toolbar/TextInputOverlay.d.ts.map +1 -0
- package/lib/typescript/src/toolbar/ToolButton.d.ts +7 -0
- package/lib/typescript/src/toolbar/ToolButton.d.ts.map +1 -0
- package/lib/typescript/src/toolbar/Toolbar.d.ts +4 -0
- package/lib/typescript/src/toolbar/Toolbar.d.ts.map +1 -0
- package/lib/typescript/src/types.d.ts +170 -0
- package/lib/typescript/src/types.d.ts.map +1 -0
- package/lib/typescript/src/utils/color.d.ts +8 -0
- package/lib/typescript/src/utils/color.d.ts.map +1 -0
- package/lib/typescript/src/utils/id.d.ts +3 -0
- package/lib/typescript/src/utils/id.d.ts.map +1 -0
- package/lib/typescript/src/utils/math.d.ts +68 -0
- package/lib/typescript/src/utils/math.d.ts.map +1 -0
- package/package.json +90 -0
- package/src/ImageEditor.tsx +133 -0
- package/src/annotations/AnnotationView.tsx +24 -0
- package/src/annotations/ArrowAnnotation.tsx +26 -0
- package/src/annotations/CircleAnnotation.tsx +22 -0
- package/src/annotations/FreehandAnnotation.tsx +22 -0
- package/src/annotations/MarkerAnnotation.tsx +20 -0
- package/src/annotations/RotatedGroup.tsx +28 -0
- package/src/annotations/TextAnnotation.tsx +42 -0
- package/src/annotations/geometry.ts +62 -0
- package/src/annotations/geometryPure.ts +73 -0
- package/src/canvas/AnnotationLayer.tsx +43 -0
- package/src/canvas/BaseImageLayer.tsx +28 -0
- package/src/canvas/CropOverlay.tsx +92 -0
- package/src/canvas/EditorCanvas.tsx +70 -0
- package/src/canvas/InFlightLayer.tsx +140 -0
- package/src/canvas/SelectionOverlay.tsx +92 -0
- package/src/constants.ts +46 -0
- package/src/context/EditorContext.tsx +229 -0
- package/src/export/drawScene.ts +120 -0
- package/src/export/exportImage.ts +111 -0
- package/src/gestures/applyTransform.ts +76 -0
- package/src/gestures/createAnnotation.ts +92 -0
- package/src/gestures/handles.ts +50 -0
- package/src/gestures/hitTest.ts +79 -0
- package/src/gestures/useCropGesture.ts +123 -0
- package/src/gestures/useEditorGestures.ts +308 -0
- package/src/image/disposeRegistry.ts +59 -0
- package/src/image/useLoadedImage.ts +131 -0
- package/src/index.ts +32 -0
- package/src/state/history.ts +71 -0
- package/src/state/selectors.ts +16 -0
- package/src/state/useEditorReducer.ts +93 -0
- package/src/toolbar/ColorPicker.tsx +72 -0
- package/src/toolbar/CropControls.tsx +46 -0
- package/src/toolbar/RotationSlider.tsx +56 -0
- package/src/toolbar/TextInputOverlay.tsx +104 -0
- package/src/toolbar/ToolButton.tsx +46 -0
- package/src/toolbar/Toolbar.tsx +110 -0
- package/src/types.ts +203 -0
- package/src/utils/color.ts +34 -0
- package/src/utils/id.ts +7 -0
- package/src/utils/math.ts +222 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.IDENTITY_SCENE = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* Public + internal types for the Skia image editor.
|
|
9
|
+
*
|
|
10
|
+
* COORDINATE-SPACE CONTRACT (read this first):
|
|
11
|
+
* Every annotation's geometry is stored in **image space** — the base image's
|
|
12
|
+
* full-resolution pixel coordinate system (0..imageWidth, 0..imageHeight).
|
|
13
|
+
* It is NEVER stored in screen space. A single `imageToScreen` affine matrix
|
|
14
|
+
* maps image space onto the on-screen canvas; its inverse maps touches back.
|
|
15
|
+
* Because of this, export can render the exact same numbers off-screen at native
|
|
16
|
+
* resolution with no rescaling. See `utils/math.ts`.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Colors are stored as CSS-style strings ("#RRGGBB" / "#RRGGBBAA" / named).
|
|
21
|
+
* Skia accepts these directly, and they are trivially serializable for history.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Non-destructive image transforms. Nothing is baked into pixels until export,
|
|
26
|
+
* so all of these are undoable.
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
const IDENTITY_SCENE = exports.IDENTITY_SCENE = {
|
|
30
|
+
rotation: 0,
|
|
31
|
+
scale: 1,
|
|
32
|
+
cropRect: null
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
/** The serializable editor document — everything undo/redo tracks. */
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Callback that persists an encoded image to disk. The library has no
|
|
39
|
+
* filesystem access of its own, so the consumer supplies this using whatever fs
|
|
40
|
+
* module they already have (react-native-fs, expo-file-system, etc.). It
|
|
41
|
+
* receives the destination path and the RAW base64 payload (no data-URI prefix).
|
|
42
|
+
*/
|
|
43
|
+
|
|
44
|
+
/** Imperative handle exposed via `ref`. */
|
|
45
|
+
|
|
46
|
+
/** Source image: a base64 string (raw or data-URI) or a file/remote URI. */
|
|
47
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["IDENTITY_SCENE","exports","rotation","scale","cropRect"],"sourceRoot":"..\\..\\src","sources":["types.ts"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAyBA;AACA;AACA;AACA;;AAkEA;AACA;AACA;AACA;;AAUO,MAAMA,cAA8B,GAAAC,OAAA,CAAAD,cAAA,GAAG;EAC5CE,QAAQ,EAAE,CAAC;EACXC,KAAK,EAAE,CAAC;EACRC,QAAQ,EAAE;AACZ,CAAC;;AAED;;AAQA;AACA;AACA;AACA;AACA;AACA;;AA4BA;;AAeA","ignoreList":[]}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.withOpacity = withOpacity;
|
|
7
|
+
/**
|
|
8
|
+
* Apply an opacity (0..1) to a hex color string, returning an 8-digit hex
|
|
9
|
+
* ("#RRGGBBAA"). Used by the marker/highlighter which draws semi-transparently.
|
|
10
|
+
* Non-hex inputs (named colors, rgba(...)) are returned unchanged.
|
|
11
|
+
*/
|
|
12
|
+
function withOpacity(color, opacity) {
|
|
13
|
+
const clamped = Math.max(0, Math.min(1, opacity));
|
|
14
|
+
const hex = color.trim();
|
|
15
|
+
if (!hex.startsWith('#')) {
|
|
16
|
+
return hex;
|
|
17
|
+
}
|
|
18
|
+
let r;
|
|
19
|
+
let g;
|
|
20
|
+
let b;
|
|
21
|
+
if (hex.length === 4) {
|
|
22
|
+
// #RGB
|
|
23
|
+
r = hex[1] + hex[1];
|
|
24
|
+
g = hex[2] + hex[2];
|
|
25
|
+
b = hex[3] + hex[3];
|
|
26
|
+
} else if (hex.length === 7 || hex.length === 9) {
|
|
27
|
+
// #RRGGBB or #RRGGBBAA (ignore existing alpha)
|
|
28
|
+
r = hex.slice(1, 3);
|
|
29
|
+
g = hex.slice(3, 5);
|
|
30
|
+
b = hex.slice(5, 7);
|
|
31
|
+
} else {
|
|
32
|
+
return hex;
|
|
33
|
+
}
|
|
34
|
+
const a = Math.round(clamped * 255).toString(16).padStart(2, '0');
|
|
35
|
+
return `#${r}${g}${b}${a}`;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=color.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["withOpacity","color","opacity","clamped","Math","max","min","hex","trim","startsWith","r","g","b","length","slice","a","round","toString","padStart"],"sourceRoot":"..\\..\\..\\src","sources":["utils/color.ts"],"mappings":";;;;;;AAEA;AACA;AACA;AACA;AACA;AACO,SAASA,WAAWA,CAACC,KAAkB,EAAEC,OAAe,EAAe;EAC5E,MAAMC,OAAO,GAAGC,IAAI,CAACC,GAAG,CAAC,CAAC,EAAED,IAAI,CAACE,GAAG,CAAC,CAAC,EAAEJ,OAAO,CAAC,CAAC;EACjD,MAAMK,GAAG,GAAGN,KAAK,CAACO,IAAI,CAAC,CAAC;EACxB,IAAI,CAACD,GAAG,CAACE,UAAU,CAAC,GAAG,CAAC,EAAE;IACxB,OAAOF,GAAG;EACZ;EACA,IAAIG,CAAS;EACb,IAAIC,CAAS;EACb,IAAIC,CAAS;EACb,IAAIL,GAAG,CAACM,MAAM,KAAK,CAAC,EAAE;IACpB;IACAH,CAAC,GAAGH,GAAG,CAAC,CAAC,CAAC,GAAIA,GAAG,CAAC,CAAC,CAAE;IACrBI,CAAC,GAAGJ,GAAG,CAAC,CAAC,CAAC,GAAIA,GAAG,CAAC,CAAC,CAAE;IACrBK,CAAC,GAAGL,GAAG,CAAC,CAAC,CAAC,GAAIA,GAAG,CAAC,CAAC,CAAE;EACvB,CAAC,MAAM,IAAIA,GAAG,CAACM,MAAM,KAAK,CAAC,IAAIN,GAAG,CAACM,MAAM,KAAK,CAAC,EAAE;IAC/C;IACAH,CAAC,GAAGH,GAAG,CAACO,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC;IACnBH,CAAC,GAAGJ,GAAG,CAACO,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC;IACnBF,CAAC,GAAGL,GAAG,CAACO,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC;EACrB,CAAC,MAAM;IACL,OAAOP,GAAG;EACZ;EACA,MAAMQ,CAAC,GAAGX,IAAI,CAACY,KAAK,CAACb,OAAO,GAAG,GAAG,CAAC,CAChCc,QAAQ,CAAC,EAAE,CAAC,CACZC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC;EACnB,OAAO,IAAIR,CAAC,GAAGC,CAAC,GAAGC,CAAC,GAAGG,CAAC,EAAE;AAC5B","ignoreList":[]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.genId = genId;
|
|
7
|
+
let counter = 0;
|
|
8
|
+
|
|
9
|
+
/** Small unique id generator (JS thread only — avoids a nanoid dependency). */
|
|
10
|
+
function genId(prefix = 'a') {
|
|
11
|
+
counter += 1;
|
|
12
|
+
return `${prefix}_${Date.now().toString(36)}_${counter.toString(36)}`;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=id.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["counter","genId","prefix","Date","now","toString"],"sourceRoot":"..\\..\\..\\src","sources":["utils/id.ts"],"mappings":";;;;;;AAAA,IAAIA,OAAO,GAAG,CAAC;;AAEf;AACO,SAASC,KAAKA,CAACC,MAAM,GAAG,GAAG,EAAU;EAC1CF,OAAO,IAAI,CAAC;EACZ,OAAO,GAAGE,MAAM,IAAIC,IAAI,CAACC,GAAG,CAAC,CAAC,CAACC,QAAQ,CAAC,EAAE,CAAC,IAAIL,OAAO,CAACK,QAAQ,CAAC,EAAE,CAAC,EAAE;AACvE","ignoreList":[]}
|
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.applyToPoint = applyToPoint;
|
|
7
|
+
exports.boundsOfPoints = boundsOfPoints;
|
|
8
|
+
exports.clampSizeToMax = clampSizeToMax;
|
|
9
|
+
exports.distance = distance;
|
|
10
|
+
exports.distanceToSegment = distanceToSegment;
|
|
11
|
+
exports.fitScale = fitScale;
|
|
12
|
+
exports.identity = identity;
|
|
13
|
+
exports.imageToScreenMatrix = imageToScreenMatrix;
|
|
14
|
+
exports.invert = invert;
|
|
15
|
+
exports.multiply = multiply;
|
|
16
|
+
exports.rectCenter = rectCenter;
|
|
17
|
+
exports.rotatePoint = rotatePoint;
|
|
18
|
+
exports.rotation = rotation;
|
|
19
|
+
exports.scaling = scaling;
|
|
20
|
+
exports.sceneTransforms2d = sceneTransforms2d;
|
|
21
|
+
exports.translation = translation;
|
|
22
|
+
/**
|
|
23
|
+
* Pure 2D affine-matrix math. Every function is marked `worklet` so it can run
|
|
24
|
+
* on the UI thread inside gesture handlers as well as on the JS thread.
|
|
25
|
+
*
|
|
26
|
+
* A matrix `Mat` maps a point p to p' via:
|
|
27
|
+
* x' = a*x + c*y + e
|
|
28
|
+
* y' = b*x + d*y + f
|
|
29
|
+
* (the canonical CSS/canvas affine convention).
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
function identity() {
|
|
33
|
+
'worklet';
|
|
34
|
+
|
|
35
|
+
return {
|
|
36
|
+
a: 1,
|
|
37
|
+
b: 0,
|
|
38
|
+
c: 0,
|
|
39
|
+
d: 1,
|
|
40
|
+
e: 0,
|
|
41
|
+
f: 0
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** Returns m1 ∘ m2 (applies m2 first, then m1). */
|
|
46
|
+
function multiply(m1, m2) {
|
|
47
|
+
'worklet';
|
|
48
|
+
|
|
49
|
+
return {
|
|
50
|
+
a: m1.a * m2.a + m1.c * m2.b,
|
|
51
|
+
b: m1.b * m2.a + m1.d * m2.b,
|
|
52
|
+
c: m1.a * m2.c + m1.c * m2.d,
|
|
53
|
+
d: m1.b * m2.c + m1.d * m2.d,
|
|
54
|
+
e: m1.a * m2.e + m1.c * m2.f + m1.e,
|
|
55
|
+
f: m1.b * m2.e + m1.d * m2.f + m1.f
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
function translation(tx, ty) {
|
|
59
|
+
'worklet';
|
|
60
|
+
|
|
61
|
+
return {
|
|
62
|
+
a: 1,
|
|
63
|
+
b: 0,
|
|
64
|
+
c: 0,
|
|
65
|
+
d: 1,
|
|
66
|
+
e: tx,
|
|
67
|
+
f: ty
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
function scaling(sx, sy) {
|
|
71
|
+
'worklet';
|
|
72
|
+
|
|
73
|
+
return {
|
|
74
|
+
a: sx,
|
|
75
|
+
b: 0,
|
|
76
|
+
c: 0,
|
|
77
|
+
d: sy,
|
|
78
|
+
e: 0,
|
|
79
|
+
f: 0
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
function rotation(theta) {
|
|
83
|
+
'worklet';
|
|
84
|
+
|
|
85
|
+
const cos = Math.cos(theta);
|
|
86
|
+
const sin = Math.sin(theta);
|
|
87
|
+
return {
|
|
88
|
+
a: cos,
|
|
89
|
+
b: sin,
|
|
90
|
+
c: -sin,
|
|
91
|
+
d: cos,
|
|
92
|
+
e: 0,
|
|
93
|
+
f: 0
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
function invert(m) {
|
|
97
|
+
'worklet';
|
|
98
|
+
|
|
99
|
+
const det = m.a * m.d - m.b * m.c;
|
|
100
|
+
if (det === 0) {
|
|
101
|
+
return identity();
|
|
102
|
+
}
|
|
103
|
+
const inv = 1 / det;
|
|
104
|
+
return {
|
|
105
|
+
a: m.d * inv,
|
|
106
|
+
b: -m.b * inv,
|
|
107
|
+
c: -m.c * inv,
|
|
108
|
+
d: m.a * inv,
|
|
109
|
+
e: (m.c * m.f - m.d * m.e) * inv,
|
|
110
|
+
f: (m.b * m.e - m.a * m.f) * inv
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
function applyToPoint(m, p) {
|
|
114
|
+
'worklet';
|
|
115
|
+
|
|
116
|
+
return {
|
|
117
|
+
x: m.a * p.x + m.c * p.y + m.e,
|
|
118
|
+
y: m.b * p.x + m.d * p.y + m.f
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/** Rotate point `p` by `theta` radians about `center`. */
|
|
123
|
+
function rotatePoint(p, center, theta) {
|
|
124
|
+
'worklet';
|
|
125
|
+
|
|
126
|
+
const cos = Math.cos(theta);
|
|
127
|
+
const sin = Math.sin(theta);
|
|
128
|
+
const dx = p.x - center.x;
|
|
129
|
+
const dy = p.y - center.y;
|
|
130
|
+
return {
|
|
131
|
+
x: center.x + dx * cos - dy * sin,
|
|
132
|
+
y: center.y + dx * sin + dy * cos
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* The base fit scale used to "contain" the image inside the on-screen layout,
|
|
137
|
+
* before any user scene scale is applied.
|
|
138
|
+
*/
|
|
139
|
+
function fitScale(image, layout) {
|
|
140
|
+
'worklet';
|
|
141
|
+
|
|
142
|
+
if (image.width <= 0 || image.height <= 0) {
|
|
143
|
+
return 1;
|
|
144
|
+
}
|
|
145
|
+
return Math.min(layout.width / image.width, layout.height / image.height);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Compose the image→screen matrix:
|
|
150
|
+
* M = T(center) · R(rotation) · S(fit·userScale) · T(-imageCenter)
|
|
151
|
+
*
|
|
152
|
+
* The on-screen Skia `<Group>` uses `sceneTransforms2d` (below), built from the
|
|
153
|
+
* SAME parameters, so the preview and this matrix stay in lock-step. Gestures
|
|
154
|
+
* use `invert(M)` to map screen touches back into image space.
|
|
155
|
+
*/
|
|
156
|
+
function imageToScreenMatrix(scene, image, layout) {
|
|
157
|
+
'worklet';
|
|
158
|
+
|
|
159
|
+
const s = fitScale(image, layout) * scene.scale;
|
|
160
|
+
const cx = layout.width / 2;
|
|
161
|
+
const cy = layout.height / 2;
|
|
162
|
+
let m = translation(cx, cy);
|
|
163
|
+
m = multiply(m, rotation(scene.rotation));
|
|
164
|
+
m = multiply(m, scaling(s, s));
|
|
165
|
+
m = multiply(m, translation(-image.width / 2, -image.height / 2));
|
|
166
|
+
return m;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Skia `Transforms2d` array for the on-screen scene `<Group>`. Applied in order,
|
|
171
|
+
* this reproduces `imageToScreenMatrix` exactly.
|
|
172
|
+
*/
|
|
173
|
+
function sceneTransforms2d(scene, image, layout) {
|
|
174
|
+
'worklet';
|
|
175
|
+
|
|
176
|
+
const s = fitScale(image, layout) * scene.scale;
|
|
177
|
+
return [{
|
|
178
|
+
translateX: layout.width / 2
|
|
179
|
+
}, {
|
|
180
|
+
translateY: layout.height / 2
|
|
181
|
+
}, {
|
|
182
|
+
rotate: scene.rotation
|
|
183
|
+
}, {
|
|
184
|
+
scaleX: s
|
|
185
|
+
}, {
|
|
186
|
+
scaleY: s
|
|
187
|
+
}, {
|
|
188
|
+
translateX: -image.width / 2
|
|
189
|
+
}, {
|
|
190
|
+
translateY: -image.height / 2
|
|
191
|
+
}];
|
|
192
|
+
}
|
|
193
|
+
function clampSizeToMax(width, height, maxSize) {
|
|
194
|
+
'worklet';
|
|
195
|
+
|
|
196
|
+
if (!maxSize || maxSize <= 0) {
|
|
197
|
+
return {
|
|
198
|
+
width,
|
|
199
|
+
height
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
const longest = Math.max(width, height);
|
|
203
|
+
if (longest <= maxSize) {
|
|
204
|
+
return {
|
|
205
|
+
width,
|
|
206
|
+
height
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
const k = maxSize / longest;
|
|
210
|
+
return {
|
|
211
|
+
width: Math.round(width * k),
|
|
212
|
+
height: Math.round(height * k)
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/** Axis-aligned bounding box of a set of points. */
|
|
217
|
+
function boundsOfPoints(points) {
|
|
218
|
+
'worklet';
|
|
219
|
+
|
|
220
|
+
if (points.length === 0) {
|
|
221
|
+
return {
|
|
222
|
+
x: 0,
|
|
223
|
+
y: 0,
|
|
224
|
+
width: 0,
|
|
225
|
+
height: 0
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
let minX = points[0].x;
|
|
229
|
+
let minY = points[0].y;
|
|
230
|
+
let maxX = points[0].x;
|
|
231
|
+
let maxY = points[0].y;
|
|
232
|
+
for (let i = 1; i < points.length; i++) {
|
|
233
|
+
const p = points[i];
|
|
234
|
+
if (p.x < minX) minX = p.x;
|
|
235
|
+
if (p.y < minY) minY = p.y;
|
|
236
|
+
if (p.x > maxX) maxX = p.x;
|
|
237
|
+
if (p.y > maxY) maxY = p.y;
|
|
238
|
+
}
|
|
239
|
+
return {
|
|
240
|
+
x: minX,
|
|
241
|
+
y: minY,
|
|
242
|
+
width: maxX - minX,
|
|
243
|
+
height: maxY - minY
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
function rectCenter(r) {
|
|
247
|
+
'worklet';
|
|
248
|
+
|
|
249
|
+
return {
|
|
250
|
+
x: r.x + r.width / 2,
|
|
251
|
+
y: r.y + r.height / 2
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
function distance(a, b) {
|
|
255
|
+
'worklet';
|
|
256
|
+
|
|
257
|
+
return Math.hypot(a.x - b.x, a.y - b.y);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/** Shortest distance from point `p` to segment `a`→`b`. */
|
|
261
|
+
function distanceToSegment(p, a, b) {
|
|
262
|
+
'worklet';
|
|
263
|
+
|
|
264
|
+
const dx = b.x - a.x;
|
|
265
|
+
const dy = b.y - a.y;
|
|
266
|
+
const lenSq = dx * dx + dy * dy;
|
|
267
|
+
if (lenSq === 0) {
|
|
268
|
+
return distance(p, a);
|
|
269
|
+
}
|
|
270
|
+
let t = ((p.x - a.x) * dx + (p.y - a.y) * dy) / lenSq;
|
|
271
|
+
t = Math.max(0, Math.min(1, t));
|
|
272
|
+
return distance(p, {
|
|
273
|
+
x: a.x + t * dx,
|
|
274
|
+
y: a.y + t * dy
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
//# sourceMappingURL=math.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["identity","a","b","c","d","e","f","multiply","m1","m2","translation","tx","ty","scaling","sx","sy","rotation","theta","cos","Math","sin","invert","m","det","inv","applyToPoint","p","x","y","rotatePoint","center","dx","dy","fitScale","image","layout","width","height","min","imageToScreenMatrix","scene","s","scale","cx","cy","sceneTransforms2d","translateX","translateY","rotate","scaleX","scaleY","clampSizeToMax","maxSize","longest","max","k","round","boundsOfPoints","points","length","minX","minY","maxX","maxY","i","rectCenter","r","distance","hypot","distanceToSegment","lenSq","t"],"sourceRoot":"..\\..\\..\\src","sources":["utils/math.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAaO,SAASA,QAAQA,CAAA,EAAQ;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
+
import { ActivityIndicator, StyleSheet, Text, View } from 'react-native';
|
|
5
|
+
import { GestureHandlerRootView } from 'react-native-gesture-handler';
|
|
6
|
+
import { EditorProvider, useEditor } from './context/EditorContext';
|
|
7
|
+
import { useLoadedImage } from './image/useLoadedImage';
|
|
8
|
+
import { EditorCanvas } from './canvas/EditorCanvas';
|
|
9
|
+
import { TextInputOverlay } from './toolbar/TextInputOverlay';
|
|
10
|
+
import { Toolbar } from './toolbar/Toolbar';
|
|
11
|
+
import { exportImage } from './export/exportImage';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Interactive Skia image editor. Loads a base64/URI image, lets the user draw
|
|
15
|
+
* circles/arrows/markers/freehand/text, crop, free-rotate and resize, then
|
|
16
|
+
* exports full-resolution base64 (via ref `export()` or the built-in Done
|
|
17
|
+
* button + `onExport`).
|
|
18
|
+
*/
|
|
19
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
20
|
+
export const ImageEditor = /*#__PURE__*/forwardRef(function ImageEditor(props, ref) {
|
|
21
|
+
const {
|
|
22
|
+
source,
|
|
23
|
+
onError,
|
|
24
|
+
style
|
|
25
|
+
} = props;
|
|
26
|
+
const {
|
|
27
|
+
image,
|
|
28
|
+
width,
|
|
29
|
+
height,
|
|
30
|
+
loading,
|
|
31
|
+
error
|
|
32
|
+
} = useLoadedImage(source);
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
if (error) {
|
|
35
|
+
onError?.(error);
|
|
36
|
+
}
|
|
37
|
+
}, [error, onError]);
|
|
38
|
+
if (error) {
|
|
39
|
+
return /*#__PURE__*/_jsx(View, {
|
|
40
|
+
style: [styles.center, style],
|
|
41
|
+
children: /*#__PURE__*/_jsx(Text, {
|
|
42
|
+
style: styles.errorText,
|
|
43
|
+
children: "Failed to load image"
|
|
44
|
+
})
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
if (loading || !image) {
|
|
48
|
+
return /*#__PURE__*/_jsx(View, {
|
|
49
|
+
style: [styles.center, style],
|
|
50
|
+
children: /*#__PURE__*/_jsx(ActivityIndicator, {
|
|
51
|
+
color: "#FFFFFF"
|
|
52
|
+
})
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
return /*#__PURE__*/_jsx(GestureHandlerRootView, {
|
|
56
|
+
style: [styles.root, style],
|
|
57
|
+
children: /*#__PURE__*/_jsx(EditorProvider, {
|
|
58
|
+
imageSize: {
|
|
59
|
+
width,
|
|
60
|
+
height
|
|
61
|
+
},
|
|
62
|
+
initialStrokeColor: props.initialStrokeColor,
|
|
63
|
+
initialTextColor: props.initialTextColor,
|
|
64
|
+
palette: props.palette,
|
|
65
|
+
children: /*#__PURE__*/_jsx(EditorBody, {
|
|
66
|
+
ref: ref,
|
|
67
|
+
image: image,
|
|
68
|
+
...props
|
|
69
|
+
})
|
|
70
|
+
})
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
const EditorBody = /*#__PURE__*/forwardRef(function EditorBody({
|
|
74
|
+
image,
|
|
75
|
+
onExport,
|
|
76
|
+
exportOptions,
|
|
77
|
+
hideToolbar
|
|
78
|
+
}, ref) {
|
|
79
|
+
const editor = useEditor();
|
|
80
|
+
const runExport = useCallback(options => exportImage({
|
|
81
|
+
image,
|
|
82
|
+
annotations: editor.doc.annotations,
|
|
83
|
+
scene: editor.doc.scene,
|
|
84
|
+
imageWidth: editor.imageSize.width,
|
|
85
|
+
imageHeight: editor.imageSize.height,
|
|
86
|
+
options: options ?? exportOptions
|
|
87
|
+
}), [image, editor.doc, editor.imageSize, exportOptions]);
|
|
88
|
+
useImperativeHandle(ref, () => ({
|
|
89
|
+
export: runExport,
|
|
90
|
+
undo: () => editor.dispatch({
|
|
91
|
+
type: 'UNDO'
|
|
92
|
+
}),
|
|
93
|
+
redo: () => editor.dispatch({
|
|
94
|
+
type: 'REDO'
|
|
95
|
+
}),
|
|
96
|
+
canUndo: () => editor.canUndo,
|
|
97
|
+
canRedo: () => editor.canRedo,
|
|
98
|
+
reset: () => editor.dispatch({
|
|
99
|
+
type: 'RESET'
|
|
100
|
+
})
|
|
101
|
+
}), [runExport, editor]);
|
|
102
|
+
const onDone = useCallback(async () => {
|
|
103
|
+
const base64 = await runExport();
|
|
104
|
+
onExport?.(base64);
|
|
105
|
+
}, [runExport, onExport]);
|
|
106
|
+
return /*#__PURE__*/_jsxs(View, {
|
|
107
|
+
style: styles.root,
|
|
108
|
+
children: [/*#__PURE__*/_jsxs(View, {
|
|
109
|
+
style: styles.canvasWrap,
|
|
110
|
+
children: [/*#__PURE__*/_jsx(EditorCanvas, {
|
|
111
|
+
image: image
|
|
112
|
+
}), /*#__PURE__*/_jsx(TextInputOverlay, {})]
|
|
113
|
+
}), hideToolbar ? null : /*#__PURE__*/_jsx(Toolbar, {
|
|
114
|
+
onDone: onExport ? onDone : undefined
|
|
115
|
+
})]
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
const styles = StyleSheet.create({
|
|
119
|
+
root: {
|
|
120
|
+
flex: 1,
|
|
121
|
+
backgroundColor: '#000000'
|
|
122
|
+
},
|
|
123
|
+
canvasWrap: {
|
|
124
|
+
flex: 1,
|
|
125
|
+
position: 'relative'
|
|
126
|
+
},
|
|
127
|
+
center: {
|
|
128
|
+
flex: 1,
|
|
129
|
+
alignItems: 'center',
|
|
130
|
+
justifyContent: 'center',
|
|
131
|
+
backgroundColor: '#000000'
|
|
132
|
+
},
|
|
133
|
+
errorText: {
|
|
134
|
+
color: '#FF6B6B',
|
|
135
|
+
fontSize: 16
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
//# sourceMappingURL=ImageEditor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["forwardRef","useCallback","useEffect","useImperativeHandle","ActivityIndicator","StyleSheet","Text","View","GestureHandlerRootView","EditorProvider","useEditor","useLoadedImage","EditorCanvas","TextInputOverlay","Toolbar","exportImage","jsx","_jsx","jsxs","_jsxs","ImageEditor","props","ref","source","onError","style","image","width","height","loading","error","styles","center","children","errorText","color","root","imageSize","initialStrokeColor","initialTextColor","palette","EditorBody","onExport","exportOptions","hideToolbar","editor","runExport","options","annotations","doc","scene","imageWidth","imageHeight","export","undo","dispatch","type","redo","canUndo","canRedo","reset","onDone","base64","canvasWrap","undefined","create","flex","backgroundColor","position","alignItems","justifyContent","fontSize"],"sourceRoot":"..\\..\\src","sources":["ImageEditor.tsx"],"mappings":";;AAAA,SACEA,UAAU,EACVC,WAAW,EACXC,SAAS,EACTC,mBAAmB,QACd,OAAO;AACd,SACEC,iBAAiB,EACjBC,UAAU,EACVC,IAAI,EACJC,IAAI,QACC,cAAc;AACrB,SAASC,sBAAsB,QAAQ,8BAA8B;AAIrE,SAASC,cAAc,EAAEC,SAAS,QAAQ,yBAAyB;AACnE,SAASC,cAAc,QAAQ,wBAAwB;AACvD,SAASC,YAAY,QAAQ,uBAAuB;AACpD,SAASC,gBAAgB,QAAQ,4BAA4B;AAC7D,SAASC,OAAO,QAAQ,mBAAmB;AAC3C,SAASC,WAAW,QAAQ,sBAAsB;;AAElD;AACA;AACA;AACA;AACA;AACA;AALA,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAMA,OAAO,MAAMC,WAAW,gBAAGpB,UAAU,CACnC,SAASoB,WAAWA,CAACC,KAAK,EAAEC,GAAG,EAAE;EAC/B,MAAM;IAAEC,MAAM;IAAEC,OAAO;IAAEC;EAAM,CAAC,GAAGJ,KAAK;EACxC,MAAM;IAAEK,KAAK;IAAEC,KAAK;IAAEC,MAAM;IAAEC,OAAO;IAAEC;EAAM,CAAC,GAAGnB,cAAc,CAACY,MAAM,CAAC;EAEvErB,SAAS,CAAC,MAAM;IACd,IAAI4B,KAAK,EAAE;MACTN,OAAO,GAAGM,KAAK,CAAC;IAClB;EACF,CAAC,EAAE,CAACA,KAAK,EAAEN,OAAO,CAAC,CAAC;EAEpB,IAAIM,KAAK,EAAE;IACT,oBACEb,IAAA,CAACV,IAAI;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,YAAY;QAACc,KAAK,EAAEA;MAAM,CAAE,CAAC,eAC9BT,IAAA,CAACJ,gBAAgB,IAAE,CAAC;IAAA,CAChB,CAAC,EACN+B,WAAW,GAAG,IAAI,gBAAG3B,IAAA,CAACH,OAAO;MAAC+C,MAAM,EAAEnB,QAAQ,GAAGmB,MAAM,GAAGG;IAAU,CAAE,CAAC;EAAA,CACpE,CAAC;AAEX,CACF,CAAC;AAED,MAAMjC,MAAM,GAAG1B,UAAU,CAAC4D,MAAM,CAAC;EAC/B7B,IAAI,EAAE;IAAE8B,IAAI,EAAE,CAAC;IAAEC,eAAe,EAAE;EAAU,CAAC;EAC7CJ,UAAU,EAAE;IAAEG,IAAI,EAAE,CAAC;IAAEE,QAAQ,EAAE;EAAW,CAAC;EAC7CpC,MAAM,EAAE;IACNkC,IAAI,EAAE,CAAC;IACPG,UAAU,EAAE,QAAQ;IACpBC,cAAc,EAAE,QAAQ;IACxBH,eAAe,EAAE;EACnB,CAAC;EACDjC,SAAS,EAAE;IAAEC,KAAK,EAAE,SAAS;IAAEoC,QAAQ,EAAE;EAAG;AAC9C,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { CircleAnnotationView } from './CircleAnnotation';
|
|
4
|
+
import { ArrowAnnotationView } from './ArrowAnnotation';
|
|
5
|
+
import { MarkerAnnotationView } from './MarkerAnnotation';
|
|
6
|
+
import { FreehandAnnotationView } from './FreehandAnnotation';
|
|
7
|
+
import { TextAnnotationView } from './TextAnnotation';
|
|
8
|
+
|
|
9
|
+
/** Render any annotation by dispatching on its discriminant. */
|
|
10
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
+
export function AnnotationView({
|
|
12
|
+
a
|
|
13
|
+
}) {
|
|
14
|
+
switch (a.type) {
|
|
15
|
+
case 'circle':
|
|
16
|
+
return /*#__PURE__*/_jsx(CircleAnnotationView, {
|
|
17
|
+
a: a
|
|
18
|
+
});
|
|
19
|
+
case 'arrow':
|
|
20
|
+
return /*#__PURE__*/_jsx(ArrowAnnotationView, {
|
|
21
|
+
a: a
|
|
22
|
+
});
|
|
23
|
+
case 'marker':
|
|
24
|
+
return /*#__PURE__*/_jsx(MarkerAnnotationView, {
|
|
25
|
+
a: a
|
|
26
|
+
});
|
|
27
|
+
case 'freehand':
|
|
28
|
+
return /*#__PURE__*/_jsx(FreehandAnnotationView, {
|
|
29
|
+
a: a
|
|
30
|
+
});
|
|
31
|
+
case 'text':
|
|
32
|
+
return /*#__PURE__*/_jsx(TextAnnotationView, {
|
|
33
|
+
a: a
|
|
34
|
+
});
|
|
35
|
+
default:
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=AnnotationView.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["CircleAnnotationView","ArrowAnnotationView","MarkerAnnotationView","FreehandAnnotationView","TextAnnotationView","jsx","_jsx","AnnotationView","a","type"],"sourceRoot":"..\\..\\..\\src","sources":["annotations/AnnotationView.tsx"],"mappings":";;AACA,SAASA,oBAAoB,QAAQ,oBAAoB;AACzD,SAASC,mBAAmB,QAAQ,mBAAmB;AACvD,SAASC,oBAAoB,QAAQ,oBAAoB;AACzD,SAASC,sBAAsB,QAAQ,sBAAsB;AAC7D,SAASC,kBAAkB,QAAQ,kBAAkB;;AAErD;AAAA,SAAAC,GAAA,IAAAC,IAAA;AACA,OAAO,SAASC,cAAcA,CAAC;EAAEC;AAAqB,CAAC,EAAE;EACvD,QAAQA,CAAC,CAACC,IAAI;IACZ,KAAK,QAAQ;MACX,oBAAOH,IAAA,CAACN,oBAAoB;QAACQ,CAAC,EAAEA;MAAE,CAAE,CAAC;IACvC,KAAK,OAAO;MACV,oBAAOF,IAAA,CAACL,mBAAmB;QAACO,CAAC,EAAEA;MAAE,CAAE,CAAC;IACtC,KAAK,QAAQ;MACX,oBAAOF,IAAA,CAACJ,oBAAoB;QAACM,CAAC,EAAEA;MAAE,CAAE,CAAC;IACvC,KAAK,UAAU;MACb,oBAAOF,IAAA,CAACH,sBAAsB;QAACK,CAAC,EAAEA;MAAE,CAAE,CAAC;IACzC,KAAK,MAAM;MACT,oBAAOF,IAAA,CAACF,kBAAkB;QAACI,CAAC,EAAEA;MAAE,CAAE,CAAC;IACrC;MACE,OAAO,IAAI;EACf;AACF","ignoreList":[]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { useMemo } from 'react';
|
|
4
|
+
import { Path } from '@shopify/react-native-skia';
|
|
5
|
+
import { buildArrowPath } from './geometry';
|
|
6
|
+
import { annotationCenter } from './geometry';
|
|
7
|
+
import { RotatedGroup } from './RotatedGroup';
|
|
8
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
|
+
export function ArrowAnnotationView({
|
|
10
|
+
a
|
|
11
|
+
}) {
|
|
12
|
+
const path = useMemo(() => buildArrowPath(a.start, a.end, a.headSize), [a.start, a.end, a.headSize]);
|
|
13
|
+
return /*#__PURE__*/_jsx(RotatedGroup, {
|
|
14
|
+
center: annotationCenter(a),
|
|
15
|
+
rotation: a.rotation,
|
|
16
|
+
children: /*#__PURE__*/_jsx(Path, {
|
|
17
|
+
path: path,
|
|
18
|
+
color: a.strokeColor,
|
|
19
|
+
style: "stroke",
|
|
20
|
+
strokeWidth: a.strokeWidth,
|
|
21
|
+
strokeCap: "round",
|
|
22
|
+
strokeJoin: "round"
|
|
23
|
+
})
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=ArrowAnnotation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useMemo","Path","buildArrowPath","annotationCenter","RotatedGroup","jsx","_jsx","ArrowAnnotationView","a","path","start","end","headSize","center","rotation","children","color","strokeColor","style","strokeWidth","strokeCap","strokeJoin"],"sourceRoot":"..\\..\\..\\src","sources":["annotations/ArrowAnnotation.tsx"],"mappings":";;AAAA,SAASA,OAAO,QAAQ,OAAO;AAC/B,SAASC,IAAI,QAAQ,4BAA4B;AAGjD,SAASC,cAAc,QAAQ,YAAY;AAC3C,SAASC,gBAAgB,QAAQ,YAAY;AAC7C,SAASC,YAAY,QAAQ,gBAAgB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAE9C,OAAO,SAASC,mBAAmBA,CAAC;EAAEC;AAA8B,CAAC,EAAE;EACrE,MAAMC,IAAI,GAAGT,OAAO,CAClB,MAAME,cAAc,CAACM,CAAC,CAACE,KAAK,EAAEF,CAAC,CAACG,GAAG,EAAEH,CAAC,CAACI,QAAQ,CAAC,EAChD,CAACJ,CAAC,CAACE,KAAK,EAAEF,CAAC,CAACG,GAAG,EAAEH,CAAC,CAACI,QAAQ,CAC7B,CAAC;EACD,oBACEN,IAAA,CAACF,YAAY;IAACS,MAAM,EAAEV,gBAAgB,CAACK,CAAC,CAAE;IAACM,QAAQ,EAAEN,CAAC,CAACM,QAAS;IAAAC,QAAA,eAC9DT,IAAA,CAACL,IAAI;MACHQ,IAAI,EAAEA,IAAK;MACXO,KAAK,EAAER,CAAC,CAACS,WAAY;MACrBC,KAAK,EAAC,QAAQ;MACdC,WAAW,EAAEX,CAAC,CAACW,WAAY;MAC3BC,SAAS,EAAC,OAAO;MACjBC,UAAU,EAAC;IAAO,CACnB;EAAC,CACU,CAAC;AAEnB","ignoreList":[]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { Circle } from '@shopify/react-native-skia';
|
|
4
|
+
import { RotatedGroup } from './RotatedGroup';
|
|
5
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
6
|
+
export function CircleAnnotationView({
|
|
7
|
+
a
|
|
8
|
+
}) {
|
|
9
|
+
return /*#__PURE__*/_jsxs(RotatedGroup, {
|
|
10
|
+
center: a.center,
|
|
11
|
+
rotation: a.rotation,
|
|
12
|
+
children: [a.fill ? /*#__PURE__*/_jsx(Circle, {
|
|
13
|
+
cx: a.center.x,
|
|
14
|
+
cy: a.center.y,
|
|
15
|
+
r: a.radius,
|
|
16
|
+
color: a.fill
|
|
17
|
+
}) : null, /*#__PURE__*/_jsx(Circle, {
|
|
18
|
+
cx: a.center.x,
|
|
19
|
+
cy: a.center.y,
|
|
20
|
+
r: a.radius,
|
|
21
|
+
color: a.strokeColor,
|
|
22
|
+
style: "stroke",
|
|
23
|
+
strokeWidth: a.strokeWidth
|
|
24
|
+
})]
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=CircleAnnotation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Circle","RotatedGroup","jsx","_jsx","jsxs","_jsxs","CircleAnnotationView","a","center","rotation","children","fill","cx","x","cy","y","r","radius","color","strokeColor","style","strokeWidth"],"sourceRoot":"..\\..\\..\\src","sources":["annotations/CircleAnnotation.tsx"],"mappings":";;AAAA,SAASA,MAAM,QAAQ,4BAA4B;AAGnD,SAASC,YAAY,QAAQ,gBAAgB;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAE9C,OAAO,SAASC,oBAAoBA,CAAC;EAAEC;AAA+B,CAAC,EAAE;EACvE,oBACEF,KAAA,CAACJ,YAAY;IAACO,MAAM,EAAED,CAAC,CAACC,MAAO;IAACC,QAAQ,EAAEF,CAAC,CAACE,QAAS;IAAAC,QAAA,GAClDH,CAAC,CAACI,IAAI,gBACLR,IAAA,CAACH,MAAM;MAACY,EAAE,EAAEL,CAAC,CAACC,MAAM,CAACK,CAAE;MAACC,EAAE,EAAEP,CAAC,CAACC,MAAM,CAACO,CAAE;MAACC,CAAC,EAAET,CAAC,CAACU,MAAO;MAACC,KAAK,EAAEX,CAAC,CAACI;IAAK,CAAE,CAAC,GACpE,IAAI,eACRR,IAAA,CAACH,MAAM;MACLY,EAAE,EAAEL,CAAC,CAACC,MAAM,CAACK,CAAE;MACfC,EAAE,EAAEP,CAAC,CAACC,MAAM,CAACO,CAAE;MACfC,CAAC,EAAET,CAAC,CAACU,MAAO;MACZC,KAAK,EAAEX,CAAC,CAACY,WAAY;MACrBC,KAAK,EAAC,QAAQ;MACdC,WAAW,EAAEd,CAAC,CAACc;IAAY,CAC5B,CAAC;EAAA,CACU,CAAC;AAEnB","ignoreList":[]}
|