@brochington/shader-backgrounds 0.1.0 → 0.1.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.
@@ -0,0 +1,5 @@
1
+ export * from './lib/core/types';
2
+ export * from './lib/core/ShaderCanvas';
3
+ export * from './lib/plugins/GradientPlugin';
4
+ export * from './lib/plugins';
5
+ export * from './lib/components/web-component';
@@ -0,0 +1,17 @@
1
+ import { ShaderPlugin } from '../core/types';
2
+ export declare class ShaderBackgroundElement extends HTMLElement {
3
+ #private;
4
+ constructor();
5
+ connectedCallback(): void;
6
+ disconnectedCallback(): void;
7
+ set plugin(plugin: ShaderPlugin);
8
+ get plugin(): ShaderPlugin;
9
+ set renderScale(value: number);
10
+ get renderScale(): number;
11
+ set singleRender(value: boolean);
12
+ get singleRender(): boolean;
13
+ render(): void;
14
+ init(): void;
15
+ static get observedAttributes(): string[];
16
+ attributeChangedCallback(name: string, oldValue: string, newValue: string): void;
17
+ }
@@ -0,0 +1,21 @@
1
+ import { OGLRenderingContext } from 'ogl';
2
+ import { ShaderPlugin } from './types';
3
+ export declare class ShaderCanvas {
4
+ #private;
5
+ private canvas;
6
+ gl: OGLRenderingContext;
7
+ constructor(canvas: HTMLCanvasElement, plugin: ShaderPlugin, options?: {
8
+ pixelRatio?: number;
9
+ width?: number;
10
+ height?: number;
11
+ renderScale?: number;
12
+ singleRender?: boolean;
13
+ });
14
+ private init;
15
+ start(): void;
16
+ stop(): void;
17
+ render(): void;
18
+ resize(width?: number, height?: number): void;
19
+ private loop;
20
+ dispose(): void;
21
+ }
@@ -0,0 +1,12 @@
1
+ import { Program, OGLRenderingContext } from 'ogl';
2
+ export interface ShaderPlugin {
3
+ name: string;
4
+ fragmentShader: string;
5
+ vertexShader?: string;
6
+ uniforms: Record<string, {
7
+ value: any;
8
+ }>;
9
+ onInit?: (gl: OGLRenderingContext, program: Program) => void;
10
+ onRender?: (dt: number, totalTime: number) => void;
11
+ onResize?: (width: number, height: number) => void;
12
+ }
@@ -0,0 +1,25 @@
1
+ import { ShaderPlugin } from '../core/types';
2
+ export type AuroraWavesConfig = {
3
+ /** Base background color */
4
+ backgroundColor: string;
5
+ /** Aurora ribbon primary color */
6
+ color1: string;
7
+ /** Aurora ribbon secondary color */
8
+ color2: string;
9
+ /** Overall brightness multiplier */
10
+ intensity?: number;
11
+ /** Motion speed */
12
+ speed?: number;
13
+ /** Noise scale (bigger = larger features) */
14
+ scale?: number;
15
+ /** Subtle film grain */
16
+ grainAmount?: number;
17
+ };
18
+ export declare class AuroraWavesPlugin implements ShaderPlugin {
19
+ name: string;
20
+ fragmentShader: string;
21
+ uniforms: any;
22
+ private speed;
23
+ constructor(config: AuroraWavesConfig);
24
+ onRender(dt: number): void;
25
+ }
@@ -0,0 +1,19 @@
1
+ import { ShaderPlugin } from '../core/types';
2
+ export type CausticsConfig = {
3
+ color: string;
4
+ backgroundColor: string;
5
+ intensity?: number;
6
+ speed?: number;
7
+ scale?: number;
8
+ distortion?: number;
9
+ sharpness?: number;
10
+ antiAlias?: number;
11
+ };
12
+ export declare class CausticsPlugin implements ShaderPlugin {
13
+ name: string;
14
+ fragmentShader: string;
15
+ uniforms: any;
16
+ private speed;
17
+ constructor(config: CausticsConfig);
18
+ onRender(dt: number): void;
19
+ }
@@ -0,0 +1,26 @@
1
+ import { ShaderPlugin } from '../core/types';
2
+ export type ContourLinesConfig = {
3
+ backgroundColor: string;
4
+ lineColor: string;
5
+ accentColor?: string;
6
+ /** Lines per unit */
7
+ density?: number;
8
+ /** Line thickness */
9
+ thickness?: number;
10
+ /** Warp amount */
11
+ warp?: number;
12
+ /** Motion speed */
13
+ speed?: number;
14
+ /** Glow amount */
15
+ glow?: number;
16
+ /** Grain amount */
17
+ grainAmount?: number;
18
+ };
19
+ export declare class ContourLinesPlugin implements ShaderPlugin {
20
+ name: string;
21
+ fragmentShader: string;
22
+ uniforms: any;
23
+ private speed;
24
+ constructor(config: ContourLinesConfig);
25
+ onRender(dt: number): void;
26
+ }
@@ -0,0 +1,30 @@
1
+ import { ShaderPlugin } from '../core/types';
2
+ export type DreamyBokehConfig = {
3
+ /** Background gradient bottom/top */
4
+ backgroundBottom: string;
5
+ backgroundTop: string;
6
+ /** A 3-color palette for the bokeh highlights */
7
+ colorA?: string;
8
+ colorB?: string;
9
+ colorC?: string;
10
+ /** Bokeh density multiplier (0..3) */
11
+ density?: number;
12
+ /** Bokeh size multiplier (0.5..2) */
13
+ size?: number;
14
+ /** Edge softness / blur multiplier (0.5..2) */
15
+ blur?: number;
16
+ /** Motion speed */
17
+ speed?: number;
18
+ /** Vignette strength (0..1) */
19
+ vignette?: number;
20
+ /** Grain strength (0..0.15) */
21
+ grainAmount?: number;
22
+ };
23
+ export declare class DreamyBokehPlugin implements ShaderPlugin {
24
+ name: string;
25
+ fragmentShader: string;
26
+ uniforms: any;
27
+ private speed;
28
+ constructor(config: DreamyBokehConfig);
29
+ onRender(dt: number): void;
30
+ }
@@ -0,0 +1,60 @@
1
+ import { ShaderPlugin } from '../core/types';
2
+ export type GradientEasing = 'linear' | 'smoothstep' | 'easeInOutQuad' | 'easeInOutCubic';
3
+ export type GradientMotionMode = 'none' | 'path' | 'random';
4
+ export type GradientMotionBounds = {
5
+ minX: number;
6
+ maxX: number;
7
+ minY: number;
8
+ maxY: number;
9
+ };
10
+ export type GradientMotion = {
11
+ /**
12
+ * - "none": static point (default)
13
+ * - "path": moves between points in `path`
14
+ * - "random": picks random targets and eases between them
15
+ */
16
+ mode?: GradientMotionMode;
17
+ /** Waypoints for "path" mode. */
18
+ path?: Array<{
19
+ x: number;
20
+ y: number;
21
+ }>;
22
+ /** Seconds to move from start -> target. Default 3.0 */
23
+ duration?: number;
24
+ /** Easing curve for interpolation. Default "smoothstep" */
25
+ easing?: GradientEasing;
26
+ /**
27
+ * Bounds for clamping/random target generation. Defaults to [-1..1] in both axes.
28
+ * (These are in the same -1..1 coordinate space as `x`/`y`.)
29
+ */
30
+ bounds?: Partial<GradientMotionBounds>;
31
+ /**
32
+ * Random mode only: if > 0, choose random targets within this radius around the point's
33
+ * base `x`/`y` (then clamp to bounds). If omitted/0, choose targets anywhere in bounds.
34
+ */
35
+ randomRadius?: number;
36
+ };
37
+ export type GradientPoint = {
38
+ x: number;
39
+ y: number;
40
+ colors: string[];
41
+ speed?: number;
42
+ motion?: GradientMotion;
43
+ };
44
+ export type GradientPluginOptions = {
45
+ /** Defaults applied to any point that doesn't specify a `motion` field. */
46
+ defaultMotion?: GradientMotion;
47
+ };
48
+ export declare class GradientPlugin implements ShaderPlugin {
49
+ #private;
50
+ name: string;
51
+ private static MAX_POINTS;
52
+ fragmentShader: string;
53
+ uniforms: any;
54
+ private pointsConfig;
55
+ private colorStates;
56
+ private motionStates;
57
+ private defaultMotion;
58
+ constructor(points: GradientPoint[], options?: GradientPluginOptions);
59
+ onRender(dt: number): void;
60
+ }
@@ -0,0 +1,21 @@
1
+ import { ShaderPlugin } from '../core/types';
2
+ export type GrainyFogConfig = {
3
+ firstColor: string;
4
+ secondColor: string;
5
+ backgroundColor: string;
6
+ grainAmount?: number;
7
+ speed?: number;
8
+ scale?: number;
9
+ octaves?: number;
10
+ lacunarity?: number;
11
+ gain?: number;
12
+ contrast?: number;
13
+ };
14
+ export declare class GrainyFogPlugin implements ShaderPlugin {
15
+ name: string;
16
+ fragmentShader: string;
17
+ uniforms: any;
18
+ private speed;
19
+ constructor(config: GrainyFogConfig);
20
+ onRender(dt: number): void;
21
+ }
@@ -0,0 +1,29 @@
1
+ import { ShaderPlugin } from '../core/types';
2
+ export type InkWashConfig = {
3
+ /** Paper/background color */
4
+ paperColor: string;
5
+ /** Ink/pigment color */
6
+ inkColor: string;
7
+ /** Overall pattern scale */
8
+ scale?: number;
9
+ /** Motion speed */
10
+ speed?: number;
11
+ /** Flow / warping amount */
12
+ flow?: number;
13
+ /** Contrast / punch of ink */
14
+ contrast?: number;
15
+ /** Granulation (pigment clumping) */
16
+ granulation?: number;
17
+ /** Vignette (0..1) */
18
+ vignette?: number;
19
+ /** Grain strength */
20
+ grainAmount?: number;
21
+ };
22
+ export declare class InkWashPlugin implements ShaderPlugin {
23
+ name: string;
24
+ fragmentShader: string;
25
+ uniforms: any;
26
+ private speed;
27
+ constructor(config: InkWashConfig);
28
+ onRender(dt: number): void;
29
+ }
@@ -0,0 +1,20 @@
1
+ import { ShaderPlugin } from '../core/types';
2
+ export type LiquidOrbConfig = {
3
+ color: string;
4
+ backgroundColor: string;
5
+ count?: number;
6
+ speed?: number;
7
+ gooeyness?: number;
8
+ edgeSoftness?: number;
9
+ };
10
+ export declare class LiquidOrbPlugin implements ShaderPlugin {
11
+ name: string;
12
+ private static MAX_ORBS;
13
+ fragmentShader: string;
14
+ uniforms: any;
15
+ private orbs;
16
+ private orbData;
17
+ private speedMultiplier;
18
+ constructor(config: LiquidOrbConfig);
19
+ onRender(dt: number): void;
20
+ }
@@ -0,0 +1,12 @@
1
+ import { ShaderPlugin } from '../core/types';
2
+ export type RetroGridConfig = {
3
+ gridColor: string;
4
+ backgroundColor: string;
5
+ speed?: number;
6
+ };
7
+ export declare class RetroGridPlugin implements ShaderPlugin {
8
+ name: string;
9
+ fragmentShader: string;
10
+ uniforms: any;
11
+ constructor(config: RetroGridConfig);
12
+ }
@@ -0,0 +1,30 @@
1
+ import { ShaderPlugin } from '../core/types';
2
+ export type SoftStarfieldConfig = {
3
+ /** Background gradient bottom/top */
4
+ backgroundBottom: string;
5
+ backgroundTop: string;
6
+ /** Star color (usually near-white) */
7
+ starColor?: string;
8
+ /** Star density multiplier */
9
+ density?: number;
10
+ /** Star size multiplier */
11
+ size?: number;
12
+ /** Twinkle amount */
13
+ twinkle?: number;
14
+ /** Nebula tint */
15
+ nebulaColor?: string;
16
+ /** Nebula strength */
17
+ nebula?: number;
18
+ /** Motion speed */
19
+ speed?: number;
20
+ /** Grain 0.. */
21
+ grainAmount?: number;
22
+ };
23
+ export declare class SoftStarfieldPlugin implements ShaderPlugin {
24
+ name: string;
25
+ fragmentShader: string;
26
+ uniforms: any;
27
+ private speed;
28
+ constructor(config: SoftStarfieldConfig);
29
+ onRender(dt: number): void;
30
+ }
@@ -0,0 +1,51 @@
1
+ import { ShaderPlugin } from '../core/types';
2
+ export type StainedGlassConfig = {
3
+ /** Background behind the glass (shows through a bit) */
4
+ backgroundColor: string;
5
+ /** Lead/edge color */
6
+ leadColor?: string;
7
+ /** Palette colors for glass cells */
8
+ colorA?: string;
9
+ colorB?: string;
10
+ colorC?: string;
11
+ colorD?: string;
12
+ /** Cell scale */
13
+ scale?: number;
14
+ /**
15
+ * Pattern variant (changes the underlying coordinate transform).
16
+ * - 0: classic
17
+ * - 1: crystal (anisotropic)
18
+ * - 2: radial-ish twist
19
+ */
20
+ variant?: 0 | 1 | 2;
21
+ /** Random seed (any number). Change this to get a different layout. */
22
+ seed?: number;
23
+ /**
24
+ * Site jitter 0..1
25
+ * - 0 => very regular cells
26
+ * - 1 => fully random Voronoi sites
27
+ */
28
+ jitter?: number;
29
+ /** Rotate the pattern in radians */
30
+ rotation?: number;
31
+ /** Edge thickness */
32
+ edgeWidth?: number;
33
+ /** Edge sharpness (higher = crisper lines) */
34
+ edgeSharpness?: number;
35
+ /** Glow along edges */
36
+ edgeGlow?: number;
37
+ /** Warp amount (0..1.5) */
38
+ distortion?: number;
39
+ /** Motion speed */
40
+ speed?: number;
41
+ /** Grain */
42
+ grainAmount?: number;
43
+ };
44
+ export declare class StainedGlassPlugin implements ShaderPlugin {
45
+ name: string;
46
+ fragmentShader: string;
47
+ uniforms: any;
48
+ private speed;
49
+ constructor(config: StainedGlassConfig);
50
+ onRender(dt: number): void;
51
+ }
@@ -0,0 +1,11 @@
1
+ export * from './GradientPlugin';
2
+ export * from './GrainyFogPlugin';
3
+ export * from './RetroGridPlugin';
4
+ export * from './LiquidOrbPlugin';
5
+ export * from './CausticsPlugin';
6
+ export * from './AuroraWavesPlugin';
7
+ export * from './SoftStarfieldPlugin';
8
+ export * from './ContourLinesPlugin';
9
+ export * from './DreamyBokehPlugin';
10
+ export * from './InkWashPlugin';
11
+ export * from './StainedGlassPlugin';