@instantshader/react 0.6.0 → 0.7.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 -5
- package/dist/index.d.ts +6 -2
- package/dist/index.js +26 -2
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -4,8 +4,9 @@
|
|
|
4
4
|
|
|
5
5
|
React bindings for [instantshader](https://www.npmjs.com/package/instantshader), a
|
|
6
6
|
zero-dependency animated WebGL gradient engine. Drop a `<Flow>`, `<Beam>`, `<Bloom>`, `<Halo>`, `<Strata>`, `<Dune>` or
|
|
7
|
-
`<Whorl>` component into any sized wrapper to mount a live, animated gradient
|
|
8
|
-
|
|
7
|
+
`<Whorl>` component into any sized wrapper to mount a live, animated gradient, and
|
|
8
|
+
add dither, pixelate, halftone or ASCII effects over it or over your own image.
|
|
9
|
+
Built by [InstantGradient](https://instantgradient.com/app).
|
|
9
10
|
|
|
10
11
|
## Install
|
|
11
12
|
|
|
@@ -41,6 +42,10 @@ One component per shader, each a thin wrapper over the same props:
|
|
|
41
42
|
| `<Strata>` | Stacked cut-paper layers with soft shadows. | `scale`, `layers`, `warp`, `ridges`, `stretch`, `depth`, `blend`, `angle`, `grain` |
|
|
42
43
|
| `<Dune>` | Overlapping crests, crisp on top and airbrushed below. | `layers`, `swell`, `waves`, `fade`, `soft`, `angle`, `grain` |
|
|
43
44
|
| `<Whorl>` | A spiral of curved blades, positionable with `x` / `y`. | `blades`, `twist`, `depth`, `scale`, `wobble`, `x`, `y`, `grain` |
|
|
45
|
+
| `<Silk>` | Satin folds with a highlight along the threads. | `scale`, `folds`, `depth`, `warp`, `sheen`, `light`, `grain` |
|
|
46
|
+
| `<Nacre>` | Glassy liquid folds whose colour shifts on every slope. | `scale`, `flow`, `crease`, `depth`, `iridescence`, `light`, `grain` |
|
|
47
|
+
| `<Burst>` | Thin rays out of one point, tunnel or star, straight or twisted. | `rays`, `sharp`, `glow`, `twist`, `x`, `y`, `grain` |
|
|
48
|
+
| `<Glint>` | A shoal of spinning shards streaming along a current. | `size`, `density`, `bend`, `angle`, `speed`, `grain` |
|
|
44
49
|
|
|
45
50
|
```tsx
|
|
46
51
|
import { Bloom } from "@instantshader/react";
|
|
@@ -56,7 +61,44 @@ import { Bloom } from "@instantshader/react";
|
|
|
56
61
|
|
|
57
62
|
See the [`instantshader` README](https://www.npmjs.com/package/instantshader)
|
|
58
63
|
for what each param does and for the shader defs themselves (re-exported from
|
|
59
|
-
here as `flow`, `beam`
|
|
64
|
+
here as `flow`, `beam`, `bloom`, `halo`, `strata`, `dune`, `whorl`, `silk`,
|
|
65
|
+
`nacre`, `burst` and `glint`).
|
|
66
|
+
|
|
67
|
+
## Effects
|
|
68
|
+
|
|
69
|
+
Every shader component takes an `effects` prop: a list of layers, bottom
|
|
70
|
+
first, each an effect def with its params.
|
|
71
|
+
|
|
72
|
+
```tsx
|
|
73
|
+
import { Bloom, dither } from "@instantshader/react";
|
|
74
|
+
|
|
75
|
+
<Bloom
|
|
76
|
+
colors={["#140f30", "#9c2168", "#eb6a4e", "#fcd87c"]}
|
|
77
|
+
effects={[{ effect: dither, params: { pattern: "blueNoise", colorMode: "palette", levels: 4 } }]}
|
|
78
|
+
style={{ width: "100%", height: "100%" }}
|
|
79
|
+
/>;
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
`<ShaderStack>` takes a `source` instead of a fixed shader, which is how you
|
|
83
|
+
put effects over an image. Any `<img>`, `<canvas>` or `<video>` element works
|
|
84
|
+
as `media`:
|
|
85
|
+
|
|
86
|
+
```tsx
|
|
87
|
+
import { ShaderStack, halftone } from "@instantshader/react";
|
|
88
|
+
|
|
89
|
+
<ShaderStack
|
|
90
|
+
source={{ kind: "media", media: img, fit: "cover" }}
|
|
91
|
+
colors={["#111111", "#f4f1ea"]}
|
|
92
|
+
effects={[{ effect: halftone, params: { size: 20, angle: 30 } }]}
|
|
93
|
+
style={{ width: "100%", height: "100%" }}
|
|
94
|
+
/>;
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Changing `effects` or their params updates the canvas in place. A new
|
|
98
|
+
`source`, `seed`, `background` or `fontFamily` remounts it. The four effect
|
|
99
|
+
defs (`pixelate`, `dither`, `halftone`, `ascii`) are re-exported from here,
|
|
100
|
+
and the [repository README](https://github.com/ugolbck/instantshader#effects)
|
|
101
|
+
lists every param with its range.
|
|
60
102
|
|
|
61
103
|
## Seamless loops
|
|
62
104
|
|
|
@@ -67,7 +109,7 @@ at the wrap:
|
|
|
67
109
|
<Flow colors={colors} loopSeconds={30} style={{ width: "100%", height: "100%" }} />
|
|
68
110
|
```
|
|
69
111
|
|
|
70
|
-
15
|
|
71
|
-
seconds
|
|
112
|
+
15 to 60s is the comfortable range, and the period is measured in animation
|
|
113
|
+
seconds, so it interacts with `speed`. See the
|
|
72
114
|
[`instantshader` README](https://www.npmjs.com/package/instantshader) for the
|
|
73
115
|
full details.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CSSProperties, ReactElement } from "react";
|
|
2
|
-
import { EffectDef, EffectLayer, EffectLayer as EffectLayer$1, EffectParamDef, ParamDef, ParamValue, ShaderDef, ShaderDef as ShaderDef$1, Source, Source as Source$1, ascii, beam, bloom, dither, dune, flow, halftone, halo, pixelate, strata, whorl } from "instantshader";
|
|
2
|
+
import { EffectDef, EffectLayer, EffectLayer as EffectLayer$1, EffectParamDef, ParamDef, ParamValue, ShaderDef, ShaderDef as ShaderDef$1, Source, Source as Source$1, ascii, beam, bloom, burst, dither, dune, flow, glint, halftone, halo, nacre, pixelate, silk, strata, whorl } from "instantshader";
|
|
3
3
|
|
|
4
4
|
//#region src/ShaderStack.d.ts
|
|
5
5
|
interface ShaderStackProps {
|
|
@@ -84,5 +84,9 @@ declare function Halo(props: Omit<ShaderCanvasProps, "shader">): ReactElement;
|
|
|
84
84
|
declare function Strata(props: Omit<ShaderCanvasProps, "shader">): ReactElement;
|
|
85
85
|
declare function Dune(props: Omit<ShaderCanvasProps, "shader">): ReactElement;
|
|
86
86
|
declare function Whorl(props: Omit<ShaderCanvasProps, "shader">): ReactElement;
|
|
87
|
+
declare function Silk(props: Omit<ShaderCanvasProps, "shader">): ReactElement;
|
|
88
|
+
declare function Nacre(props: Omit<ShaderCanvasProps, "shader">): ReactElement;
|
|
89
|
+
declare function Burst(props: Omit<ShaderCanvasProps, "shader">): ReactElement;
|
|
90
|
+
declare function Glint(props: Omit<ShaderCanvasProps, "shader">): ReactElement;
|
|
87
91
|
//#endregion
|
|
88
|
-
export { Beam, Bloom, Dune, type EffectDef, type EffectLayer, type EffectParamDef, Flow, Halo, type ParamDef, type ParamValue, ShaderCanvas, type ShaderCanvasProps, type ShaderDef, ShaderStack, type ShaderStackProps, type Source, Strata, Whorl, ascii, beam, bloom, dither, dune, flow, halftone, halo, pixelate, strata, whorl };
|
|
92
|
+
export { Beam, Bloom, Burst, Dune, type EffectDef, type EffectLayer, type EffectParamDef, Flow, Glint, Halo, Nacre, type ParamDef, type ParamValue, ShaderCanvas, type ShaderCanvasProps, type ShaderDef, ShaderStack, type ShaderStackProps, Silk, type Source, Strata, Whorl, ascii, beam, bloom, burst, dither, dune, flow, glint, halftone, halo, nacre, pixelate, silk, strata, whorl };
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { useEffect, useMemo, useRef } from "react";
|
|
3
|
-
import { ascii, beam, beam as beam$1, bloom, bloom as bloom$1, dither, dune, dune as dune$1, flow, flow as flow$1, halftone, halo, halo as halo$1, mountStack, pixelate, strata, strata as strata$1, whorl, whorl as whorl$1 } from "instantshader";
|
|
3
|
+
import { ascii, beam, beam as beam$1, bloom, bloom as bloom$1, burst, burst as burst$1, dither, dune, dune as dune$1, flow, flow as flow$1, glint, glint as glint$1, halftone, halo, halo as halo$1, mountStack, nacre, nacre as nacre$1, pixelate, silk, silk as silk$1, strata, strata as strata$1, whorl, whorl as whorl$1 } from "instantshader";
|
|
4
4
|
import { jsx } from "react/jsx-runtime";
|
|
5
5
|
|
|
6
6
|
//#region src/ShaderStack.tsx
|
|
@@ -139,6 +139,30 @@ function Whorl(props) {
|
|
|
139
139
|
...props
|
|
140
140
|
});
|
|
141
141
|
}
|
|
142
|
+
function Silk(props) {
|
|
143
|
+
return /* @__PURE__ */ jsx(ShaderCanvas, {
|
|
144
|
+
shader: silk$1,
|
|
145
|
+
...props
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
function Nacre(props) {
|
|
149
|
+
return /* @__PURE__ */ jsx(ShaderCanvas, {
|
|
150
|
+
shader: nacre$1,
|
|
151
|
+
...props
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
function Burst(props) {
|
|
155
|
+
return /* @__PURE__ */ jsx(ShaderCanvas, {
|
|
156
|
+
shader: burst$1,
|
|
157
|
+
...props
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
function Glint(props) {
|
|
161
|
+
return /* @__PURE__ */ jsx(ShaderCanvas, {
|
|
162
|
+
shader: glint$1,
|
|
163
|
+
...props
|
|
164
|
+
});
|
|
165
|
+
}
|
|
142
166
|
|
|
143
167
|
//#endregion
|
|
144
|
-
export { Beam, Bloom, Dune, Flow, Halo, ShaderCanvas, ShaderStack, Strata, Whorl, ascii, beam, bloom, dither, dune, flow, halftone, halo, pixelate, strata, whorl };
|
|
168
|
+
export { Beam, Bloom, Burst, Dune, Flow, Glint, Halo, Nacre, ShaderCanvas, ShaderStack, Silk, Strata, Whorl, ascii, beam, bloom, burst, dither, dune, flow, glint, halftone, halo, nacre, pixelate, silk, strata, whorl };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instantshader/react",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "React
|
|
3
|
+
"version": "0.7.0",
|
|
4
|
+
"description": "React components for InstantShader: animated WebGL gradients and image effects.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"react"
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"instantshader": "0.
|
|
39
|
+
"instantshader": "0.7.0"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
42
|
"react": "^18 || ^19",
|