@paper-design/shaders-react 0.0.29 → 0.0.31

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.
Files changed (67) hide show
  1. package/dist/color-props-are-equal.d.ts +6 -0
  2. package/dist/color-props-are-equal.js +34 -0
  3. package/dist/color-props-are-equal.js.map +7 -0
  4. package/dist/index.d.ts +46 -41
  5. package/dist/index.js +61 -1872
  6. package/dist/index.js.map +4 -4
  7. package/dist/shader-mount.d.ts +15 -13
  8. package/dist/shader-mount.js +120 -0
  9. package/dist/shader-mount.js.map +7 -0
  10. package/dist/shaders/dithering.d.ts +15 -0
  11. package/dist/shaders/dithering.js +179 -0
  12. package/dist/shaders/dithering.js.map +7 -0
  13. package/dist/shaders/dot-grid.d.ts +6 -20
  14. package/dist/shaders/dot-grid.js +230 -0
  15. package/dist/shaders/dot-grid.js.map +7 -0
  16. package/dist/shaders/dot-orbit.d.ts +6 -18
  17. package/dist/shaders/dot-orbit.js +77 -0
  18. package/dist/shaders/dot-orbit.js.map +7 -0
  19. package/dist/shaders/god-rays.d.ts +6 -22
  20. package/dist/shaders/god-rays.js +160 -0
  21. package/dist/shaders/god-rays.js.map +7 -0
  22. package/dist/shaders/grain-gradient.d.ts +16 -0
  23. package/dist/shaders/grain-gradient.js +197 -0
  24. package/dist/shaders/grain-gradient.js.map +7 -0
  25. package/dist/shaders/liquid-metal.d.ts +9 -0
  26. package/dist/shaders/liquid-metal.js +87 -0
  27. package/dist/shaders/liquid-metal.js.map +7 -0
  28. package/dist/shaders/mesh-gradient.d.ts +7 -15
  29. package/dist/shaders/mesh-gradient.js +104 -0
  30. package/dist/shaders/mesh-gradient.js.map +7 -0
  31. package/dist/shaders/metaballs.d.ts +6 -16
  32. package/dist/shaders/metaballs.js +72 -0
  33. package/dist/shaders/metaballs.js.map +7 -0
  34. package/dist/shaders/neuro-noise.d.ts +6 -14
  35. package/dist/shaders/neuro-noise.js +82 -0
  36. package/dist/shaders/neuro-noise.js.map +7 -0
  37. package/dist/shaders/perlin-noise.d.ts +6 -17
  38. package/dist/shaders/perlin-noise.js +183 -0
  39. package/dist/shaders/perlin-noise.js.map +7 -0
  40. package/dist/shaders/pulsing-border.d.ts +11 -0
  41. package/dist/shaders/pulsing-border.js +153 -0
  42. package/dist/shaders/pulsing-border.js.map +7 -0
  43. package/dist/shaders/simplex-noise.d.ts +9 -0
  44. package/dist/shaders/simplex-noise.js +80 -0
  45. package/dist/shaders/simplex-noise.js.map +7 -0
  46. package/dist/shaders/smoke-ring.d.ts +8 -18
  47. package/dist/shaders/smoke-ring.js +134 -0
  48. package/dist/shaders/smoke-ring.js.map +7 -0
  49. package/dist/shaders/spiral.d.ts +6 -23
  50. package/dist/shaders/spiral.js +218 -0
  51. package/dist/shaders/spiral.js.map +7 -0
  52. package/dist/shaders/swirl.d.ts +12 -0
  53. package/dist/shaders/swirl.js +137 -0
  54. package/dist/shaders/swirl.js.map +7 -0
  55. package/dist/shaders/voronoi.d.ts +7 -28
  56. package/dist/shaders/voronoi.js +102 -0
  57. package/dist/shaders/voronoi.js.map +7 -0
  58. package/dist/shaders/warp.d.ts +6 -23
  59. package/dist/shaders/warp.js +290 -0
  60. package/dist/shaders/warp.js.map +7 -0
  61. package/dist/shaders/waves.d.ts +6 -19
  62. package/dist/shaders/waves.js +178 -0
  63. package/dist/shaders/waves.js.map +7 -0
  64. package/dist/use-merge-refs.js +48 -0
  65. package/dist/use-merge-refs.js.map +7 -0
  66. package/package.json +13 -4
  67. package/dist/shaders/stepped-simplex-noise.d.ts +0 -20
@@ -0,0 +1,102 @@
1
+ /* * * * * * * * * * * * * * * * * * * * * * * * * * * *
2
+ * Paper Shaders *
3
+ * https://github.com/paper-design/shaders *
4
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * */
5
+
6
+ import { memo } from "react";
7
+ import { ShaderMount } from "../shader-mount";
8
+ import { colorPropsAreEqual } from "../color-props-are-equal";
9
+ import {
10
+ defaultPatternSizing,
11
+ getShaderColorFromString,
12
+ getShaderNoiseTexture,
13
+ voronoiFragmentShader,
14
+ ShaderFitOptions
15
+ } from "@paper-design/shaders";
16
+ import { jsx } from "react/jsx-runtime";
17
+ const defaultPreset = {
18
+ name: "Default",
19
+ params: {
20
+ ...defaultPatternSizing,
21
+ speed: 0.5,
22
+ frame: 0,
23
+ colors: ["hsla(15, 80%, 50%, 1)", "hsla(50, 80%, 50%, 1)", "hsla(200, 80%, 50%, 1)"],
24
+ stepsPerColor: 1,
25
+ colorGlow: "hsla(266, 100%, 50%, 1)",
26
+ colorBack: "hsla(0, 0%, 100%, 1)",
27
+ distortion: 0.42,
28
+ gap: 0.06,
29
+ innerGlow: 0
30
+ }
31
+ };
32
+ const shadowPreset = {
33
+ name: "Shadow",
34
+ params: {
35
+ ...defaultPatternSizing,
36
+ speed: 0.5,
37
+ frame: 0,
38
+ colors: ["hsla(259, 29%, 98%, 1)", "hsla(48, 73%, 98%, 1)", "hsla(295, 32%, 98%, 1)"],
39
+ stepsPerColor: 1,
40
+ colorGlow: "hsla(290, 18%, 42%, 1)",
41
+ colorBack: "hsla(0, 0%, 100%, 1)",
42
+ distortion: 0.23,
43
+ gap: 0,
44
+ innerGlow: 0.8
45
+ }
46
+ };
47
+ const voronoiPresets = [defaultPreset, shadowPreset];
48
+ const Voronoi = memo(function VoronoiImpl({
49
+ // Own props
50
+ speed = defaultPreset.params.speed,
51
+ frame = defaultPreset.params.frame,
52
+ colors = defaultPreset.params.colors,
53
+ stepsPerColor = defaultPreset.params.stepsPerColor,
54
+ colorGlow = defaultPreset.params.colorGlow,
55
+ colorBack = defaultPreset.params.colorBack,
56
+ distortion = defaultPreset.params.distortion,
57
+ gap = defaultPreset.params.gap,
58
+ innerGlow = defaultPreset.params.innerGlow,
59
+ // Sizing props
60
+ fit = defaultPreset.params.fit,
61
+ scale = defaultPreset.params.scale,
62
+ rotation = defaultPreset.params.rotation,
63
+ originX = defaultPreset.params.originX,
64
+ originY = defaultPreset.params.originY,
65
+ offsetX = defaultPreset.params.offsetX,
66
+ offsetY = defaultPreset.params.offsetY,
67
+ worldWidth = defaultPreset.params.worldWidth,
68
+ worldHeight = defaultPreset.params.worldHeight,
69
+ ...props
70
+ }) {
71
+ const noiseTexture = typeof window !== "undefined" && { u_noiseTexture: getShaderNoiseTexture() };
72
+ const uniforms = {
73
+ // Own uniforms
74
+ u_colors: colors.map(getShaderColorFromString),
75
+ u_colorsCount: colors.length,
76
+ u_stepsPerColor: stepsPerColor,
77
+ u_colorGlow: getShaderColorFromString(colorGlow),
78
+ u_colorBack: getShaderColorFromString(colorBack),
79
+ u_distortion: distortion,
80
+ u_gap: gap,
81
+ u_innerGlow: innerGlow,
82
+ ...noiseTexture,
83
+ // Sizing uniforms
84
+ u_fit: ShaderFitOptions[fit],
85
+ u_scale: scale,
86
+ u_rotation: rotation,
87
+ u_offsetX: offsetX,
88
+ u_offsetY: offsetY,
89
+ u_originX: originX,
90
+ u_originY: originY,
91
+ u_worldWidth: worldWidth,
92
+ u_worldHeight: worldHeight
93
+ };
94
+ return /* @__PURE__ */ jsx(ShaderMount, { ...props, speed, frame, fragmentShader: voronoiFragmentShader, uniforms });
95
+ }, colorPropsAreEqual);
96
+ export {
97
+ Voronoi,
98
+ defaultPreset,
99
+ shadowPreset,
100
+ voronoiPresets
101
+ };
102
+ //# sourceMappingURL=voronoi.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/shaders/voronoi.tsx"],
4
+ "sourcesContent": ["import { memo } from 'react';\nimport { ShaderMount, type ShaderComponentProps } from '../shader-mount';\nimport { colorPropsAreEqual } from '../color-props-are-equal';\nimport {\n defaultPatternSizing,\n getShaderColorFromString,\n getShaderNoiseTexture,\n voronoiFragmentShader,\n ShaderFitOptions,\n type VoronoiParams,\n type VoronoiUniforms,\n type ShaderPreset,\n} from '@paper-design/shaders';\n\nexport interface VoronoiProps extends ShaderComponentProps, VoronoiParams {}\n\ntype VoronoiPreset = ShaderPreset<VoronoiParams>;\n\n// Due to Leva controls limitation:\n// 1) keep default colors in HSLA format to keep alpha channel\n// 2) don't use decimal values on HSL values (to avoid button highlight bug)\n\nexport const defaultPreset: VoronoiPreset = {\n name: 'Default',\n params: {\n ...defaultPatternSizing,\n speed: 0.5,\n frame: 0,\n colors: ['hsla(15, 80%, 50%, 1)', 'hsla(50, 80%, 50%, 1)', 'hsla(200, 80%, 50%, 1)'],\n stepsPerColor: 1,\n colorGlow: 'hsla(266, 100%, 50%, 1)',\n colorBack: 'hsla(0, 0%, 100%, 1)',\n distortion: 0.42,\n gap: 0.06,\n innerGlow: 0,\n },\n};\n\nexport const shadowPreset: VoronoiPreset = {\n name: 'Shadow',\n params: {\n ...defaultPatternSizing,\n speed: 0.5,\n frame: 0,\n colors: ['hsla(259, 29%, 98%, 1)', 'hsla(48, 73%, 98%, 1)', 'hsla(295, 32%, 98%, 1)'],\n stepsPerColor: 1,\n colorGlow: 'hsla(290, 18%, 42%, 1)',\n colorBack: 'hsla(0, 0%, 100%, 1)',\n distortion: 0.23,\n gap: 0,\n innerGlow: 0.8,\n },\n};\n\nexport const voronoiPresets: VoronoiPreset[] = [defaultPreset, shadowPreset];\n\nexport const Voronoi: React.FC<VoronoiProps> = memo(function VoronoiImpl({\n // Own props\n speed = defaultPreset.params.speed,\n frame = defaultPreset.params.frame,\n colors = defaultPreset.params.colors,\n stepsPerColor = defaultPreset.params.stepsPerColor,\n colorGlow = defaultPreset.params.colorGlow,\n colorBack = defaultPreset.params.colorBack,\n distortion = defaultPreset.params.distortion,\n gap = defaultPreset.params.gap,\n innerGlow = defaultPreset.params.innerGlow,\n\n // Sizing props\n fit = defaultPreset.params.fit,\n scale = defaultPreset.params.scale,\n rotation = defaultPreset.params.rotation,\n originX = defaultPreset.params.originX,\n originY = defaultPreset.params.originY,\n offsetX = defaultPreset.params.offsetX,\n offsetY = defaultPreset.params.offsetY,\n worldWidth = defaultPreset.params.worldWidth,\n worldHeight = defaultPreset.params.worldHeight,\n ...props\n}: VoronoiProps) {\n const noiseTexture = typeof window !== 'undefined' && { u_noiseTexture: getShaderNoiseTexture() };\n\n const uniforms = {\n // Own uniforms\n u_colors: colors.map(getShaderColorFromString),\n u_colorsCount: colors.length,\n u_stepsPerColor: stepsPerColor,\n u_colorGlow: getShaderColorFromString(colorGlow),\n u_colorBack: getShaderColorFromString(colorBack),\n u_distortion: distortion,\n u_gap: gap,\n u_innerGlow: innerGlow,\n ...noiseTexture,\n\n // Sizing uniforms\n u_fit: ShaderFitOptions[fit],\n u_scale: scale,\n u_rotation: rotation,\n u_offsetX: offsetX,\n u_offsetY: offsetY,\n u_originX: originX,\n u_originY: originY,\n u_worldWidth: worldWidth,\n u_worldHeight: worldHeight,\n } satisfies VoronoiUniforms;\n\n return (\n <ShaderMount {...props} speed={speed} frame={frame} fragmentShader={voronoiFragmentShader} uniforms={uniforms} />\n );\n}, colorPropsAreEqual);\n"],
5
+ "mappings": ";;;;;AAAA,SAAS,YAAY;AACrB,SAAS,mBAA8C;AACvD,SAAS,0BAA0B;AACnC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAIK;AA+FH;AArFG,MAAM,gBAA+B;AAAA,EAC1C,MAAM;AAAA,EACN,QAAQ;AAAA,IACN,GAAG;AAAA,IACH,OAAO;AAAA,IACP,OAAO;AAAA,IACP,QAAQ,CAAC,yBAAyB,yBAAyB,wBAAwB;AAAA,IACnF,eAAe;AAAA,IACf,WAAW;AAAA,IACX,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,KAAK;AAAA,IACL,WAAW;AAAA,EACb;AACF;AAEO,MAAM,eAA8B;AAAA,EACzC,MAAM;AAAA,EACN,QAAQ;AAAA,IACN,GAAG;AAAA,IACH,OAAO;AAAA,IACP,OAAO;AAAA,IACP,QAAQ,CAAC,0BAA0B,yBAAyB,wBAAwB;AAAA,IACpF,eAAe;AAAA,IACf,WAAW;AAAA,IACX,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,KAA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eAAa,GAAG,OAAO,OAAc,OAAc,gBAAgB,uBAAuB,UAAoB;AAEnH,GAAG,kBAAkB;",
6
+ "names": []
7
+ }
@@ -1,25 +1,8 @@
1
- import { type GlobalParams, type ShaderMountProps } from '../shader-mount';
2
- import { type PatternShape } from '@paper-design/shaders';
3
- export type WarpParams = {
4
- scale?: number;
5
- rotation?: number;
6
- color1?: string;
7
- color2?: string;
8
- color3?: string;
9
- proportion?: number;
10
- softness?: number;
11
- distortion?: number;
12
- swirl?: number;
13
- swirlIterations?: number;
14
- shapeScale?: number;
15
- shape?: PatternShape;
16
- } & GlobalParams;
17
- export type WarpProps = Omit<ShaderMountProps, 'fragmentShader'> & WarpParams;
18
- type WarpPreset = {
19
- name: string;
20
- params: Required<WarpParams>;
21
- style?: React.CSSProperties;
22
- };
1
+ import { type ShaderComponentProps } from '../shader-mount';
2
+ import { type WarpParams, type ShaderPreset } from '@paper-design/shaders';
3
+ export interface WarpProps extends ShaderComponentProps, WarpParams {
4
+ }
5
+ type WarpPreset = ShaderPreset<WarpParams>;
23
6
  export declare const defaultPreset: WarpPreset;
24
7
  export declare const presetCauldron: WarpPreset;
25
8
  export declare const presetSilk: WarpPreset;
@@ -32,5 +15,5 @@ export declare const presetNectar: WarpPreset;
32
15
  export declare const presetFilteredLight: WarpPreset;
33
16
  export declare const presetKelp: WarpPreset;
34
17
  export declare const warpPresets: WarpPreset[];
35
- export declare const Warp: ({ scale, rotation, color1, color2, color3, proportion, softness, distortion, swirl, swirlIterations, shapeScale, shape, ...props }: WarpProps) => React.ReactElement;
18
+ export declare const Warp: React.FC<WarpProps>;
36
19
  export {};
@@ -0,0 +1,290 @@
1
+ /* * * * * * * * * * * * * * * * * * * * * * * * * * * *
2
+ * Paper Shaders *
3
+ * https://github.com/paper-design/shaders *
4
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * */
5
+
6
+ import { memo } from "react";
7
+ import { ShaderMount } from "../shader-mount";
8
+ import { colorPropsAreEqual } from "../color-props-are-equal";
9
+ import {
10
+ defaultPatternSizing,
11
+ getShaderColorFromString,
12
+ warpFragmentShader,
13
+ ShaderFitOptions,
14
+ WarpPatterns
15
+ } from "@paper-design/shaders";
16
+ import { jsx } from "react/jsx-runtime";
17
+ const defaultPreset = {
18
+ name: "Default",
19
+ params: {
20
+ ...defaultPatternSizing,
21
+ rotation: 0,
22
+ speed: 1,
23
+ frame: 0,
24
+ colors: ["hsla(0, 0%, 15%, 1)", "hsla(203, 80%, 70%, 1)", "hsla(0, 0%, 100%, 1)"],
25
+ proportion: 0.35,
26
+ softness: 1,
27
+ distortion: 0.25,
28
+ swirl: 0.8,
29
+ swirlIterations: 10,
30
+ shapeScale: 0.1,
31
+ shape: "edge"
32
+ }
33
+ };
34
+ const presetCauldron = {
35
+ name: "Cauldron Pot",
36
+ params: {
37
+ ...defaultPatternSizing,
38
+ scale: 1 / 1.1,
39
+ rotation: 1.62,
40
+ speed: 10,
41
+ frame: 0,
42
+ colors: ["hsla(100, 51%, 75%, 1)", "hsla(220, 39%, 32%, 1)", "hsla(129.2, 41.9%, 6.1%, 1)"],
43
+ proportion: 0.64,
44
+ softness: 0.95,
45
+ distortion: 0.2,
46
+ swirl: 0.86,
47
+ swirlIterations: 7,
48
+ shapeScale: 0,
49
+ shape: "edge"
50
+ }
51
+ };
52
+ const presetSilk = {
53
+ name: "Silk",
54
+ params: {
55
+ ...defaultPatternSizing,
56
+ scale: 1 / 0.26,
57
+ rotation: 0,
58
+ speed: 5,
59
+ frame: 0,
60
+ colors: ["hsla(0, 9%, 7%, 1)", "hsla(8, 13%, 34%, 1)", "hsla(5, 8%, 71%, 1)"],
61
+ proportion: 0,
62
+ softness: 1,
63
+ distortion: 0.3,
64
+ swirl: 0.6,
65
+ swirlIterations: 11,
66
+ shapeScale: 0.05,
67
+ shape: "stripes"
68
+ }
69
+ };
70
+ const presetPassion = {
71
+ name: "Passion",
72
+ params: {
73
+ ...defaultPatternSizing,
74
+ scale: 1 / 0.25,
75
+ rotation: 1.35,
76
+ speed: 3,
77
+ frame: 0,
78
+ colors: ["hsla(0, 44.7%, 14.9%, 1)", "hsla(353.4, 34%, 42.2%, 1)", "hsla(29, 100%, 76.1%, 1)"],
79
+ proportion: 0.5,
80
+ softness: 1,
81
+ distortion: 0.09,
82
+ swirl: 0.9,
83
+ swirlIterations: 6,
84
+ shapeScale: 0.25,
85
+ shape: "checks"
86
+ }
87
+ };
88
+ const presetPhantom = {
89
+ name: "Phantom",
90
+ params: {
91
+ ...defaultPatternSizing,
92
+ scale: 1 / 0.68,
93
+ rotation: 1.8,
94
+ speed: 12,
95
+ frame: 0,
96
+ colors: ["hsla(242.2, 44.3%, 12%, 1)", "hsla(236.1, 80.4%, 70%, 1)", "hsla(0, 0%, 100%, 1)"],
97
+ proportion: 0.45,
98
+ softness: 1,
99
+ distortion: 0.16,
100
+ swirl: 0.3,
101
+ swirlIterations: 7,
102
+ shapeScale: 0.1,
103
+ shape: "checks"
104
+ }
105
+ };
106
+ const presetAbyss = {
107
+ name: "The Abyss",
108
+ params: {
109
+ ...defaultPatternSizing,
110
+ scale: 1 / 0.1,
111
+ rotation: 2,
112
+ speed: 0.6,
113
+ frame: 0,
114
+ colors: ["hsla(242.2, 44.3%, 12%, 1)", "hsla(236.1, 80.4%, 70%, 1)", "hsla(0, 0%, 100%, 1)"],
115
+ proportion: 0,
116
+ softness: 1,
117
+ distortion: 0.09,
118
+ swirl: 0.48,
119
+ swirlIterations: 4,
120
+ shapeScale: 0.1,
121
+ shape: "edge"
122
+ }
123
+ };
124
+ const presetInk = {
125
+ name: "Live Ink",
126
+ params: {
127
+ ...defaultPatternSizing,
128
+ scale: 1 / 0.7,
129
+ rotation: 1.5,
130
+ speed: 2.5,
131
+ frame: 0,
132
+ colors: ["hsla(210, 11.1%, 7.1%, 1)", "hsla(165, 9%, 65.1%, 1)", "hsla(84, 100%, 97.1%, 1)"],
133
+ proportion: 0.35,
134
+ softness: 0,
135
+ distortion: 0.25,
136
+ swirl: 0.8,
137
+ swirlIterations: 10,
138
+ shapeScale: 0.26,
139
+ shape: "checks"
140
+ }
141
+ };
142
+ const presetIceberg = {
143
+ name: "Iceberg",
144
+ params: {
145
+ ...defaultPatternSizing,
146
+ scale: 1 / 1.1,
147
+ rotation: 2,
148
+ speed: 0.5,
149
+ frame: 0,
150
+ colors: ["hsla(0, 0%, 100%, 1)", "hsla(220, 38.7%, 32%, 1)", "hsla(129.2, 41.9%, 6.1%, 1)"],
151
+ proportion: 0.3,
152
+ softness: 1,
153
+ distortion: 0.2,
154
+ swirl: 0.86,
155
+ swirlIterations: 7,
156
+ shapeScale: 0,
157
+ shape: "checks"
158
+ }
159
+ };
160
+ const presetNectar = {
161
+ name: "Nectar",
162
+ params: {
163
+ ...defaultPatternSizing,
164
+ scale: 1 / 0.24,
165
+ rotation: 0,
166
+ speed: 4.2,
167
+ frame: 0,
168
+ colors: ["hsla(37.5, 22.2%, 7.1%, 1)", "hsla(38.5, 59.1%, 63.1%, 1)", "hsla(37.6, 30%, 95.2%, 1)"],
169
+ proportion: 0.24,
170
+ softness: 1,
171
+ distortion: 0.21,
172
+ swirl: 0.57,
173
+ swirlIterations: 10,
174
+ shapeScale: 0.32,
175
+ shape: "edge"
176
+ }
177
+ };
178
+ const presetFilteredLight = {
179
+ name: "Filtered Light",
180
+ params: {
181
+ ...defaultPatternSizing,
182
+ scale: 2,
183
+ rotation: 0.44,
184
+ speed: 3.2,
185
+ frame: 0,
186
+ colors: ["hsla(60.2, 7.8%, 8.3%, 1)", "hsla(64.4, 27.8%, 81%, 1)", "hsla(60, 100%, 93.9%, 1)"],
187
+ proportion: 0.25,
188
+ softness: 1,
189
+ distortion: 0.06,
190
+ swirl: 0,
191
+ swirlIterations: 0,
192
+ shapeScale: 0,
193
+ shape: "stripes"
194
+ }
195
+ };
196
+ const presetKelp = {
197
+ name: "Kelp",
198
+ params: {
199
+ ...defaultPatternSizing,
200
+ scale: 0.38,
201
+ rotation: 0.6,
202
+ speed: 20,
203
+ frame: 0,
204
+ colors: ["hsla(79.3, 100%, 78%, 1)", "hsla(112, 10.5%, 28%, 1)", "hsla(203.3, 50%, 7.1%, 1)"],
205
+ proportion: 1,
206
+ softness: 0,
207
+ distortion: 0,
208
+ swirl: 0.15,
209
+ swirlIterations: 0,
210
+ shapeScale: 0.74,
211
+ shape: "stripes"
212
+ }
213
+ };
214
+ const warpPresets = [
215
+ defaultPreset,
216
+ presetAbyss,
217
+ presetCauldron,
218
+ presetFilteredLight,
219
+ presetIceberg,
220
+ presetInk,
221
+ presetKelp,
222
+ presetNectar,
223
+ presetPassion,
224
+ presetPhantom,
225
+ presetSilk
226
+ ];
227
+ const Warp = memo(function WarpImpl({
228
+ // Own props
229
+ speed = defaultPreset.params.speed,
230
+ frame = defaultPreset.params.frame,
231
+ colors = defaultPreset.params.colors,
232
+ proportion = defaultPreset.params.proportion,
233
+ softness = defaultPreset.params.softness,
234
+ distortion = defaultPreset.params.distortion,
235
+ swirl = defaultPreset.params.swirl,
236
+ swirlIterations = defaultPreset.params.swirlIterations,
237
+ shapeScale = defaultPreset.params.shapeScale,
238
+ shape = defaultPreset.params.shape,
239
+ // Sizing props
240
+ fit = defaultPreset.params.fit,
241
+ scale = defaultPreset.params.scale,
242
+ rotation = defaultPreset.params.rotation,
243
+ originX = defaultPreset.params.originX,
244
+ originY = defaultPreset.params.originY,
245
+ offsetX = defaultPreset.params.offsetX,
246
+ offsetY = defaultPreset.params.offsetY,
247
+ worldWidth = defaultPreset.params.worldWidth,
248
+ worldHeight = defaultPreset.params.worldHeight,
249
+ ...props
250
+ }) {
251
+ const uniforms = {
252
+ // Own uniforms
253
+ u_colors: colors.map(getShaderColorFromString),
254
+ u_colorsCount: colors.length,
255
+ u_proportion: proportion,
256
+ u_softness: softness,
257
+ u_distortion: distortion,
258
+ u_swirl: swirl,
259
+ u_swirlIterations: swirlIterations,
260
+ u_shapeScale: shapeScale,
261
+ u_shape: WarpPatterns[shape],
262
+ // Sizing uniforms
263
+ u_scale: scale,
264
+ u_rotation: rotation,
265
+ u_fit: ShaderFitOptions[fit],
266
+ u_offsetX: offsetX,
267
+ u_offsetY: offsetY,
268
+ u_originX: originX,
269
+ u_originY: originY,
270
+ u_worldWidth: worldWidth,
271
+ u_worldHeight: worldHeight
272
+ };
273
+ return /* @__PURE__ */ jsx(ShaderMount, { ...props, speed, frame, fragmentShader: warpFragmentShader, uniforms });
274
+ }, colorPropsAreEqual);
275
+ export {
276
+ Warp,
277
+ defaultPreset,
278
+ presetAbyss,
279
+ presetCauldron,
280
+ presetFilteredLight,
281
+ presetIceberg,
282
+ presetInk,
283
+ presetKelp,
284
+ presetNectar,
285
+ presetPassion,
286
+ presetPhantom,
287
+ presetSilk,
288
+ warpPresets
289
+ };
290
+ //# sourceMappingURL=warp.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/shaders/warp.tsx"],
4
+ "sourcesContent": ["import { memo } from 'react';\nimport { ShaderMount, type ShaderComponentProps } from '../shader-mount';\nimport { colorPropsAreEqual } from '../color-props-are-equal';\nimport {\n defaultPatternSizing,\n getShaderColorFromString,\n warpFragmentShader,\n ShaderFitOptions,\n type WarpParams,\n type WarpUniforms,\n type ShaderPreset,\n WarpPatterns,\n} from '@paper-design/shaders';\n\nexport interface WarpProps extends ShaderComponentProps, WarpParams {}\n\ntype WarpPreset = ShaderPreset<WarpParams>;\n\n// Due to Leva controls limitation:\n// 1) keep default colors in HSLA format to keep alpha channel\n// 2) don't use decimal values on HSL values (to avoid button highlight bug)\n\nexport const defaultPreset: WarpPreset = {\n name: 'Default',\n params: {\n ...defaultPatternSizing,\n rotation: 0,\n speed: 1,\n frame: 0,\n colors: ['hsla(0, 0%, 15%, 1)', 'hsla(203, 80%, 70%, 1)', 'hsla(0, 0%, 100%, 1)'],\n proportion: 0.35,\n softness: 1,\n distortion: 0.25,\n swirl: 0.8,\n swirlIterations: 10,\n shapeScale: 0.1,\n shape: 'edge',\n },\n};\n\nexport const presetCauldron: WarpPreset = {\n name: 'Cauldron Pot',\n params: {\n ...defaultPatternSizing,\n scale: 1 / 1.1,\n rotation: 1.62,\n speed: 10,\n frame: 0,\n colors: ['hsla(100, 51%, 75%, 1)', 'hsla(220, 39%, 32%, 1)', 'hsla(129.2, 41.9%, 6.1%, 1)'],\n proportion: 0.64,\n softness: 0.95,\n distortion: 0.2,\n swirl: 0.86,\n swirlIterations: 7,\n shapeScale: 0,\n shape: 'edge',\n },\n};\n\nexport const presetSilk: WarpPreset = {\n name: 'Silk',\n params: {\n ...defaultPatternSizing,\n scale: 1 / 0.26,\n rotation: 0,\n speed: 5,\n frame: 0,\n colors: ['hsla(0, 9%, 7%, 1)', 'hsla(8, 13%, 34%, 1)', 'hsla(5, 8%, 71%, 1)'],\n proportion: 0,\n softness: 1,\n distortion: 0.3,\n swirl: 0.6,\n swirlIterations: 11,\n shapeScale: 0.05,\n shape: 'stripes',\n },\n};\n\nexport const presetPassion: WarpPreset = {\n name: 'Passion',\n params: {\n ...defaultPatternSizing,\n scale: 1 / 0.25,\n rotation: 1.35,\n speed: 3,\n frame: 0,\n colors: ['hsla(0, 44.7%, 14.9%, 1)', 'hsla(353.4, 34%, 42.2%, 1)', 'hsla(29, 100%, 76.1%, 1)'],\n proportion: 0.5,\n softness: 1,\n distortion: 0.09,\n swirl: 0.9,\n swirlIterations: 6,\n shapeScale: 0.25,\n shape: 'checks',\n },\n};\n\nexport const presetPhantom: WarpPreset = {\n name: 'Phantom',\n params: {\n ...defaultPatternSizing,\n scale: 1 / 0.68,\n rotation: 1.8,\n speed: 12,\n frame: 0,\n colors: ['hsla(242.2, 44.3%, 12%, 1)', 'hsla(236.1, 80.4%, 70%, 1)', 'hsla(0, 0%, 100%, 1)'],\n proportion: 0.45,\n softness: 1,\n distortion: 0.16,\n swirl: 0.3,\n swirlIterations: 7,\n shapeScale: 0.1,\n shape: 'checks',\n },\n};\n\nexport const presetAbyss: WarpPreset = {\n name: 'The Abyss',\n params: {\n ...defaultPatternSizing,\n scale: 1 / 0.1,\n rotation: 2,\n speed: 0.6,\n frame: 0,\n colors: ['hsla(242.2, 44.3%, 12%, 1)', 'hsla(236.1, 80.4%, 70%, 1)', 'hsla(0, 0%, 100%, 1)'],\n proportion: 0,\n softness: 1,\n distortion: 0.09,\n swirl: 0.48,\n swirlIterations: 4,\n shapeScale: 0.1,\n shape: 'edge',\n },\n};\n\nexport const presetInk: WarpPreset = {\n name: 'Live Ink',\n params: {\n ...defaultPatternSizing,\n scale: 1 / 0.7,\n rotation: 1.5,\n speed: 2.5,\n frame: 0,\n colors: ['hsla(210, 11.1%, 7.1%, 1)', 'hsla(165, 9%, 65.1%, 1)', 'hsla(84, 100%, 97.1%, 1)'],\n proportion: 0.35,\n softness: 0,\n distortion: 0.25,\n swirl: 0.8,\n swirlIterations: 10,\n shapeScale: 0.26,\n shape: 'checks',\n },\n};\n\nexport const presetIceberg: WarpPreset = {\n name: 'Iceberg',\n params: {\n ...defaultPatternSizing,\n scale: 1 / 1.1,\n rotation: 2,\n speed: 0.5,\n frame: 0,\n colors: ['hsla(0, 0%, 100%, 1)', 'hsla(220, 38.7%, 32%, 1)', 'hsla(129.2, 41.9%, 6.1%, 1)'],\n proportion: 0.3,\n softness: 1,\n distortion: 0.2,\n swirl: 0.86,\n swirlIterations: 7,\n shapeScale: 0,\n shape: 'checks',\n },\n};\n\nexport const presetNectar: WarpPreset = {\n name: 'Nectar',\n params: {\n ...defaultPatternSizing,\n scale: 1 / 0.24,\n rotation: 0,\n speed: 4.2,\n frame: 0,\n colors: ['hsla(37.5, 22.2%, 7.1%, 1)', 'hsla(38.5, 59.1%, 63.1%, 1)', 'hsla(37.6, 30%, 95.2%, 1)'],\n proportion: 0.24,\n softness: 1,\n distortion: 0.21,\n swirl: 0.57,\n swirlIterations: 10,\n shapeScale: 0.32,\n shape: 'edge',\n },\n};\n\nexport const presetFilteredLight: WarpPreset = {\n name: 'Filtered Light',\n params: {\n ...defaultPatternSizing,\n scale: 2,\n rotation: 0.44,\n speed: 3.2,\n frame: 0,\n colors: ['hsla(60.2, 7.8%, 8.3%, 1)', 'hsla(64.4, 27.8%, 81%, 1)', 'hsla(60, 100%, 93.9%, 1)'],\n proportion: 0.25,\n softness: 1,\n distortion: 0.06,\n swirl: 0,\n swirlIterations: 0,\n shapeScale: 0,\n shape: 'stripes',\n },\n};\n\nexport const presetKelp: WarpPreset = {\n name: 'Kelp',\n params: {\n ...defaultPatternSizing,\n scale: 0.38,\n rotation: 0.6,\n speed: 20,\n frame: 0,\n colors: ['hsla(79.3, 100%, 78%, 1)', 'hsla(112, 10.5%, 28%, 1)', 'hsla(203.3, 50%, 7.1%, 1)'],\n proportion: 1,\n softness: 0,\n distortion: 0,\n swirl: 0.15,\n swirlIterations: 0,\n shapeScale: 0.74,\n shape: 'stripes',\n },\n};\n\nexport const warpPresets: WarpPreset[] = [\n defaultPreset,\n presetAbyss,\n presetCauldron,\n presetFilteredLight,\n presetIceberg,\n presetInk,\n presetKelp,\n presetNectar,\n presetPassion,\n presetPhantom,\n presetSilk,\n];\n\nexport const Warp: React.FC<WarpProps> = memo(function WarpImpl({\n // Own props\n speed = defaultPreset.params.speed,\n frame = defaultPreset.params.frame,\n colors = defaultPreset.params.colors,\n proportion = defaultPreset.params.proportion,\n softness = defaultPreset.params.softness,\n distortion = defaultPreset.params.distortion,\n swirl = defaultPreset.params.swirl,\n swirlIterations = defaultPreset.params.swirlIterations,\n shapeScale = defaultPreset.params.shapeScale,\n shape = defaultPreset.params.shape,\n\n // Sizing props\n fit = defaultPreset.params.fit,\n scale = defaultPreset.params.scale,\n rotation = defaultPreset.params.rotation,\n originX = defaultPreset.params.originX,\n originY = defaultPreset.params.originY,\n offsetX = defaultPreset.params.offsetX,\n offsetY = defaultPreset.params.offsetY,\n worldWidth = defaultPreset.params.worldWidth,\n worldHeight = defaultPreset.params.worldHeight,\n ...props\n}: WarpProps) {\n const uniforms = {\n // Own uniforms\n u_colors: colors.map(getShaderColorFromString),\n u_colorsCount: colors.length,\n u_proportion: proportion,\n u_softness: softness,\n u_distortion: distortion,\n u_swirl: swirl,\n u_swirlIterations: swirlIterations,\n u_shapeScale: shapeScale,\n u_shape: WarpPatterns[shape],\n\n // Sizing uniforms\n u_scale: scale,\n u_rotation: rotation,\n u_fit: ShaderFitOptions[fit],\n u_offsetX: offsetX,\n u_offsetY: offsetY,\n u_originX: originX,\n u_originY: originY,\n u_worldWidth: worldWidth,\n u_worldHeight: worldHeight,\n } satisfies WarpUniforms;\n\n return <ShaderMount {...props} speed={speed} frame={frame} fragmentShader={warpFragmentShader} uniforms={uniforms} />;\n}, colorPropsAreEqual);\n"],
5
+ "mappings": ";;;;;AAAA,SAAS,YAAY;AACrB,SAAS,mBAA8C;AACvD,SAAS,0BAA0B;AACnC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAIA;AAAA,OACK;AAyRE;AA/QF,MAAM,gBAA4B;AAAA,EACvC,MAAM;AAAA,EACN,QAAQ;AAAA,IACN,GAAG;AAAA,IACH,UAAU;AAAA,IACV,OAAO;AAAA,IACP,OAAO;AAAA,IACP,QAAQ,CAAC,uBAAuB,0BAA0B,sBAAsB;AAAA,IAChF,YAAY;AAAA,IACZ,UAAU;AAAA,IACV,YAAY;AAAA,IACZ,OAAO;AAAA,IACP,iBAAiB;AAAA,IACjB,YAAY;AAAA,IACZ,OAAO;AAAA,EACT;AACF;AAEO,MAAM,iBAA6B;AAAA,EACxC,MAAM;AAAA,EACN,QAAQ;AAAA,IACN,GAAG;AAAA,IACH,OAAO,IAAI;AAAA,IACX,UAAU;AAAA,IACV,OAAO;AAAA,IACP,OAAO;AAAA,IACP,QAAQ,CAAC,0BAA0B,0BAA0B,6BAA6B;AAAA,IAC1F,YAAY;AAAA,IACZ,UAAU;AAAA,IACV,YAAY;AAAA,IACZ,OAAO;AAAA,IACP,iBAAiB;AAAA,IACjB,YAAY;AAAA,IACZ,OAAO;AAAA,EACT;AACF;AAEO,MAAM,aAAyB;AAAA,EACpC,MAAM;AAAA,EAC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B,UAAU,cAAc,OAAO;AAAA,EAC/B,aAAa,cAAc,OAAO;AAAA,EAClC,cAAc,cAAc,OAAO;AAAA,EACnC,GAAG;AACL,GAAc;AACZ,QAAM,WAAW;AAAA;AAAA,IAEf,UAAU,OAAO,IAAI,wBAAwB;AAAA,IAC7C,eAAe,OAAO;AAAA,IACtB,cAAc;AAAA,IACd,YAAY;AAAA,IACZ,cAAc;AAAA,IACd,SAAS;AAAA,IACT,mBAAmB;AAAA,IACnB,cAAc;AAAA,IACd,SAAS,aAAa,KAAK;AAAA;AAAA,IAG3B,SAAS;AAAA,IACT,YAAY;AAAA,IACZ,OAAO,iBAAiB,GAAG;AAAA,IAC3B,WAAW;AAAA,IACX,WAAW;AAAA,IACX,WAAW;AAAA,IACX,WAAW;AAAA,IACX,cAAc;AAAA,IACd,eAAe;AAAA,EACjB;AAEA,SAAO,oBAAC,eAAa,GAAG,OAAO,OAAc,OAAc,gBAAgB,oBAAoB,UAAoB;AACrH,GAAG,kBAAkB;",
6
+ "names": []
7
+ }
@@ -1,21 +1,8 @@
1
- import { type ShaderMountProps } from '../shader-mount';
2
- export type WavesParams = {
3
- scale?: number;
4
- rotation?: number;
5
- color?: string;
6
- shape?: number;
7
- frequency?: number;
8
- amplitude?: number;
9
- spacing?: number;
10
- dutyCycle?: number;
11
- softness?: number;
12
- };
13
- export type WavesProps = Omit<ShaderMountProps, 'fragmentShader'> & WavesParams;
14
- type WavesPreset = {
15
- name: string;
16
- params: Required<WavesParams>;
17
- style?: React.CSSProperties;
18
- };
1
+ import { type ShaderComponentProps } from '../shader-mount';
2
+ import { type WavesParams, type ShaderPreset } from '@paper-design/shaders';
3
+ export interface WavesProps extends ShaderComponentProps, WavesParams {
4
+ }
5
+ type WavesPreset = ShaderPreset<WavesParams>;
19
6
  export declare const defaultPreset: WavesPreset;
20
7
  export declare const spikesPreset: WavesPreset;
21
8
  export declare const groovyPreset: WavesPreset;
@@ -23,5 +10,5 @@ export declare const tangledUpPreset: WavesPreset;
23
10
  export declare const zigZagPreset: WavesPreset;
24
11
  export declare const waveRidePreset: WavesPreset;
25
12
  export declare const wavesPresets: WavesPreset[];
26
- export declare const Waves: ({ scale, rotation, color, shape, frequency, amplitude, spacing, dutyCycle, softness, ...props }: WavesProps) => React.ReactElement;
13
+ export declare const Waves: React.FC<WavesProps>;
27
14
  export {};
@@ -0,0 +1,178 @@
1
+ /* * * * * * * * * * * * * * * * * * * * * * * * * * * *
2
+ * Paper Shaders *
3
+ * https://github.com/paper-design/shaders *
4
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * */
5
+
6
+ import { memo } from "react";
7
+ import { ShaderMount } from "../shader-mount";
8
+ import { colorPropsAreEqual } from "../color-props-are-equal";
9
+ import {
10
+ defaultPatternSizing,
11
+ getShaderColorFromString,
12
+ wavesFragmentShader,
13
+ ShaderFitOptions
14
+ } from "@paper-design/shaders";
15
+ import { jsx } from "react/jsx-runtime";
16
+ const defaultPreset = {
17
+ name: "Default",
18
+ params: {
19
+ ...defaultPatternSizing,
20
+ scale: 1.6,
21
+ rotation: 0,
22
+ color1: "hsla(0, 0%, 100%, 1)",
23
+ color2: "hsla(225, 75%, 24%, 1)",
24
+ shape: 0,
25
+ frequency: 0.5,
26
+ amplitude: 0.6,
27
+ spacing: 0.65,
28
+ proportion: 0.15,
29
+ softness: 0
30
+ }
31
+ };
32
+ const spikesPreset = {
33
+ name: "Spikes",
34
+ params: {
35
+ ...defaultPatternSizing,
36
+ scale: 1 / 2.3,
37
+ rotation: 0,
38
+ color1: "hsla(65, 100%, 95%, 1)",
39
+ color2: "hsla(290, 52%, 15%, 1)",
40
+ shape: 0,
41
+ frequency: 0.5,
42
+ amplitude: 0.9,
43
+ spacing: 0.37,
44
+ proportion: 0.93,
45
+ softness: 0.15
46
+ }
47
+ };
48
+ const groovyPreset = {
49
+ name: "Groovy",
50
+ params: {
51
+ ...defaultPatternSizing,
52
+ scale: 1 / 0.5,
53
+ rotation: 1,
54
+ color1: "hsla(60, 100%, 97%, 1)",
55
+ color2: "hsla(20, 100%, 71%, 1)",
56
+ shape: 2.37,
57
+ frequency: 0.2,
58
+ amplitude: 0.67,
59
+ spacing: 1.17,
60
+ proportion: 0.57,
61
+ softness: 0
62
+ }
63
+ };
64
+ const tangledUpPreset = {
65
+ name: "Tangled up",
66
+ params: {
67
+ ...defaultPatternSizing,
68
+ scale: 1 / 3.04,
69
+ rotation: 1,
70
+ color1: "hsla(198.7, 66.7%, 14.1%, 1)",
71
+ color2: "hsla(85.5, 35.7%, 78%, 1)",
72
+ shape: 3,
73
+ frequency: 0.44,
74
+ amplitude: 0.57,
75
+ spacing: 1.05,
76
+ proportion: 0.97,
77
+ softness: 0
78
+ }
79
+ };
80
+ const zigZagPreset = {
81
+ name: "Zig zag",
82
+ params: {
83
+ ...defaultPatternSizing,
84
+ scale: 1 / 2.7,
85
+ rotation: 1,
86
+ color1: "hsla(0, 0%, 0%, 1)",
87
+ color2: "hsla(0, 0%, 90%, 1)",
88
+ shape: 0,
89
+ frequency: 0.6,
90
+ amplitude: 0.8,
91
+ spacing: 0.5,
92
+ proportion: 1,
93
+ softness: 0.5
94
+ }
95
+ };
96
+ const waveRidePreset = {
97
+ name: "Ride the wave",
98
+ params: {
99
+ ...defaultPatternSizing,
100
+ scale: 1 / 0.84,
101
+ rotation: 0,
102
+ color1: "hsla(65, 100%, 95%, 1)",
103
+ color2: "hsla(0, 0%, 12%, 1)",
104
+ shape: 2.23,
105
+ frequency: 0.1,
106
+ amplitude: 0.6,
107
+ spacing: 0.41,
108
+ proportion: 0.99,
109
+ softness: 0
110
+ }
111
+ };
112
+ const wavesPresets = [
113
+ defaultPreset,
114
+ spikesPreset,
115
+ groovyPreset,
116
+ tangledUpPreset,
117
+ zigZagPreset,
118
+ waveRidePreset
119
+ ];
120
+ const Waves = memo(function WavesImpl({
121
+ // Own props
122
+ color1 = defaultPreset.params.color1,
123
+ color2 = defaultPreset.params.color2,
124
+ shape = defaultPreset.params.shape,
125
+ frequency = defaultPreset.params.frequency,
126
+ amplitude = defaultPreset.params.amplitude,
127
+ spacing = defaultPreset.params.spacing,
128
+ proportion = defaultPreset.params.proportion,
129
+ softness = defaultPreset.params.softness,
130
+ // Sizing props
131
+ fit = defaultPreset.params.fit,
132
+ scale = defaultPreset.params.scale,
133
+ rotation = defaultPreset.params.rotation,
134
+ offsetX = defaultPreset.params.offsetX,
135
+ offsetY = defaultPreset.params.offsetY,
136
+ originX = defaultPreset.params.originX,
137
+ originY = defaultPreset.params.originY,
138
+ worldWidth = defaultPreset.params.worldWidth,
139
+ worldHeight = defaultPreset.params.worldHeight,
140
+ // Other props
141
+ maxPixelCount = 6016 * 3384,
142
+ // Higher max resolution for this shader
143
+ ...props
144
+ }) {
145
+ const uniforms = {
146
+ // Own uniforms
147
+ u_color1: getShaderColorFromString(color1),
148
+ u_color2: getShaderColorFromString(color2),
149
+ u_shape: shape,
150
+ u_frequency: frequency,
151
+ u_amplitude: amplitude,
152
+ u_spacing: spacing,
153
+ u_proportion: proportion,
154
+ u_softness: softness,
155
+ // Sizing uniforms
156
+ u_fit: ShaderFitOptions[fit],
157
+ u_scale: scale,
158
+ u_rotation: rotation,
159
+ u_offsetX: offsetX,
160
+ u_offsetY: offsetY,
161
+ u_originX: originX,
162
+ u_originY: originY,
163
+ u_worldWidth: worldWidth,
164
+ u_worldHeight: worldHeight
165
+ };
166
+ return /* @__PURE__ */ jsx(ShaderMount, { ...props, fragmentShader: wavesFragmentShader, uniforms });
167
+ }, colorPropsAreEqual);
168
+ export {
169
+ Waves,
170
+ defaultPreset,
171
+ groovyPreset,
172
+ spikesPreset,
173
+ tangledUpPreset,
174
+ waveRidePreset,
175
+ wavesPresets,
176
+ zigZagPreset
177
+ };
178
+ //# sourceMappingURL=waves.js.map