@ewanc26/noise 0.1.0 → 0.1.2

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 CHANGED
@@ -1,124 +1,13 @@
1
1
  # @ewanc26/noise
2
2
 
3
- Generic deterministic value-noise generation from a string seed. Arbitrary dimensions, multi-octave FBM, multiple colour modes. Zero runtime dependencies, works in any environment with a `Uint8ClampedArray` (browsers, Node.js, workers).
4
-
5
- Part of the [`@ewanc26/pkgs`](https://github.com/ewanc26/pkgs) monorepo.
6
-
7
- ## Install
3
+ Deterministic value-noise generation from a string seed arbitrary dimensions, multi-octave FBM, multiple colour modes. Zero dependencies.
8
4
 
9
5
  ```bash
10
6
  pnpm add @ewanc26/noise
11
7
  ```
12
8
 
13
- ## Usage
14
-
15
- ### Raw pixels (no DOM required)
16
-
17
- ```ts
18
- import { generateNoisePixels } from '@ewanc26/noise';
19
-
20
- const pixels = generateNoisePixels(256, 256, 'my-seed', {
21
- octaves: 4,
22
- colorMode: { type: 'grayscale' },
23
- });
24
- // pixels is a Uint8ClampedArray of RGBA values
25
- ```
26
-
27
- ### Canvas
28
-
29
- ```ts
30
- import { renderNoise } from '@ewanc26/noise';
31
-
32
- const canvas = document.querySelector('canvas');
33
- renderNoise(canvas, 'my-seed', { size: 128, octaves: 3 });
34
- ```
35
-
36
- ### Svelte action
37
-
38
- ```svelte
39
- <script>
40
- import { noiseAction } from '@ewanc26/noise';
41
-
42
- let seed = 'my-seed';
43
- </script>
44
-
45
- <canvas use:noiseAction={{ seed, size: 128, octaves: 3 }}></canvas>
46
- ```
47
-
48
- ## API
49
-
50
- ### `generateNoisePixels(width, height, seed, options?)`
51
-
52
- Generates raw RGBA pixel data — no canvas or DOM needed.
53
-
54
- Returns a `Uint8ClampedArray` of length `width * height * 4`.
55
-
56
- ### `renderNoise(canvas, seed, options?)`
57
-
58
- Renders noise onto an existing `HTMLCanvasElement` (resizes it to `width`/`height`/`size`).
59
-
60
- ### `noiseAction(canvas, params)`
61
-
62
- Svelte action wrapper around `renderNoise`. Re-renders reactively when `params` changes via `update`.
63
-
64
- Params object: `{ seed, ...NoiseOptions, width?, height?, size? }`
65
-
66
- ---
67
-
68
- ### Noise options
69
-
70
- | Option | Type | Default | Description |
71
- |---|---|---|---|
72
- | `gridSize` | `number` | `5` | Noise grid resolution |
73
- | `octaves` | `number` | `1` | FBM octave count (1 = plain value noise) |
74
- | `persistence` | `number` | `0.5` | FBM amplitude falloff per octave |
75
- | `lacunarity` | `number` | `2` | FBM frequency multiplier per octave |
76
- | `colorMode` | `ColorMode` | `{ type: 'hsl' }` | How noise values map to colours |
77
-
78
- ### Render options (canvas/action only)
79
-
80
- | Option | Type | Default | Description |
81
- |---|---|---|---|
82
- | `width` | `number` | `64` | Canvas width in pixels |
83
- | `height` | `number` | `64` | Canvas height in pixels |
84
- | `size` | `number` | — | Shorthand to set width and height equally |
85
-
86
- ### Colour modes
87
-
88
- **`{ type: 'hsl' }`** — hue derived from seed, noise shifts hue/saturation/lightness.
89
-
90
- | Option | Type | Default |
91
- |---|---|---|
92
- | `hueRange` | `number` | `60` |
93
- | `saturationRange` | `[number, number]` | `[45, 70]` |
94
- | `lightnessRange` | `[number, number]` | `[40, 70]` |
95
-
96
- **`{ type: 'grayscale' }`** — noise value maps to luminance.
97
-
98
- | Option | Type | Default |
99
- |---|---|---|
100
- | `range` | `[number, number]` | `[0, 255]` |
101
-
102
- **`{ type: 'palette', colors }`** — noise value interpolates through an ordered list of RGB colours.
103
-
104
- ```ts
105
- colorMode: {
106
- type: 'palette',
107
- colors: [[0, 0, 128], [0, 200, 255], [255, 255, 255]],
108
- }
109
- ```
110
-
111
- ---
112
-
113
- ### Core primitives
114
-
115
- | Export | Description |
116
- |---|---|
117
- | `hash32(str)` | djb2 hash → unsigned 32-bit integer |
118
- | `makePrng(seed)` | Seeded LCG PRNG → `() => float in [0, 1)` |
119
- | `hslToRgb(h, s, l)` | HSL (components in `[0, 1]`) → RGB triple (`[0, 255]`) |
120
- | `makeValueNoiseSampler(gridSize, rng)` | Returns `(nx, ny) → float in [0, 1]` value-noise sampler |
9
+ Full documentation at **[docs.ewancroft.uk](https://docs.ewancroft.uk/projects/noise)**.
121
10
 
122
11
  ## Licence
123
12
 
124
- AGPL-3.0-only
13
+ AGPL-3.0-only.
package/dist/index.cjs ADDED
@@ -0,0 +1,172 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ generateNoisePixels: () => generateNoisePixels,
24
+ hash32: () => hash32,
25
+ hslToRgb: () => hslToRgb,
26
+ makePrng: () => makePrng,
27
+ makeValueNoiseSampler: () => makeValueNoiseSampler,
28
+ noiseAction: () => noiseAction,
29
+ renderNoise: () => renderNoise
30
+ });
31
+ module.exports = __toCommonJS(index_exports);
32
+ function hash32(str) {
33
+ let h = 5381;
34
+ for (let i = 0; i < str.length; i++) h = Math.imul(33, h) ^ str.charCodeAt(i);
35
+ return h >>> 0;
36
+ }
37
+ function makePrng(seed) {
38
+ let s = seed >>> 0;
39
+ return () => {
40
+ s = Math.imul(1664525, s) + 1013904223 >>> 0;
41
+ return s / 4294967296;
42
+ };
43
+ }
44
+ function hslToRgb(h, s, l) {
45
+ const a = s * Math.min(l, 1 - l);
46
+ const f = (n) => {
47
+ const k = (n + h * 12) % 12;
48
+ return l - a * Math.max(-1, Math.min(k - 3, 9 - k, 1));
49
+ };
50
+ return [Math.round(f(0) * 255), Math.round(f(8) * 255), Math.round(f(4) * 255)];
51
+ }
52
+ function applyColorMode(noiseValue, mode, baseHue) {
53
+ switch (mode.type) {
54
+ case "hsl": {
55
+ const hueRange = mode.hueRange ?? 60;
56
+ const [sMin, sMax] = mode.saturationRange ?? [45, 70];
57
+ const [lMin, lMax] = mode.lightnessRange ?? [40, 70];
58
+ const hue = (baseHue + noiseValue * hueRange) % 360;
59
+ const sat = sMin + noiseValue * (sMax - sMin);
60
+ const light = lMin + noiseValue * (lMax - lMin);
61
+ return hslToRgb(hue / 360, sat / 100, light / 100);
62
+ }
63
+ case "grayscale": {
64
+ const [lo, hi] = mode.range ?? [0, 255];
65
+ const v = Math.round(lo + noiseValue * (hi - lo));
66
+ return [v, v, v];
67
+ }
68
+ case "palette": {
69
+ const colors = mode.colors;
70
+ if (colors.length === 0) return [0, 0, 0];
71
+ if (colors.length === 1) return colors[0];
72
+ const scaled = noiseValue * (colors.length - 1);
73
+ const lo = Math.floor(scaled);
74
+ const hi = Math.min(lo + 1, colors.length - 1);
75
+ const t = scaled - lo;
76
+ const [r1, g1, b1] = colors[lo];
77
+ const [r2, g2, b2] = colors[hi];
78
+ return [
79
+ Math.round(r1 + t * (r2 - r1)),
80
+ Math.round(g1 + t * (g2 - g1)),
81
+ Math.round(b1 + t * (b2 - b1))
82
+ ];
83
+ }
84
+ }
85
+ }
86
+ function smoothstep(t) {
87
+ return t * t * (3 - 2 * t);
88
+ }
89
+ function makeValueNoiseSampler(gridSize, rng) {
90
+ const G = gridSize + 1;
91
+ const grid = Array.from({ length: G * G }, () => rng());
92
+ const at = (gx, gy) => grid[gy * G + gx];
93
+ return (nx, ny) => {
94
+ const fx = nx * gridSize;
95
+ const fy = ny * gridSize;
96
+ const gx = Math.floor(fx);
97
+ const gy = Math.floor(fy);
98
+ const tx = smoothstep(fx - gx);
99
+ const ty = smoothstep(fy - gy);
100
+ return (1 - ty) * ((1 - tx) * at(gx, gy) + tx * at(gx + 1, gy)) + ty * ((1 - tx) * at(gx, gy + 1) + tx * at(gx + 1, gy + 1));
101
+ };
102
+ }
103
+ function generateNoisePixels(width, height, seed, options = {}) {
104
+ const {
105
+ gridSize = 5,
106
+ octaves = 1,
107
+ persistence = 0.5,
108
+ lacunarity = 2,
109
+ colorMode = { type: "hsl" }
110
+ } = options;
111
+ const seedNum = hash32(seed);
112
+ const baseHue = seedNum % 360;
113
+ const samplers = Array.from({ length: octaves }, (_, i) => {
114
+ const rng = makePrng(hash32(`${seed}|oct${i}`));
115
+ return makeValueNoiseSampler(gridSize * Math.pow(lacunarity, i), rng);
116
+ });
117
+ const pixels = new Uint8ClampedArray(width * height * 4);
118
+ for (let py = 0; py < height; py++) {
119
+ for (let px = 0; px < width; px++) {
120
+ const nx = px / width;
121
+ const ny = py / height;
122
+ let value = 0;
123
+ let amplitude = 1;
124
+ let maxAmplitude = 0;
125
+ for (let o = 0; o < octaves; o++) {
126
+ value += samplers[o](nx, ny) * amplitude;
127
+ maxAmplitude += amplitude;
128
+ amplitude *= persistence;
129
+ }
130
+ value /= maxAmplitude;
131
+ const [r, g, b] = applyColorMode(value, colorMode, baseHue);
132
+ const idx = (py * width + px) * 4;
133
+ pixels[idx] = r;
134
+ pixels[idx + 1] = g;
135
+ pixels[idx + 2] = b;
136
+ pixels[idx + 3] = 255;
137
+ }
138
+ }
139
+ return pixels;
140
+ }
141
+ function renderNoise(canvas, seed, options = {}) {
142
+ const { size, width: wOpt, height: hOpt, ...noiseOpts } = options;
143
+ const width = wOpt ?? size ?? 64;
144
+ const height = hOpt ?? size ?? 64;
145
+ canvas.width = width;
146
+ canvas.height = height;
147
+ const ctx = canvas.getContext("2d");
148
+ if (!ctx) return;
149
+ const pixels = generateNoisePixels(width, height, seed, noiseOpts);
150
+ const imageData = new ImageData(new Uint8ClampedArray(pixels), width, height);
151
+ ctx.putImageData(imageData, 0, 0);
152
+ }
153
+ function noiseAction(canvas, params) {
154
+ const { seed, ...opts } = params;
155
+ renderNoise(canvas, seed, opts);
156
+ return {
157
+ update(newParams) {
158
+ const { seed: newSeed, ...newOpts } = newParams;
159
+ renderNoise(canvas, newSeed, newOpts);
160
+ }
161
+ };
162
+ }
163
+ // Annotate the CommonJS export names for ESM import in node:
164
+ 0 && (module.exports = {
165
+ generateNoisePixels,
166
+ hash32,
167
+ hslToRgb,
168
+ makePrng,
169
+ makeValueNoiseSampler,
170
+ noiseAction,
171
+ renderNoise
172
+ });
@@ -0,0 +1,147 @@
1
+ /**
2
+ * @ewanc26/noise
3
+ *
4
+ * Generic deterministic value-noise generation.
5
+ *
6
+ * Produces consistent noise from an arbitrary string seed — same seed always
7
+ * gives the same output. Supports arbitrary dimensions, multi-octave FBM, and
8
+ * several colour modes. Zero runtime dependencies; works anywhere with a
9
+ * Uint8ClampedArray (Node.js, browsers, workers).
10
+ *
11
+ * Canvas and Svelte action helpers are also exported for convenience.
12
+ */
13
+ /**
14
+ * djb2 hash — returns an unsigned 32-bit integer for any string.
15
+ */
16
+ declare function hash32(str: string): number;
17
+ /**
18
+ * Seeded LCG pseudo-random number generator.
19
+ * Returns a function that produces floats in [0, 1).
20
+ */
21
+ declare function makePrng(seed: number): () => number;
22
+ /**
23
+ * Convert HSL (each component in [0, 1]) to an RGB triple ([0, 255] each).
24
+ */
25
+ declare function hslToRgb(h: number, s: number, l: number): [number, number, number];
26
+ /**
27
+ * HSL colour mode — hue derived from seed, noise value shifts hue/sat/light.
28
+ */
29
+ interface HslColorMode {
30
+ type: 'hsl';
31
+ /** Hue spread in degrees around the seed-derived base hue. @default 60 */
32
+ hueRange?: number;
33
+ /** Saturation [min, max] as percentages. @default [45, 70] */
34
+ saturationRange?: [number, number];
35
+ /** Lightness [min, max] as percentages. @default [40, 70] */
36
+ lightnessRange?: [number, number];
37
+ }
38
+ /**
39
+ * Grayscale colour mode — noise value maps to a luminance range.
40
+ */
41
+ interface GrayscaleColorMode {
42
+ type: 'grayscale';
43
+ /** Luminance [min, max] in [0, 255]. @default [0, 255] */
44
+ range?: [number, number];
45
+ }
46
+ /**
47
+ * Palette colour mode — noise value indexes into a list of RGB colours
48
+ * using smooth interpolation between adjacent entries.
49
+ */
50
+ interface PaletteColorMode {
51
+ type: 'palette';
52
+ /** At least two RGB triples, e.g. [[255,0,128],[0,200,255]]. */
53
+ colors: [number, number, number][];
54
+ }
55
+ type ColorMode = HslColorMode | GrayscaleColorMode | PaletteColorMode;
56
+ /**
57
+ * Build a value-noise grid and return a sampler for normalised coordinates.
58
+ *
59
+ * @param gridSize Number of grid cells along each axis.
60
+ * @param rng Seeded PRNG from `makePrng`.
61
+ * @returns A function `(nx, ny) → float in [0, 1]` where nx, ny ∈ [0, 1].
62
+ */
63
+ declare function makeValueNoiseSampler(gridSize: number, rng: () => number): (nx: number, ny: number) => number;
64
+ interface NoiseOptions {
65
+ /**
66
+ * Side length of the noise grid (higher = finer detail).
67
+ * @default 5
68
+ */
69
+ gridSize?: number;
70
+ /**
71
+ * Number of FBM octaves. 1 = plain value noise. More octaves add
72
+ * finer detail at the cost of a little extra work.
73
+ * @default 1
74
+ */
75
+ octaves?: number;
76
+ /**
77
+ * FBM persistence — how much each successive octave contributes.
78
+ * @default 0.5
79
+ */
80
+ persistence?: number;
81
+ /**
82
+ * FBM lacunarity — how much each successive octave's frequency increases.
83
+ * @default 2
84
+ */
85
+ lacunarity?: number;
86
+ /**
87
+ * How noise values map to colours.
88
+ * @default { type: 'hsl' }
89
+ */
90
+ colorMode?: ColorMode;
91
+ }
92
+ /**
93
+ * Generate raw RGBA pixel data for a noise texture.
94
+ *
95
+ * Works in any environment that has `Uint8ClampedArray` (all modern runtimes).
96
+ * No canvas or DOM required.
97
+ *
98
+ * @param width Output width in pixels.
99
+ * @param height Output height in pixels.
100
+ * @param seed Arbitrary string — same seed always produces the same image.
101
+ * @param options Noise and colour options.
102
+ * @returns A `Uint8ClampedArray` of length `width * height * 4` (RGBA).
103
+ */
104
+ declare function generateNoisePixels(width: number, height: number, seed: string, options?: NoiseOptions): Uint8ClampedArray;
105
+ interface RenderNoiseOptions extends NoiseOptions {
106
+ /**
107
+ * Rendered canvas width in pixels. Defaults to `size` if set, else 64.
108
+ */
109
+ width?: number;
110
+ /**
111
+ * Rendered canvas height in pixels. Defaults to `size` if set, else 64.
112
+ */
113
+ height?: number;
114
+ /**
115
+ * Shorthand to set both width and height to the same value.
116
+ */
117
+ size?: number;
118
+ }
119
+ /**
120
+ * Render a deterministic noise texture onto an existing `HTMLCanvasElement`.
121
+ *
122
+ * @param canvas Target canvas (will be resized).
123
+ * @param seed Arbitrary string — same seed always produces the same image.
124
+ * @param options Render and noise options.
125
+ */
126
+ declare function renderNoise(canvas: HTMLCanvasElement, seed: string, options?: RenderNoiseOptions): void;
127
+ interface NoiseActionParams extends RenderNoiseOptions {
128
+ seed: string;
129
+ }
130
+ /**
131
+ * Svelte action that renders noise onto a canvas and re-renders reactively
132
+ * when params change.
133
+ *
134
+ * @example
135
+ * ```svelte
136
+ * <script>
137
+ * import { noiseAction } from '@ewanc26/noise';
138
+ * </script>
139
+ *
140
+ * <canvas use:noiseAction={{ seed: 'my-seed', size: 128, octaves: 3 }}></canvas>
141
+ * ```
142
+ */
143
+ declare function noiseAction(canvas: HTMLCanvasElement, params: NoiseActionParams): {
144
+ update(newParams: NoiseActionParams): void;
145
+ };
146
+
147
+ export { type ColorMode, type GrayscaleColorMode, type HslColorMode, type NoiseActionParams, type NoiseOptions, type PaletteColorMode, type RenderNoiseOptions, generateNoisePixels, hash32, hslToRgb, makePrng, makeValueNoiseSampler, noiseAction, renderNoise };
@@ -0,0 +1,147 @@
1
+ /**
2
+ * @ewanc26/noise
3
+ *
4
+ * Generic deterministic value-noise generation.
5
+ *
6
+ * Produces consistent noise from an arbitrary string seed — same seed always
7
+ * gives the same output. Supports arbitrary dimensions, multi-octave FBM, and
8
+ * several colour modes. Zero runtime dependencies; works anywhere with a
9
+ * Uint8ClampedArray (Node.js, browsers, workers).
10
+ *
11
+ * Canvas and Svelte action helpers are also exported for convenience.
12
+ */
13
+ /**
14
+ * djb2 hash — returns an unsigned 32-bit integer for any string.
15
+ */
16
+ declare function hash32(str: string): number;
17
+ /**
18
+ * Seeded LCG pseudo-random number generator.
19
+ * Returns a function that produces floats in [0, 1).
20
+ */
21
+ declare function makePrng(seed: number): () => number;
22
+ /**
23
+ * Convert HSL (each component in [0, 1]) to an RGB triple ([0, 255] each).
24
+ */
25
+ declare function hslToRgb(h: number, s: number, l: number): [number, number, number];
26
+ /**
27
+ * HSL colour mode — hue derived from seed, noise value shifts hue/sat/light.
28
+ */
29
+ interface HslColorMode {
30
+ type: 'hsl';
31
+ /** Hue spread in degrees around the seed-derived base hue. @default 60 */
32
+ hueRange?: number;
33
+ /** Saturation [min, max] as percentages. @default [45, 70] */
34
+ saturationRange?: [number, number];
35
+ /** Lightness [min, max] as percentages. @default [40, 70] */
36
+ lightnessRange?: [number, number];
37
+ }
38
+ /**
39
+ * Grayscale colour mode — noise value maps to a luminance range.
40
+ */
41
+ interface GrayscaleColorMode {
42
+ type: 'grayscale';
43
+ /** Luminance [min, max] in [0, 255]. @default [0, 255] */
44
+ range?: [number, number];
45
+ }
46
+ /**
47
+ * Palette colour mode — noise value indexes into a list of RGB colours
48
+ * using smooth interpolation between adjacent entries.
49
+ */
50
+ interface PaletteColorMode {
51
+ type: 'palette';
52
+ /** At least two RGB triples, e.g. [[255,0,128],[0,200,255]]. */
53
+ colors: [number, number, number][];
54
+ }
55
+ type ColorMode = HslColorMode | GrayscaleColorMode | PaletteColorMode;
56
+ /**
57
+ * Build a value-noise grid and return a sampler for normalised coordinates.
58
+ *
59
+ * @param gridSize Number of grid cells along each axis.
60
+ * @param rng Seeded PRNG from `makePrng`.
61
+ * @returns A function `(nx, ny) → float in [0, 1]` where nx, ny ∈ [0, 1].
62
+ */
63
+ declare function makeValueNoiseSampler(gridSize: number, rng: () => number): (nx: number, ny: number) => number;
64
+ interface NoiseOptions {
65
+ /**
66
+ * Side length of the noise grid (higher = finer detail).
67
+ * @default 5
68
+ */
69
+ gridSize?: number;
70
+ /**
71
+ * Number of FBM octaves. 1 = plain value noise. More octaves add
72
+ * finer detail at the cost of a little extra work.
73
+ * @default 1
74
+ */
75
+ octaves?: number;
76
+ /**
77
+ * FBM persistence — how much each successive octave contributes.
78
+ * @default 0.5
79
+ */
80
+ persistence?: number;
81
+ /**
82
+ * FBM lacunarity — how much each successive octave's frequency increases.
83
+ * @default 2
84
+ */
85
+ lacunarity?: number;
86
+ /**
87
+ * How noise values map to colours.
88
+ * @default { type: 'hsl' }
89
+ */
90
+ colorMode?: ColorMode;
91
+ }
92
+ /**
93
+ * Generate raw RGBA pixel data for a noise texture.
94
+ *
95
+ * Works in any environment that has `Uint8ClampedArray` (all modern runtimes).
96
+ * No canvas or DOM required.
97
+ *
98
+ * @param width Output width in pixels.
99
+ * @param height Output height in pixels.
100
+ * @param seed Arbitrary string — same seed always produces the same image.
101
+ * @param options Noise and colour options.
102
+ * @returns A `Uint8ClampedArray` of length `width * height * 4` (RGBA).
103
+ */
104
+ declare function generateNoisePixels(width: number, height: number, seed: string, options?: NoiseOptions): Uint8ClampedArray;
105
+ interface RenderNoiseOptions extends NoiseOptions {
106
+ /**
107
+ * Rendered canvas width in pixels. Defaults to `size` if set, else 64.
108
+ */
109
+ width?: number;
110
+ /**
111
+ * Rendered canvas height in pixels. Defaults to `size` if set, else 64.
112
+ */
113
+ height?: number;
114
+ /**
115
+ * Shorthand to set both width and height to the same value.
116
+ */
117
+ size?: number;
118
+ }
119
+ /**
120
+ * Render a deterministic noise texture onto an existing `HTMLCanvasElement`.
121
+ *
122
+ * @param canvas Target canvas (will be resized).
123
+ * @param seed Arbitrary string — same seed always produces the same image.
124
+ * @param options Render and noise options.
125
+ */
126
+ declare function renderNoise(canvas: HTMLCanvasElement, seed: string, options?: RenderNoiseOptions): void;
127
+ interface NoiseActionParams extends RenderNoiseOptions {
128
+ seed: string;
129
+ }
130
+ /**
131
+ * Svelte action that renders noise onto a canvas and re-renders reactively
132
+ * when params change.
133
+ *
134
+ * @example
135
+ * ```svelte
136
+ * <script>
137
+ * import { noiseAction } from '@ewanc26/noise';
138
+ * </script>
139
+ *
140
+ * <canvas use:noiseAction={{ seed: 'my-seed', size: 128, octaves: 3 }}></canvas>
141
+ * ```
142
+ */
143
+ declare function noiseAction(canvas: HTMLCanvasElement, params: NoiseActionParams): {
144
+ update(newParams: NoiseActionParams): void;
145
+ };
146
+
147
+ export { type ColorMode, type GrayscaleColorMode, type HslColorMode, type NoiseActionParams, type NoiseOptions, type PaletteColorMode, type RenderNoiseOptions, generateNoisePixels, hash32, hslToRgb, makePrng, makeValueNoiseSampler, noiseAction, renderNoise };