instantshader 0.4.1 → 0.6.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 +30 -0
- package/dist/index.d.ts +287 -5
- package/dist/index.js +3036 -252
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+

|
|
2
|
+
|
|
1
3
|
# instantshader
|
|
2
4
|
|
|
3
5
|
Animated WebGL gradient shaders with zero dependencies. Mount a live, resizable
|
|
@@ -33,6 +35,13 @@ tree-shake away.
|
|
|
33
35
|
| `flow` | Isotropic swirling currents. A curl-noise field advects the sample point before it hits fbm, so colour masses travel in continuous, fluid-like eddies with defined luminous edges and generous calm negative space. | `scale`, `curl`, `drift`, `openness`, `grain` |
|
|
34
36
|
| `beam` | One wide beam of soft light crossing a near-black frame. The palette walks the beam's length, thin brighter filaments crawl inside it, and most of the frame is dark negative space. | `scale`, `width`, `glow`, `angle`, `grain` |
|
|
35
37
|
| `bloom` | A fan of huge, ultra-soft petals radiating from the frame's bottom edge. One analytic rose-curve field, so the palette reads as concentric scalloped bands from a hot core out to a dark background, with thin dark creases between the petals. | `scale`, `petals`, `pinch`, `bend`, `sway`, `colorflow`, `grain` |
|
|
38
|
+
| `halo` | An eclipse: one dark disc with a razor-bright limb and a corona of streamers flowing outward, the palette wrapped around the ring. `x` / `y` place the disc; the default sinks it below the frame for a glowing horizon arc. | `radius`, `x`, `y`, `glow`, `crescent`, `flares`, `grain` |
|
|
39
|
+
| `strata` | Stacked cut-paper sheets, one per palette step, each casting a soft shadow on the one below. `ridges` and `stretch` reshape the relief itself, from round islands to branching spines to long agate bands. | `scale`, `layers`, `warp`, `ridges`, `stretch`, `depth`, `blend`, `angle`, `grain` |
|
|
40
|
+
| `dune` | Overlapping crests rolling across the frame, back to front. Each has one crisp top edge and airbrushes away below it; neighbouring crests slide against each other. | `layers`, `swell`, `waves`, `fade`, `soft`, `angle`, `grain` |
|
|
41
|
+
| `whorl` | A logarithmic spiral of curved blades, each with one sharp leading edge and a soft fade behind it. `x` / `y` place the centre anywhere, including off-frame. | `blades`, `twist`, `depth`, `scale`, `wobble`, `x`, `y`, `grain` |
|
|
42
|
+
|
|
43
|
+
Previews of every look, with full param ranges, are in the
|
|
44
|
+
[repository README](https://github.com/ugolbck/instantshader#readme).
|
|
36
45
|
|
|
37
46
|
Every shader takes the same mount options; `params` is where they differ:
|
|
38
47
|
|
|
@@ -53,6 +62,25 @@ is an array of `ParamDef`, and `shader.randomParams(rand)` produces a full,
|
|
|
53
62
|
sensible param set for "randomize" flows. `shaders` and `getShader(id)` expose
|
|
54
63
|
the whole registry (importing either pulls every shader).
|
|
55
64
|
|
|
65
|
+
## Effects
|
|
66
|
+
|
|
67
|
+
Effects redraw an existing picture: a generator's output or your own image, canvas or video frame.
|
|
68
|
+
|
|
69
|
+
```ts
|
|
70
|
+
import { mountStack, bloom, dither } from "instantshader";
|
|
71
|
+
|
|
72
|
+
mountStack(el, {
|
|
73
|
+
source: { kind: "generator", shader: bloom },
|
|
74
|
+
colors: ["#140f30", "#9c2168", "#eb6a4e", "#fcd87c"],
|
|
75
|
+
effects: [{ effect: dither, params: { pattern: "blueNoise", colorMode: "palette", levels: 4 } }],
|
|
76
|
+
loopSeconds: 30,
|
|
77
|
+
});
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
`pixelate`, `dither`, `halftone` and `ascii` ship today; `effects` and `getEffect(id)` list them, and each `EffectDef.params` describes its controls (float, enum, bool and color, with a `when` hint for conditional ones). Use `{ kind: "media", media }` as the source for an image. `createStackRenderer` is the seekable renderer for export and `renderStackFrame` the one-shot.
|
|
81
|
+
|
|
82
|
+
Effect sizes are in pixels at 1080p and effects work on a per-cell buffer that is identical at every output size, so an export matches its preview cell for cell. The [main README](../../README.md#effects) has the details.
|
|
83
|
+
|
|
56
84
|
## Seamless loops
|
|
57
85
|
|
|
58
86
|
Set `loopSeconds` and the animation repeats exactly, with no visible seam at
|
|
@@ -104,5 +132,7 @@ Notes:
|
|
|
104
132
|
shorter than about half its own period, so below ~10s the wander is the only
|
|
105
133
|
thing left moving. `colorflow` is unaffected — it always fits at least one
|
|
106
134
|
full cycle into the loop, flowing faster on a short one.
|
|
135
|
+
- `halo`, `dune` and `whorl` always complete at least one full cycle of their
|
|
136
|
+
main motion per loop, so a short loop simply runs them faster.
|
|
107
137
|
- Any loop necessarily revisits the same state every N seconds; a long period
|
|
108
138
|
is what buys the impression of never repeating.
|
package/dist/index.d.ts
CHANGED
|
@@ -12,6 +12,29 @@ type Renderer = {
|
|
|
12
12
|
};
|
|
13
13
|
declare function createRenderer(opts: RendererOptions): Renderer;
|
|
14
14
|
//#endregion
|
|
15
|
+
//#region src/stack.d.ts
|
|
16
|
+
type StackRenderer = {
|
|
17
|
+
renderAt(timeMs: number): void;
|
|
18
|
+
setColors(colors: string[]): void;
|
|
19
|
+
/** Swaps the source. Recompiles only when the generator shader changed. */
|
|
20
|
+
setSource(source: Source): void;
|
|
21
|
+
/** Replaces the generator source's params. No-op for a media source. */
|
|
22
|
+
setSourceParams(params: Record<string, number>): void;
|
|
23
|
+
/** Re-uploads the media element's current pixels, e.g. after a video
|
|
24
|
+
* element advanced a frame. */
|
|
25
|
+
refreshMedia(): void;
|
|
26
|
+
/** Replaces the layer list. Layers whose EffectDef is unchanged at the same
|
|
27
|
+
* position keep their compiled programs. */
|
|
28
|
+
setEffects(layers: EffectLayer[]): void;
|
|
29
|
+
/** Merges params into one layer. */
|
|
30
|
+
setEffectParams(index: number, params: Record<string, ParamValue>): void;
|
|
31
|
+
setLoopSeconds(seconds: number | undefined): void;
|
|
32
|
+
resize(width: number, height: number): void;
|
|
33
|
+
getGridInfo(): GridInfo[];
|
|
34
|
+
dispose(): void;
|
|
35
|
+
};
|
|
36
|
+
declare function createStackRenderer(opts: StackOptions): StackRenderer;
|
|
37
|
+
//#endregion
|
|
15
38
|
//#region src/types.d.ts
|
|
16
39
|
/**
|
|
17
40
|
* Describes a single tunable knob exposed by a shader (e.g. "frequency",
|
|
@@ -116,6 +139,185 @@ type RendererOptions = {
|
|
|
116
139
|
* See MountOptions.loopSeconds. */
|
|
117
140
|
loopSeconds?: number;
|
|
118
141
|
};
|
|
142
|
+
/** A generator is what this library has always called a shader. */
|
|
143
|
+
type GeneratorDef = ShaderDef;
|
|
144
|
+
/** Effect params are wider than generator params: a dither needs a pattern
|
|
145
|
+
* choice and two colors, which floats cannot express. */
|
|
146
|
+
type ParamValue = number | boolean | string;
|
|
147
|
+
type EffectParamBase = {
|
|
148
|
+
/** Param identifier. The GLSL uniform name is always "u_" + key. */
|
|
149
|
+
key: string;
|
|
150
|
+
label: string;
|
|
151
|
+
/** UI hint: show this control only while another param holds one of these
|
|
152
|
+
* values. The runtime ignores it. */
|
|
153
|
+
when?: {
|
|
154
|
+
key: string;
|
|
155
|
+
in: ParamValue[];
|
|
156
|
+
};
|
|
157
|
+
};
|
|
158
|
+
/** `type` is optional so that a generator's ParamDef is a valid FloatParamDef. */
|
|
159
|
+
type FloatParamDef = EffectParamBase & {
|
|
160
|
+
type?: "float";
|
|
161
|
+
min: number;
|
|
162
|
+
max: number;
|
|
163
|
+
step: number;
|
|
164
|
+
default: number;
|
|
165
|
+
};
|
|
166
|
+
/** Values are strings so that reordering `options` never changes a saved
|
|
167
|
+
* design. The uniform is a float holding the option's index. */
|
|
168
|
+
type EnumParamDef = EffectParamBase & {
|
|
169
|
+
type: "enum";
|
|
170
|
+
options: {
|
|
171
|
+
value: string;
|
|
172
|
+
label: string;
|
|
173
|
+
}[];
|
|
174
|
+
default: string;
|
|
175
|
+
};
|
|
176
|
+
/** Uniform is a float, 0 or 1. */
|
|
177
|
+
type BoolParamDef = EffectParamBase & {
|
|
178
|
+
type: "bool";
|
|
179
|
+
default: boolean;
|
|
180
|
+
};
|
|
181
|
+
/** "#rrggbb". Uniform is a vec3 of gamma-encoded sRGB in 0-1. */
|
|
182
|
+
type ColorParamDef = EffectParamBase & {
|
|
183
|
+
type: "color";
|
|
184
|
+
default: string;
|
|
185
|
+
};
|
|
186
|
+
type EffectParamDef = FloatParamDef | EnumParamDef | BoolParamDef | ColorParamDef;
|
|
187
|
+
/** What an EffectTexture's key() and build() get to look at. */
|
|
188
|
+
type TextureEnv = {
|
|
189
|
+
/** The layer's fully resolved params. */
|
|
190
|
+
params: Record<string, ParamValue>;
|
|
191
|
+
/** Frame size in device pixels. */
|
|
192
|
+
width: number;
|
|
193
|
+
height: number;
|
|
194
|
+
/** Device pixels per reference pixel. */
|
|
195
|
+
outputScale: number;
|
|
196
|
+
/** From StackOptions.fontFamily, for effects that draw text. */
|
|
197
|
+
fontFamily: string;
|
|
198
|
+
};
|
|
199
|
+
type TextureData = {
|
|
200
|
+
/** Raw bytes are read as one channel when data.length === width * height,
|
|
201
|
+
* as RGBA when it is four times that. */
|
|
202
|
+
source: TexImageSource | {
|
|
203
|
+
data: Uint8Array;
|
|
204
|
+
width: number;
|
|
205
|
+
height: number;
|
|
206
|
+
};
|
|
207
|
+
filter: "nearest" | "linear";
|
|
208
|
+
/** "repeat" is only legal for power-of-two sizes in WebGL1. */
|
|
209
|
+
wrap: "clamp" | "repeat";
|
|
210
|
+
/** Extra uniforms describing the texture, e.g. an atlas's grid and glyph
|
|
211
|
+
* count. A number sets a float, an array a vec2/vec3/vec4. */
|
|
212
|
+
uniforms?: Record<string, number | number[]>;
|
|
213
|
+
};
|
|
214
|
+
/** An extra texture an effect needs, built by JS: a glyph atlas, a noise tile. */
|
|
215
|
+
type EffectTexture = {
|
|
216
|
+
/** Sampler uniform name, e.g. "u_atlas". */
|
|
217
|
+
uniform: string;
|
|
218
|
+
/** Cache key. The runtime rebuilds the texture when this changes. */
|
|
219
|
+
key: (env: TextureEnv) => string;
|
|
220
|
+
build: (env: TextureEnv) => TextureData;
|
|
221
|
+
};
|
|
222
|
+
/**
|
|
223
|
+
* A registered effect. Two shapes:
|
|
224
|
+
*
|
|
225
|
+
* - SOFT effect: only `fragment`. Runs once per output pixel and reads the
|
|
226
|
+
* layer below as `u_source`.
|
|
227
|
+
* - GRID effect: has `grid`. `grid.fragment` is the CELL STAGE, run once per
|
|
228
|
+
* cell into a small cell buffer whose size depends on params and aspect
|
|
229
|
+
* ratio only. `fragment` is then the DRAW STAGE that paints that buffer
|
|
230
|
+
* onto the frame; omit it to get the default coverage upscale.
|
|
231
|
+
*
|
|
232
|
+
* The cell buffer is what makes a 900px preview and a 3840px export contain
|
|
233
|
+
* the same cells. See SPEC-effects.md section 6.
|
|
234
|
+
*/
|
|
235
|
+
type EffectDef = {
|
|
236
|
+
id: string;
|
|
237
|
+
label: string;
|
|
238
|
+
params: EffectParamDef[];
|
|
239
|
+
fragment?: string;
|
|
240
|
+
grid?: {
|
|
241
|
+
/** Cell size in reference pixels, from the layer's resolved params.
|
|
242
|
+
* Rounded to whole reference pixels unless `lattice` is given. */
|
|
243
|
+
cell: (params: Record<string, ParamValue>) => [number, number];
|
|
244
|
+
/**
|
|
245
|
+
* Makes the grid a LATTICE: rotated by `angle` degrees about the frame
|
|
246
|
+
* centre, with an unrounded pitch. For effects whose draw stage paints
|
|
247
|
+
* soft antialiased shapes (halftone) rather than filling cells, so that
|
|
248
|
+
* nothing needs to land on whole pixels. coverage() is meaningless for a
|
|
249
|
+
* lattice; such an effect must supply its own draw `fragment`.
|
|
250
|
+
*/
|
|
251
|
+
lattice?: (params: Record<string, ParamValue>) => {
|
|
252
|
+
angle: number;
|
|
253
|
+
};
|
|
254
|
+
fragment: string;
|
|
255
|
+
};
|
|
256
|
+
textures?: EffectTexture[];
|
|
257
|
+
/** Same contract as ShaderDef.randomParams. */
|
|
258
|
+
randomParams: (rand: () => number) => Record<string, ParamValue>;
|
|
259
|
+
};
|
|
260
|
+
/** The bottom of a stack. */
|
|
261
|
+
type Source = {
|
|
262
|
+
kind: "generator";
|
|
263
|
+
shader: ShaderDef;
|
|
264
|
+
params?: Record<string, number>;
|
|
265
|
+
} | {
|
|
266
|
+
kind: "media";
|
|
267
|
+
media: TexImageSource;
|
|
268
|
+
fit?: "cover" | "contain";
|
|
269
|
+
};
|
|
270
|
+
/** One effect in a stack. */
|
|
271
|
+
type EffectLayer = {
|
|
272
|
+
effect: EffectDef;
|
|
273
|
+
/** Overrides; unset keys fall back to the param's default. */
|
|
274
|
+
params?: Record<string, ParamValue>;
|
|
275
|
+
/** Defaults to true. A disabled layer renders as if it were absent. */
|
|
276
|
+
enabled?: boolean;
|
|
277
|
+
};
|
|
278
|
+
type StackOptions = {
|
|
279
|
+
canvas: HTMLCanvasElement;
|
|
280
|
+
source: Source;
|
|
281
|
+
effects?: EffectLayer[];
|
|
282
|
+
/** Hex color stops of the palette ramp. Generators draw with it; effects
|
|
283
|
+
* in "palette" color mode map tone through it. */
|
|
284
|
+
colors: string[];
|
|
285
|
+
seed?: number;
|
|
286
|
+
/** See MountOptions.loopSeconds. Shared by the source and every layer. */
|
|
287
|
+
loopSeconds?: number;
|
|
288
|
+
/** Shown behind contain-fit media and under media alpha. Default black. */
|
|
289
|
+
background?: string;
|
|
290
|
+
/** CSS font-family for effects that draw text. The host must have loaded
|
|
291
|
+
* it (document.fonts.load) before creating the stack. */
|
|
292
|
+
fontFamily?: string;
|
|
293
|
+
};
|
|
294
|
+
/** Per grid layer: how the grid lands on the current frame. A host can use
|
|
295
|
+
* pxPerCell to warn that a small preview cannot resolve a fine pattern. */
|
|
296
|
+
type GridInfo = {
|
|
297
|
+
/** Index into the layer list. */
|
|
298
|
+
index: number;
|
|
299
|
+
cols: number;
|
|
300
|
+
rows: number;
|
|
301
|
+
pxPerCell: [number, number];
|
|
302
|
+
};
|
|
303
|
+
/** Options accepted by mountStack(): StackOptions without the canvas (the
|
|
304
|
+
* mount owns one), plus playback speed. */
|
|
305
|
+
type StackMountOptions = Omit<StackOptions, "canvas"> & {
|
|
306
|
+
/** Animation speed multiplier. Defaults to 1. */
|
|
307
|
+
speed?: number;
|
|
308
|
+
};
|
|
309
|
+
/** Live handle returned by mountStack(). */
|
|
310
|
+
type StackHandle = Omit<MountHandle, "setParams"> & {
|
|
311
|
+
setSource(source: Source): void;
|
|
312
|
+
/** Merges params into a generator source. No-op for a media source. */
|
|
313
|
+
setSourceParams(params: Record<string, number>): void;
|
|
314
|
+
setEffects(layers: EffectLayer[]): void;
|
|
315
|
+
/** Merges params into one layer. */
|
|
316
|
+
setEffectParams(index: number, params: Record<string, ParamValue>): void;
|
|
317
|
+
/** Re-uploads the media element's current pixels. */
|
|
318
|
+
refreshMedia(): void;
|
|
319
|
+
getGridInfo(): GridInfo[];
|
|
320
|
+
};
|
|
119
321
|
//#endregion
|
|
120
322
|
//#region src/shaders/flow.d.ts
|
|
121
323
|
declare const flow: ShaderDef;
|
|
@@ -126,13 +328,41 @@ declare const beam: ShaderDef;
|
|
|
126
328
|
//#region src/shaders/bloom.d.ts
|
|
127
329
|
declare const bloom: ShaderDef;
|
|
128
330
|
//#endregion
|
|
331
|
+
//#region src/shaders/halo.d.ts
|
|
332
|
+
declare const halo: ShaderDef;
|
|
333
|
+
//#endregion
|
|
334
|
+
//#region src/shaders/strata.d.ts
|
|
335
|
+
declare const strata: ShaderDef;
|
|
336
|
+
//#endregion
|
|
337
|
+
//#region src/shaders/dune.d.ts
|
|
338
|
+
declare const dune: ShaderDef;
|
|
339
|
+
//#endregion
|
|
340
|
+
//#region src/shaders/whorl.d.ts
|
|
341
|
+
declare const whorl: ShaderDef;
|
|
342
|
+
//#endregion
|
|
343
|
+
//#region src/effects/pixelate.d.ts
|
|
344
|
+
declare const pixelate: EffectDef;
|
|
345
|
+
//#endregion
|
|
346
|
+
//#region src/effects/dither.d.ts
|
|
347
|
+
declare const dither: EffectDef;
|
|
348
|
+
//#endregion
|
|
349
|
+
//#region src/effects/halftone.d.ts
|
|
350
|
+
declare const halftone: EffectDef;
|
|
351
|
+
//#endregion
|
|
352
|
+
//#region src/effects/ascii.d.ts
|
|
353
|
+
declare const ascii: EffectDef;
|
|
354
|
+
//#endregion
|
|
129
355
|
//#region src/registry.d.ts
|
|
130
356
|
declare const shaders: readonly ShaderDef[];
|
|
131
357
|
declare function getShader(id: string): ShaderDef | undefined;
|
|
132
358
|
//#endregion
|
|
359
|
+
//#region src/effectRegistry.d.ts
|
|
360
|
+
declare const effects: readonly EffectDef[];
|
|
361
|
+
declare function getEffect(id: string): EffectDef | undefined;
|
|
362
|
+
//#endregion
|
|
133
363
|
//#region src/mount.d.ts
|
|
134
364
|
/**
|
|
135
|
-
* Mounts a live, animated
|
|
365
|
+
* Mounts a live, animated stack (a source plus effect layers) into `container` and returns a handle to
|
|
136
366
|
* control it. Owns a canvas (sized to the container via ResizeObserver, DPR
|
|
137
367
|
* capped at 2 to bound fill-rate cost on high-density displays) and a RAF
|
|
138
368
|
* loop that runs ONLY while playing — the same lifecycle used by the
|
|
@@ -147,19 +377,35 @@ declare function getShader(id: string): ShaderDef | undefined;
|
|
|
147
377
|
* callers may mount many simultaneously-paused instances (e.g. a screenshot
|
|
148
378
|
* grid) that must never carry a perpetual 60fps draw loop each.
|
|
149
379
|
*/
|
|
380
|
+
declare function mountStack(container: HTMLElement, opts: StackMountOptions): StackHandle;
|
|
381
|
+
/** mountStack() for the common case of one generator and no effects. */
|
|
150
382
|
declare function mountGradient(container: HTMLElement, opts: MountOptions): MountHandle;
|
|
151
383
|
//#endregion
|
|
152
384
|
//#region src/frame.d.ts
|
|
153
385
|
/**
|
|
154
|
-
* Renders a single frame
|
|
155
|
-
* pixel size, for export/thumbnail
|
|
156
|
-
* snapshot rather than a live animation.
|
|
386
|
+
* Renders a single frame of a stack (a source plus effect layers) into a
|
|
387
|
+
* detached (not-in-DOM) canvas at an exact pixel size, for export/thumbnail
|
|
388
|
+
* use cases that need a synchronous snapshot rather than a live animation.
|
|
157
389
|
*
|
|
158
390
|
* The returned canvas is NOT disposed automatically — its GL context must
|
|
159
391
|
* stay alive after this function returns so callers can scrape pixels from
|
|
160
392
|
* it (toDataURL/toBlob/getImageData/drawImage). Once the caller is done
|
|
161
393
|
* with it, release the GL context by calling the returned `dispose()`.
|
|
162
394
|
*/
|
|
395
|
+
declare function renderStackFrame(opts: {
|
|
396
|
+
source: Source;
|
|
397
|
+
effects?: EffectLayer[];
|
|
398
|
+
colors: string[];
|
|
399
|
+
seed?: number;
|
|
400
|
+
timeMs?: number;
|
|
401
|
+
/** See MountOptions.loopSeconds. */
|
|
402
|
+
loopSeconds?: number;
|
|
403
|
+
background?: string;
|
|
404
|
+
fontFamily?: string;
|
|
405
|
+
width: number;
|
|
406
|
+
height: number;
|
|
407
|
+
}): RenderFrameResult;
|
|
408
|
+
/** renderStackFrame() for the common case of one generator and no effects. */
|
|
163
409
|
declare function renderGradientFrame(opts: {
|
|
164
410
|
shader: ShaderDef;
|
|
165
411
|
colors: string[];
|
|
@@ -175,6 +421,42 @@ declare function renderGradientFrame(opts: {
|
|
|
175
421
|
height: number;
|
|
176
422
|
}): RenderFrameResult;
|
|
177
423
|
//#endregion
|
|
424
|
+
//#region src/grid.d.ts
|
|
425
|
+
type Grid = {
|
|
426
|
+
cols: number;
|
|
427
|
+
rows: number;
|
|
428
|
+
/** Cell size in reference pixels. */
|
|
429
|
+
cell: [number, number];
|
|
430
|
+
/** Frame size in reference pixels. */
|
|
431
|
+
ref: [number, number];
|
|
432
|
+
/** Output pixels per cell on each axis. Whole numbers mean an exact export. */
|
|
433
|
+
pxPerCell: [number, number];
|
|
434
|
+
/** Rotation of the grid about the frame centre, in radians. 0 unless the
|
|
435
|
+
* effect asked for a lattice. */
|
|
436
|
+
angle: number;
|
|
437
|
+
/** How far an unrotated grid extends past the frame, as a multiple of the
|
|
438
|
+
* frame (>= 1 on each axis). Partial cells at the edges make this exceed 1. */
|
|
439
|
+
extent: [number, number];
|
|
440
|
+
};
|
|
441
|
+
/**
|
|
442
|
+
* The grid a cell size produces on a frame. Centred on the frame with a cell
|
|
443
|
+
* boundary at the centre, so cols and rows are always even and a different
|
|
444
|
+
* aspect ratio crops the grid evenly. Depends on the frame's aspect ratio
|
|
445
|
+
* and the cell size only, never on its pixel dimensions.
|
|
446
|
+
*
|
|
447
|
+
* Two flavours:
|
|
448
|
+
*
|
|
449
|
+
* - default: cells are whole reference pixels and axis-aligned, so that
|
|
450
|
+
* 1080p-class and 4K-class exports get whole output pixels per cell.
|
|
451
|
+
* - `lattice`: for effects that draw soft, antialiased shapes (halftone).
|
|
452
|
+
* The grid may be rotated and its pitch need not be whole, since nothing
|
|
453
|
+
* snaps to pixels; it is sized to cover the rotated frame plus a margin of
|
|
454
|
+
* two cells, because a shape can spill into its neighbours' cells.
|
|
455
|
+
*/
|
|
456
|
+
declare function gridFor(width: number, height: number, cell: [number, number], lattice?: {
|
|
457
|
+
angle: number;
|
|
458
|
+
}): Grid;
|
|
459
|
+
//#endregion
|
|
178
460
|
//#region src/palette.d.ts
|
|
179
461
|
/**
|
|
180
462
|
* Builds a 1024-texel RGBA ramp (Uint8Array, length 1024*4) by interpolating
|
|
@@ -191,4 +473,4 @@ declare function renderGradientFrame(opts: {
|
|
|
191
473
|
*/
|
|
192
474
|
declare function buildPaletteRamp(colors: string[]): Uint8Array;
|
|
193
475
|
//#endregion
|
|
194
|
-
export { type MountHandle, type MountOptions, type ParamDef, type RenderFrameResult, type Renderer, type RendererOptions, type ShaderDef, beam, bloom, buildPaletteRamp, createRenderer, flow, getShader, mountGradient, renderGradientFrame, shaders };
|
|
476
|
+
export { type BoolParamDef, type ColorParamDef, type EffectDef, type EffectLayer, type EffectParamDef, type EffectTexture, type EnumParamDef, type FloatParamDef, type GeneratorDef, type Grid, type GridInfo, type MountHandle, type MountOptions, type ParamDef, type ParamValue, type RenderFrameResult, type Renderer, type RendererOptions, type ShaderDef, type Source, type StackHandle, type StackMountOptions, type StackOptions, type StackRenderer, type TextureData, type TextureEnv, ascii, beam, bloom, buildPaletteRamp, createRenderer, createStackRenderer, dither, dune, effects, flow, getEffect, getShader, gridFor, halftone, halo, mountGradient, mountStack, pixelate, renderGradientFrame, renderStackFrame, shaders, strata, whorl };
|