@dilemmagx/orchestra 1.2.2 → 1.2.4
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 +26 -8
- package/dist/core/nodes.d.ts +55 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +10 -10
- package/dist/index.js.map +3 -3
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -117,14 +117,11 @@ the system font family is used when available.
|
|
|
117
117
|
```ts
|
|
118
118
|
import { Pipeline, createImageNode, sourceFromEmpty } from '@dilemmagx/orchestra';
|
|
119
119
|
|
|
120
|
-
const posterize = createImageNode(
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
const next = Math.round(pixel.r / params.step) * params.step;
|
|
126
|
-
return { r: next, g: next, b: next, a: pixel.a };
|
|
127
|
-
})
|
|
120
|
+
const posterize = createImageNode('posterize', { step: 32 }, (_context, image, params) =>
|
|
121
|
+
image.mapPixels((pixel) => {
|
|
122
|
+
const next = Math.round(pixel.r / params.step) * params.step;
|
|
123
|
+
return { r: next, g: next, b: next, a: pixel.a };
|
|
124
|
+
})
|
|
128
125
|
);
|
|
129
126
|
|
|
130
127
|
const pipeline = new Pipeline().add(posterize);
|
|
@@ -186,6 +183,23 @@ const pipeline = new Pipeline().add(mapped);
|
|
|
186
183
|
const image = await pipeline.run(sourceFromUrl('https://example.com/image.jpg'));
|
|
187
184
|
```
|
|
188
185
|
|
|
186
|
+
## Stroke Nodes
|
|
187
|
+
|
|
188
|
+
```ts
|
|
189
|
+
import {
|
|
190
|
+
Pipeline,
|
|
191
|
+
createContrastStrokeNode,
|
|
192
|
+
createAlphaStrokeNode,
|
|
193
|
+
sourceFromUrl,
|
|
194
|
+
} from '@dilemmagx/orchestra';
|
|
195
|
+
|
|
196
|
+
const pipeline = new Pipeline()
|
|
197
|
+
.add(createAlphaStrokeNode({ alphaThreshold: 8, thickness: 2, color: '#0f172a' }))
|
|
198
|
+
.add(createContrastStrokeNode({ threshold: 28, thickness: 2, color: '#ffffff' }));
|
|
199
|
+
|
|
200
|
+
const image = await pipeline.run(sourceFromUrl('https://example.com/image.png'));
|
|
201
|
+
```
|
|
202
|
+
|
|
189
203
|
## Built-in Nodes
|
|
190
204
|
|
|
191
205
|
- createBrightnessNode
|
|
@@ -193,7 +207,9 @@ const image = await pipeline.run(sourceFromUrl('https://example.com/image.jpg'))
|
|
|
193
207
|
- createCircleNode
|
|
194
208
|
- createConvolutionNode
|
|
195
209
|
- createContrastNode
|
|
210
|
+
- createContrastStrokeNode
|
|
196
211
|
- createEdgeDetectNode
|
|
212
|
+
- createAlphaStrokeNode
|
|
197
213
|
- createFillNode
|
|
198
214
|
- createGammaNode
|
|
199
215
|
- createGaussianBlurNode
|
|
@@ -219,7 +235,9 @@ const image = await pipeline.run(sourceFromUrl('https://example.com/image.jpg'))
|
|
|
219
235
|
Selectors and masking helpers:
|
|
220
236
|
|
|
221
237
|
- createAlphaSelector
|
|
238
|
+
- createAlphaStrokeSelector
|
|
222
239
|
- createCircleSelector
|
|
240
|
+
- createContrastStrokeSelector
|
|
223
241
|
- createLumaSelector
|
|
224
242
|
- createMaskMapNode
|
|
225
243
|
- createMaskedNode
|
package/dist/core/nodes.d.ts
CHANGED
|
@@ -119,7 +119,9 @@ export declare function runNodeImage(node: ImageNode, context: NodeContext, stat
|
|
|
119
119
|
/**
|
|
120
120
|
* Selector used to choose pixels for masked execution.
|
|
121
121
|
*/
|
|
122
|
-
export type PixelSelector = (pixel: Pixel, x: number, y: number, context: NodeContext) => boolean
|
|
122
|
+
export type PixelSelector = ((pixel: Pixel, x: number, y: number, context: NodeContext) => boolean) & {
|
|
123
|
+
prepare?: (image: ImageBuffer, context: NodeContext) => Uint8Array;
|
|
124
|
+
};
|
|
123
125
|
/**
|
|
124
126
|
* Masking options for nodes.
|
|
125
127
|
*/
|
|
@@ -171,6 +173,42 @@ export type CircleSelectorOptions = {
|
|
|
171
173
|
cy: number;
|
|
172
174
|
radius: number;
|
|
173
175
|
};
|
|
176
|
+
/**
|
|
177
|
+
* Options for alpha-boundary stroke nodes.
|
|
178
|
+
*/
|
|
179
|
+
export type AlphaStrokeOptions = {
|
|
180
|
+
alphaThreshold?: number;
|
|
181
|
+
thickness?: number;
|
|
182
|
+
color?: ColorInput;
|
|
183
|
+
connectivity?: 4 | 8;
|
|
184
|
+
};
|
|
185
|
+
/**
|
|
186
|
+
* Options for contrast-boundary stroke nodes.
|
|
187
|
+
*/
|
|
188
|
+
export type ContrastStrokeOptions = {
|
|
189
|
+
threshold?: number;
|
|
190
|
+
thickness?: number;
|
|
191
|
+
color?: ColorInput;
|
|
192
|
+
connectivity?: 4 | 8;
|
|
193
|
+
};
|
|
194
|
+
/**
|
|
195
|
+
* Options for alpha-boundary selectors.
|
|
196
|
+
*/
|
|
197
|
+
export type AlphaStrokeSelectorOptions = {
|
|
198
|
+
alphaThreshold?: number;
|
|
199
|
+
thickness?: number;
|
|
200
|
+
mode?: 'stroke' | 'shape';
|
|
201
|
+
connectivity?: 4 | 8;
|
|
202
|
+
};
|
|
203
|
+
/**
|
|
204
|
+
* Options for contrast-boundary selectors.
|
|
205
|
+
*/
|
|
206
|
+
export type ContrastStrokeSelectorOptions = {
|
|
207
|
+
threshold?: number;
|
|
208
|
+
thickness?: number;
|
|
209
|
+
mode?: 'stroke' | 'shape';
|
|
210
|
+
connectivity?: 4 | 8;
|
|
211
|
+
};
|
|
174
212
|
/**
|
|
175
213
|
* Creates a rectangle selector.
|
|
176
214
|
*/
|
|
@@ -187,6 +225,14 @@ export declare function createLumaSelector(threshold: number): PixelSelector;
|
|
|
187
225
|
* Creates an alpha-based selector.
|
|
188
226
|
*/
|
|
189
227
|
export declare function createAlphaSelector(threshold: number): PixelSelector;
|
|
228
|
+
/**
|
|
229
|
+
* Creates an alpha-boundary selector.
|
|
230
|
+
*/
|
|
231
|
+
export declare function createAlphaStrokeSelector(options?: AlphaStrokeSelectorOptions): PixelSelector;
|
|
232
|
+
/**
|
|
233
|
+
* Creates a contrast-boundary selector.
|
|
234
|
+
*/
|
|
235
|
+
export declare function createContrastStrokeSelector(options?: ContrastStrokeSelectorOptions): PixelSelector;
|
|
190
236
|
/**
|
|
191
237
|
* Creates a node with typed parameters stored in the node metadata.
|
|
192
238
|
*/
|
|
@@ -203,6 +249,14 @@ export declare function createMaskMapNode(mask: MaskMapSource, entries: MaskMapE
|
|
|
203
249
|
* Creates a node that removes pixels outside the selection.
|
|
204
250
|
*/
|
|
205
251
|
export declare function createSelectionCropNode(selector: PixelSelector, options?: SelectionOptions): ImageNode;
|
|
252
|
+
/**
|
|
253
|
+
* Creates a node that draws a stroke along alpha boundaries.
|
|
254
|
+
*/
|
|
255
|
+
export declare function createAlphaStrokeNode(options?: AlphaStrokeOptions): ImageNode;
|
|
256
|
+
/**
|
|
257
|
+
* Creates a node that draws a stroke along contrast boundaries.
|
|
258
|
+
*/
|
|
259
|
+
export declare function createContrastStrokeNode(options?: ContrastStrokeOptions): ImageNode;
|
|
206
260
|
/**
|
|
207
261
|
* Creates a node that maps every pixel using a custom mapper.
|
|
208
262
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export { ImageBuffer } from './core/image';
|
|
|
5
5
|
export { SeededRandom, createRandom } from './core/random';
|
|
6
6
|
export type { ResizeOptions, SaveImageOptions, TextFont, TextFontSource, TextLayout, TextOptions, TextStyle, } from './core/sources';
|
|
7
7
|
export { imageToBuffer, loadImage, renderText, resizeImage, saveImage, sourceFromBuffer, sourceFromDataUri, sourceFromEmpty, sourceFromPath, sourceFromUrl, } from './core/sources';
|
|
8
|
-
export type { CircleSelectorOptions, ImageInput, ImageNode, ImageNodeOptions, MaskMapEntry, MaskMapOptions, MaskMapSource, NodeDefinition, NodeContext, NodeResult, NodeState, ParametricNode, PixelMatrix, PixelNodeInfo, PixelNodeRunner, PixelSelector, FractalNoiseOptions, PerlinNoiseOptions, RectSelectorOptions, SelectionMode, SelectionOptions, SimpleNodeDefinition, ValueNoiseOptions, RidgedNoiseOptions, TurbulenceNoiseOptions, VoronoiNoiseOptions, } from './core/nodes';
|
|
9
|
-
export { DEFAULT_IMAGE_KEY, createBrightnessNode, createCircleSelector, createCheckerboardNode, createCircleNode, createConvolutionNode, createContrastNode, createAlphaSelector, createEdgeDetectNode, createFillNode, createGammaNode, createGaussianBlurNode, createGaussianNoiseNode, createGrayscaleNode, createInvertNode, createImageNode, createPixelNode, createLumaSelector, createMapNode, createMaskMapNode, createMaskedNode, createNoiseNode, createFractalNoiseNode, createPerlinNoiseNode, createRidgedNoiseNode, createTurbulenceNoiseNode, createValueNoiseNode, createVoronoiNoiseNode, createPaletteMapNode, createParamNode, createRandomFillNode, createRectSelector, createResizeNode, createSelectionCropNode, createRectNode, createSaltPepperNoiseNode, createSharpenNode, createThresholdNode, createTextNode, defineNode, getImage, mergeNodeState, node, runNode, runNodeImage, buildBoxKernel, buildGaussianKernel, } from './core/nodes';
|
|
8
|
+
export type { AlphaStrokeOptions, AlphaStrokeSelectorOptions, CircleSelectorOptions, ContrastStrokeOptions, ContrastStrokeSelectorOptions, ImageInput, ImageNode, ImageNodeOptions, MaskMapEntry, MaskMapOptions, MaskMapSource, NodeDefinition, NodeContext, NodeResult, NodeState, ParametricNode, PixelMatrix, PixelNodeInfo, PixelNodeRunner, PixelSelector, FractalNoiseOptions, PerlinNoiseOptions, RectSelectorOptions, SelectionMode, SelectionOptions, SimpleNodeDefinition, ValueNoiseOptions, RidgedNoiseOptions, TurbulenceNoiseOptions, VoronoiNoiseOptions, } from './core/nodes';
|
|
9
|
+
export { DEFAULT_IMAGE_KEY, createAlphaStrokeNode, createAlphaStrokeSelector, createBrightnessNode, createCircleSelector, createCheckerboardNode, createCircleNode, createConvolutionNode, createContrastNode, createAlphaSelector, createContrastStrokeNode, createContrastStrokeSelector, createEdgeDetectNode, createFillNode, createGammaNode, createGaussianBlurNode, createGaussianNoiseNode, createGrayscaleNode, createInvertNode, createImageNode, createPixelNode, createLumaSelector, createMapNode, createMaskMapNode, createMaskedNode, createNoiseNode, createFractalNoiseNode, createPerlinNoiseNode, createRidgedNoiseNode, createTurbulenceNoiseNode, createValueNoiseNode, createVoronoiNoiseNode, createPaletteMapNode, createParamNode, createRandomFillNode, createRectSelector, createResizeNode, createSelectionCropNode, createRectNode, createSaltPepperNoiseNode, createSharpenNode, createThresholdNode, createTextNode, defineNode, getImage, mergeNodeState, node, runNode, runNodeImage, buildBoxKernel, buildGaussianKernel, } from './core/nodes';
|
|
10
10
|
export type { PipelineInput, PipelineOptions } from './core/pipeline';
|
|
11
11
|
export { Pipeline, createExamplePipeline, pipeline } from './core/pipeline';
|