@umituz/react-native-design-system 4.23.59 → 4.23.60
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umituz/react-native-design-system",
|
|
3
|
-
"version": "4.23.
|
|
3
|
+
"version": "4.23.60",
|
|
4
4
|
"description": "Universal design system for React Native apps - Consolidated package with atoms, molecules, organisms, theme, typography, responsive, safe area, exception, infinite scroll, UUID, image, timezone, offline, onboarding, and loading utilities",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"types": "./src/index.ts",
|
|
@@ -14,8 +14,8 @@ import { ImageErrorHandler, IMAGE_ERROR_CODES } from '../utils/ImageErrorHandler
|
|
|
14
14
|
import { ImageEditorHistoryUtils } from '../utils/ImageEditorHistoryUtils';
|
|
15
15
|
|
|
16
16
|
export class ImageEditorService {
|
|
17
|
-
|
|
18
|
-
return Math.random().toString(36).
|
|
17
|
+
static generateId(): string {
|
|
18
|
+
return Math.random().toString(36).substring(2, 11);
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
static createInitialState(
|
|
@@ -52,9 +52,8 @@ export class ImageAnalysisUtils {
|
|
|
52
52
|
return noiseLevel / (sampleCount * 3 * 255);
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
static applySharpening(imageData: Uint8ClampedArray): Uint8ClampedArray {
|
|
55
|
+
static applySharpening(imageData: Uint8ClampedArray, width: number, height: number): Uint8ClampedArray {
|
|
56
56
|
const result = new Uint8ClampedArray(imageData.length);
|
|
57
|
-
const width = Math.sqrt(imageData.length / 4);
|
|
58
57
|
const kernel = [
|
|
59
58
|
0, -1, 0,
|
|
60
59
|
-1, 5, -1,
|
|
@@ -73,7 +72,7 @@ export class ImageAnalysisUtils {
|
|
|
73
72
|
const nx = x + kx;
|
|
74
73
|
const ny = y + ky;
|
|
75
74
|
|
|
76
|
-
if (nx >= 0 && nx < width && ny >= 0 && ny <
|
|
75
|
+
if (nx >= 0 && nx < width && ny >= 0 && ny < height) {
|
|
77
76
|
const neighborIndex = (ny * width + nx) * 4 + c;
|
|
78
77
|
sum += (imageData[neighborIndex] ?? 0) * (kernel[(ky + 1) * 3 + (kx + 1)] ?? 0);
|
|
79
78
|
}
|
|
@@ -87,9 +86,8 @@ export class ImageAnalysisUtils {
|
|
|
87
86
|
return result;
|
|
88
87
|
}
|
|
89
88
|
|
|
90
|
-
static applyNoiseReduction(imageData: Uint8ClampedArray): Uint8ClampedArray {
|
|
89
|
+
static applyNoiseReduction(imageData: Uint8ClampedArray, width: number, height: number): Uint8ClampedArray {
|
|
91
90
|
const result = new Uint8ClampedArray(imageData.length);
|
|
92
|
-
const width = Math.sqrt(imageData.length / 4);
|
|
93
91
|
|
|
94
92
|
for (let i = 0; i < imageData.length; i += 4) {
|
|
95
93
|
const pixelIndex = i / 4;
|
|
@@ -104,7 +102,7 @@ export class ImageAnalysisUtils {
|
|
|
104
102
|
const nx = x + dx;
|
|
105
103
|
const ny = y + dy;
|
|
106
104
|
|
|
107
|
-
if (nx >= 0 && nx < width && ny >= 0 && ny <
|
|
105
|
+
if (nx >= 0 && nx < width && ny >= 0 && ny < height) {
|
|
108
106
|
const neighborIndex = (ny * width + nx) * 4 + c;
|
|
109
107
|
values.push(imageData[neighborIndex] ?? 0);
|
|
110
108
|
}
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import type { EditorLayer } from '../../domain/entities/EditorTypes';
|
|
8
|
+
import { ImageEditorService } from '../services/ImageEditorService';
|
|
8
9
|
|
|
9
10
|
type LayerElement = EditorLayer['elements'][number];
|
|
10
11
|
export type LayerOperation = 'add' | 'remove' | 'move' | 'merge' | 'duplicate';
|
|
@@ -19,46 +20,31 @@ export class LayerManager {
|
|
|
19
20
|
|
|
20
21
|
|
|
21
22
|
static mergeLayers(
|
|
22
|
-
layers:
|
|
23
|
-
id: string;
|
|
24
|
-
name: string;
|
|
25
|
-
elements: LayerElement[];
|
|
26
|
-
}>,
|
|
23
|
+
layers: EditorLayer[],
|
|
27
24
|
targetIds: string[]
|
|
28
|
-
):
|
|
29
|
-
id: string;
|
|
30
|
-
name: string;
|
|
31
|
-
elements: LayerElement[];
|
|
32
|
-
}> {
|
|
25
|
+
): EditorLayer[] {
|
|
33
26
|
const targetLayers = layers.filter(layer => targetIds.includes(layer.id));
|
|
34
27
|
const otherLayers = layers.filter(layer => !targetIds.includes(layer.id));
|
|
35
28
|
|
|
36
29
|
if (targetLayers.length === 0) return layers;
|
|
37
30
|
|
|
38
|
-
// Merge elements from target layers
|
|
39
31
|
const mergedElements = targetLayers.flatMap(layer => layer.elements);
|
|
40
|
-
const mergedLayer = {
|
|
41
|
-
id:
|
|
32
|
+
const mergedLayer: EditorLayer = {
|
|
33
|
+
id: ImageEditorService.generateId(),
|
|
42
34
|
name: targetLayers.map(l => l.name).join(' + '),
|
|
35
|
+
visible: true,
|
|
36
|
+
opacity: 1,
|
|
37
|
+
locked: false,
|
|
43
38
|
elements: mergedElements,
|
|
44
39
|
};
|
|
45
40
|
|
|
46
41
|
return [...otherLayers, mergedLayer];
|
|
47
42
|
}
|
|
48
43
|
|
|
49
|
-
static duplicateLayer(
|
|
50
|
-
layer: {
|
|
51
|
-
id: string;
|
|
52
|
-
name: string;
|
|
53
|
-
elements: LayerElement[];
|
|
54
|
-
}
|
|
55
|
-
): {
|
|
56
|
-
id: string;
|
|
57
|
-
name: string;
|
|
58
|
-
elements: LayerElement[];
|
|
59
|
-
} {
|
|
44
|
+
static duplicateLayer(layer: EditorLayer): EditorLayer {
|
|
60
45
|
return {
|
|
61
|
-
|
|
46
|
+
...layer,
|
|
47
|
+
id: ImageEditorService.generateId(),
|
|
62
48
|
name: `${layer.name} Copy`,
|
|
63
49
|
elements: [...layer.elements],
|
|
64
50
|
};
|
|
@@ -46,11 +46,11 @@ export const CircularMenu: React.FC<CircularMenuProps> = ({
|
|
|
46
46
|
*/
|
|
47
47
|
const layoutItems = useMemo(() => {
|
|
48
48
|
if (actions.length === 3) {
|
|
49
|
-
// Triangle
|
|
49
|
+
// Triangle layout: middle item on top, first and last on bottom
|
|
50
50
|
return [
|
|
51
|
-
{ ...actions[1], position: getTopRowPosition(0, 1) },
|
|
52
|
-
{ ...actions[0], position: getBottomRowPosition("left") },
|
|
53
|
-
{ ...actions[2], position: getBottomRowPosition("right") },
|
|
51
|
+
{ ...actions[1], position: getTopRowPosition(0, 1) },
|
|
52
|
+
{ ...actions[0], position: getBottomRowPosition("left") },
|
|
53
|
+
{ ...actions[2], position: getBottomRowPosition("right") },
|
|
54
54
|
];
|
|
55
55
|
} else if (actions.length === 2) {
|
|
56
56
|
// 2 items: place on bottom left and right of close button
|