@dilemmagx/orchestra 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/README.md +94 -0
- package/package.json +43 -0
package/README.md
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
# @dilemmagx/orchestra
|
|
2
|
+
|
|
3
|
+
Orchestra is a programmable, node-based image synthesis and processing toolkit.
|
|
4
|
+
It focuses on deterministic, pixel-accurate workflows with simple composable nodes.
|
|
5
|
+
|
|
6
|
+
## Install
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
npm i @dilemmagx/orchestra
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## Quick Start
|
|
13
|
+
|
|
14
|
+
```ts
|
|
15
|
+
import { Pipeline, createNoiseNode, createInvertNode, sourceFromEmpty } from '@dilemmagx/orchestra';
|
|
16
|
+
|
|
17
|
+
const pipeline = new Pipeline().add(createNoiseNode({ grayscale: true })).add(createInvertNode());
|
|
18
|
+
|
|
19
|
+
const image = await pipeline.run(sourceFromEmpty(256, 256, 'rgba8'), { seed: 42 });
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Resize & Palette Mapping
|
|
23
|
+
|
|
24
|
+
```ts
|
|
25
|
+
import {
|
|
26
|
+
Pipeline,
|
|
27
|
+
createResizeNode,
|
|
28
|
+
createPaletteMapNode,
|
|
29
|
+
saveImage,
|
|
30
|
+
sourceFromUrl,
|
|
31
|
+
} from '@dilemmagx/orchestra';
|
|
32
|
+
|
|
33
|
+
const palette = ['#9bbc0f', '#8bac0f', '#306230', '#0f380f'];
|
|
34
|
+
const pipeline = new Pipeline().add(createResizeNode(128, 85)).add(createPaletteMapNode(palette));
|
|
35
|
+
|
|
36
|
+
const image = await pipeline.run(sourceFromUrl('https://example.com/image.jpg'));
|
|
37
|
+
await saveImage(image, './gameboy.png');
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Color Formats
|
|
41
|
+
|
|
42
|
+
```ts
|
|
43
|
+
import { toRgba, hsvaToRgba } from '@dilemmagx/orchestra';
|
|
44
|
+
|
|
45
|
+
const rgba = toRgba('#ffcc00');
|
|
46
|
+
const other = hsvaToRgba({ h: 120, s: 50, v: 90, a: 1 });
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Common Nodes
|
|
50
|
+
|
|
51
|
+
```ts
|
|
52
|
+
import { Pipeline, createGrayscaleNode, createGammaNode } from '@dilemmagx/orchestra';
|
|
53
|
+
|
|
54
|
+
const pipeline = new Pipeline().add(createGrayscaleNode()).add(createGammaNode(1.2));
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Built-in nodes:
|
|
58
|
+
|
|
59
|
+
- createBrightnessNode
|
|
60
|
+
- createCheckerboardNode
|
|
61
|
+
- createCircleNode
|
|
62
|
+
- createConvolutionNode
|
|
63
|
+
- createContrastNode
|
|
64
|
+
- createEdgeDetectNode
|
|
65
|
+
- createFillNode
|
|
66
|
+
- createGammaNode
|
|
67
|
+
- createGaussianBlurNode
|
|
68
|
+
- createGaussianNoiseNode
|
|
69
|
+
- createGrayscaleNode
|
|
70
|
+
- createInvertNode
|
|
71
|
+
- createNoiseNode
|
|
72
|
+
- createPaletteMapNode
|
|
73
|
+
- createRandomFillNode
|
|
74
|
+
- createRectNode
|
|
75
|
+
- createResizeNode
|
|
76
|
+
- createSaltPepperNoiseNode
|
|
77
|
+
- createSharpenNode
|
|
78
|
+
- createThresholdNode
|
|
79
|
+
|
|
80
|
+
## Custom Node
|
|
81
|
+
|
|
82
|
+
```ts
|
|
83
|
+
import { Pipeline, createParamNode, sourceFromEmpty } from '@dilemmagx/orchestra';
|
|
84
|
+
|
|
85
|
+
const posterize = createParamNode('posterize', { step: 32 }, (_context, image, params) =>
|
|
86
|
+
image.mapPixels((pixel) => {
|
|
87
|
+
const next = Math.round(pixel.r / params.step) * params.step;
|
|
88
|
+
return { r: next, g: next, b: next, a: pixel.a };
|
|
89
|
+
})
|
|
90
|
+
);
|
|
91
|
+
|
|
92
|
+
const pipeline = new Pipeline().add(posterize);
|
|
93
|
+
const image = await pipeline.run(sourceFromEmpty(512, 512, 'rgba8'));
|
|
94
|
+
```
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@dilemmagx/orchestra",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "A programmable node-based image synthesis and processing toolkit.",
|
|
5
|
+
"license": "GPL-3.0",
|
|
6
|
+
"publishConfig": {
|
|
7
|
+
"access": "public"
|
|
8
|
+
},
|
|
9
|
+
"author": "DilemmaGX",
|
|
10
|
+
"homepage": "https://github.com/DilemmaGX/dilib/tree/main/orchestra#readme",
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/DilemmaGX/dilib/issues"
|
|
13
|
+
},
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "https://github.com/DilemmaGX/dilib.git",
|
|
17
|
+
"directory": "orchestra"
|
|
18
|
+
},
|
|
19
|
+
"main": "dist/index.js",
|
|
20
|
+
"types": "dist/index.d.ts",
|
|
21
|
+
"files": [
|
|
22
|
+
"dist",
|
|
23
|
+
"README.md",
|
|
24
|
+
"package.json"
|
|
25
|
+
],
|
|
26
|
+
"keywords": [
|
|
27
|
+
"image",
|
|
28
|
+
"processing",
|
|
29
|
+
"graph",
|
|
30
|
+
"nodes"
|
|
31
|
+
],
|
|
32
|
+
"scripts": {
|
|
33
|
+
"build": "tsc -p tsconfig.json --emitDeclarationOnly && esbuild src/index.ts --bundle --outfile=dist/index.js --platform=node --target=node18 --sourcemap --minify"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@types/node": "^25.2.3",
|
|
37
|
+
"esbuild": "^0.27.3",
|
|
38
|
+
"typescript": "^5.9.3"
|
|
39
|
+
},
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"sharp": "^0.34.3"
|
|
42
|
+
}
|
|
43
|
+
}
|