@instantshader/react 0.7.0 → 0.8.1

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
@@ -2,11 +2,11 @@
2
2
 
3
3
  # @instantshader/react
4
4
 
5
- React bindings for [instantshader](https://www.npmjs.com/package/instantshader), a
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, and
8
- add dither, pixelate, halftone or ASCII effects over it or over your own image.
9
- Built by [InstantGradient](https://instantgradient.com/app).
5
+ React components for [instantshader](https://www.npmjs.com/package/instantshader),
6
+ animated WebGL gradients with zero dependencies. Put a shader component in any
7
+ sized element, and add dither, pixelate, halftone, ASCII or tint effects over
8
+ it or over your own image. Built by
9
+ [InstantGradient](https://instantgradient.com/app).
10
10
 
11
11
  ## Install
12
12
 
@@ -31,16 +31,16 @@ export function Background() {
31
31
 
32
32
  ## Shaders
33
33
 
34
- One component per shader, each a thin wrapper over the same props:
34
+ One component per shader, all with the same props:
35
35
 
36
36
  | Component | Look | Params |
37
37
  | --- | --- | --- |
38
- | `<Flow>` | Isotropic swirling currents with defined luminous edges and calm negative space. | `scale`, `curl`, `drift`, `openness`, `grain` |
39
- | `<Beam>` | One wide beam of soft light crossing a near-black frame, the palette walking its length. | `scale`, `width`, `glow`, `angle`, `grain` |
40
- | `<Bloom>` | A fan of huge soft petals radiating from the bottom edge, palette as concentric scalloped bands. | `scale`, `petals`, `pinch`, `bend`, `sway`, `colorflow`, `grain` |
41
- | `<Halo>` | An eclipse disc with a bright limb and flowing corona; `x` / `y` place it, and the default is a glowing horizon arc. | `radius`, `x`, `y`, `glow`, `crescent`, `flares`, `grain` |
38
+ | `<Flow>` | Swirling fluid currents with bright edges and calm open space. | `scale`, `curl`, `drift`, `openness`, `grain` |
39
+ | `<Beam>` | One wide beam of soft light across a near-black frame, the palette running along it. | `scale`, `width`, `glow`, `angle`, `grain` |
40
+ | `<Bloom>` | A fan of huge soft petals rising from the bottom edge. | `scale`, `petals`, `pinch`, `bend`, `sway`, `colorflow`, `grain` |
41
+ | `<Halo>` | An eclipse: a dark disc with a bright rim and a corona. `x` / `y` place it; the default is a glowing horizon. | `radius`, `x`, `y`, `glow`, `crescent`, `flares`, `grain` |
42
42
  | `<Strata>` | Stacked cut-paper layers with soft shadows. | `scale`, `layers`, `warp`, `ridges`, `stretch`, `depth`, `blend`, `angle`, `grain` |
43
- | `<Dune>` | Overlapping crests, crisp on top and airbrushed below. | `layers`, `swell`, `waves`, `fade`, `soft`, `angle`, `grain` |
43
+ | `<Dune>` | Overlapping crests, crisp on top and fading out below. | `layers`, `swell`, `waves`, `fade`, `soft`, `angle`, `grain` |
44
44
  | `<Whorl>` | A spiral of curved blades, positionable with `x` / `y`. | `blades`, `twist`, `depth`, `scale`, `wobble`, `x`, `y`, `grain` |
45
45
  | `<Silk>` | Satin folds with a highlight along the threads. | `scale`, `folds`, `depth`, `warp`, `sheen`, `light`, `grain` |
46
46
  | `<Nacre>` | Glassy liquid folds whose colour shifts on every slope. | `scale`, `flow`, `crease`, `depth`, `iridescence`, `light`, `grain` |
@@ -67,14 +67,14 @@ here as `flow`, `beam`, `bloom`, `halo`, `strata`, `dune`, `whorl`, `silk`,
67
67
  ## Effects
68
68
 
69
69
  Every shader component takes an `effects` prop: a list of layers, bottom
70
- first, each an effect def with its params.
70
+ first. Each layer works on everything below it, so effects stack.
71
71
 
72
72
  ```tsx
73
73
  import { Bloom, dither } from "@instantshader/react";
74
74
 
75
75
  <Bloom
76
76
  colors={["#140f30", "#9c2168", "#eb6a4e", "#fcd87c"]}
77
- effects={[{ effect: dither, params: { pattern: "blueNoise", colorMode: "palette", levels: 4 } }]}
77
+ effects={[{ effect: dither, params: { pattern: "blueNoise", colorMode: "palette", levels: 4, blend: "normal", opacity: 1 } }]}
78
78
  style={{ width: "100%", height: "100%" }}
79
79
  />;
80
80
  ```
@@ -84,19 +84,27 @@ put effects over an image. Any `<img>`, `<canvas>` or `<video>` element works
84
84
  as `media`:
85
85
 
86
86
  ```tsx
87
- import { ShaderStack, halftone } from "@instantshader/react";
87
+ import { ShaderStack, halftone, tint } from "@instantshader/react";
88
88
 
89
89
  <ShaderStack
90
90
  source={{ kind: "media", media: img, fit: "cover" }}
91
91
  colors={["#111111", "#f4f1ea"]}
92
- effects={[{ effect: halftone, params: { size: 20, angle: 30 } }]}
92
+ effects={[
93
+ { effect: halftone, params: { shape: "dot", size: 16 } },
94
+ { effect: tint, params: { mode: "palette", amount: 0.6 } },
95
+ ]}
93
96
  style={{ width: "100%", height: "100%" }}
94
97
  />;
95
98
  ```
96
99
 
100
+ Halftone and ASCII draw shapes or characters over the picture; set `ground:
101
+ "paper"` to draw them on a flat colour instead. `blend` and `opacity` set how
102
+ any effect mixes with what is below it. A layer with `enabled: false` is
103
+ skipped.
104
+
97
105
  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,
106
+ `source`, `seed`, `background` or `fontFamily` remounts it. The five effect
107
+ defs (`pixelate`, `dither`, `halftone`, `ascii`, `tint`) are re-exported from here,
100
108
  and the [repository README](https://github.com/ugolbck/instantshader#effects)
101
109
  lists every param with its range.
102
110
 
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, burst, dither, dune, flow, glint, halftone, halo, nacre, pixelate, silk, 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, tint, whorl } from "instantshader";
3
3
 
4
4
  //#region src/ShaderStack.d.ts
5
5
  interface ShaderStackProps {
@@ -89,4 +89,4 @@ declare function Nacre(props: Omit<ShaderCanvasProps, "shader">): ReactElement;
89
89
  declare function Burst(props: Omit<ShaderCanvasProps, "shader">): ReactElement;
90
90
  declare function Glint(props: Omit<ShaderCanvasProps, "shader">): ReactElement;
91
91
  //#endregion
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 };
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, tint, 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, 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";
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, tint, whorl, whorl as whorl$1 } from "instantshader";
4
4
  import { jsx } from "react/jsx-runtime";
5
5
 
6
6
  //#region src/ShaderStack.tsx
@@ -165,4 +165,4 @@ function Glint(props) {
165
165
  }
166
166
 
167
167
  //#endregion
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 };
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, tint, whorl };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instantshader/react",
3
- "version": "0.7.0",
3
+ "version": "0.8.1",
4
4
  "description": "React components for InstantShader: animated WebGL gradients and image effects.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -36,7 +36,7 @@
36
36
  "react"
37
37
  ],
38
38
  "dependencies": {
39
- "instantshader": "0.7.0"
39
+ "instantshader": "0.8.1"
40
40
  },
41
41
  "peerDependencies": {
42
42
  "react": "^18 || ^19",