@dilemmagx/orchestra 1.0.0 → 1.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/README.md +47 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -37,6 +37,43 @@ const image = await pipeline.run(sourceFromUrl('https://example.com/image.jpg'))
|
|
|
37
37
|
await saveImage(image, './gameboy.png');
|
|
38
38
|
```
|
|
39
39
|
|
|
40
|
+
## Color Mask Mapping
|
|
41
|
+
|
|
42
|
+
```ts
|
|
43
|
+
import {
|
|
44
|
+
Pipeline,
|
|
45
|
+
createMaskMapNode,
|
|
46
|
+
createGaussianBlurNode,
|
|
47
|
+
createMapNode,
|
|
48
|
+
sourceFromUrl,
|
|
49
|
+
} from '@dilemmagx/orchestra';
|
|
50
|
+
|
|
51
|
+
const mask = createMapNode('mask', (_pixel, x, y) => {
|
|
52
|
+
const dx = x - 128;
|
|
53
|
+
const dy = y - 128;
|
|
54
|
+
const inside = dx * dx + dy * dy <= 96 * 96;
|
|
55
|
+
return inside ? '#ffffff' : '#000000';
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
const mapped = createMaskMapNode(mask, [
|
|
59
|
+
{ color: '#ffffff', source: createGaussianBlurNode(9, 2) },
|
|
60
|
+
]);
|
|
61
|
+
|
|
62
|
+
const pipeline = new Pipeline().add(mapped);
|
|
63
|
+
const image = await pipeline.run(sourceFromUrl('https://example.com/image.jpg'));
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Mask mapping uses color keys to stitch multiple image results. Each entry maps a mask
|
|
67
|
+
color to a source image or node output, with optional tolerance.
|
|
68
|
+
|
|
69
|
+
You can also use a dedicated crop node:
|
|
70
|
+
|
|
71
|
+
```ts
|
|
72
|
+
import { createSelectionCropNode } from '@dilemmagx/orchestra';
|
|
73
|
+
|
|
74
|
+
const crop = createSelectionCropNode(selector, { outsideColor: '#00000000' });
|
|
75
|
+
```
|
|
76
|
+
|
|
40
77
|
## Color Formats
|
|
41
78
|
|
|
42
79
|
```ts
|
|
@@ -77,6 +114,16 @@ Built-in nodes:
|
|
|
77
114
|
- createSharpenNode
|
|
78
115
|
- createThresholdNode
|
|
79
116
|
|
|
117
|
+
Selectors and masking:
|
|
118
|
+
|
|
119
|
+
- createAlphaSelector
|
|
120
|
+
- createCircleSelector
|
|
121
|
+
- createLumaSelector
|
|
122
|
+
- createMaskMapNode
|
|
123
|
+
- createMaskedNode
|
|
124
|
+
- createRectSelector
|
|
125
|
+
- createSelectionCropNode
|
|
126
|
+
|
|
80
127
|
## Custom Node
|
|
81
128
|
|
|
82
129
|
```ts
|