# Shader gradient

An animated WebGL mesh gradient that fills its box.

Section: Effects / Light
Page: https://ui.heyramzi.com/components/shader-gradient
Import path: `@heyramzi/ui/effects/shader-gradient`

## Import

```ts
import { ShaderGradient } from "@heyramzi/ui/effects/shader-gradient";
```

## Demo

```svelte
<script lang="ts">
	import { ShaderGradient } from "@heyramzi/ui/effects/shader-gradient";
</script>

<div class="grid w-full max-w-2xl gap-4 sm:grid-cols-2">
	<div class="h-64 overflow-hidden rounded-2xl">
		<ShaderGradient class="size-full" />
	</div>
	<div class="h-64 overflow-hidden rounded-2xl">
		<ShaderGradient
			class="size-full"
			color1="#0f766e"
			color2="#a7f3d0"
			color3="#f5e9c8"
			bgColor="#042f2e"
			uSpeed={0.25}
			rotationZ={120}
		/>
	</div>
</div>
```

## API

| Prop | Type | Default | Notes |
| --- | --- | --- | --- |
| `class` | `string` |  |  |
| `color1` | `string` | `"#ff5005"` | Warm stop. Any CSS color, including `var(--token)`. Read at the left edge of the plane. |
| `color2` | `string` | `"#dbba95"` | Middle stop. Read at the right edge of the plane. |
| `color3` | `string` | `"#d0bce1"` | Cool stop. Mixed in by the noise displacement, so it rides the crests and troughs. |
| `bgColor` | `string` | `"#000000"` | Painted behind the mesh. The mesh covers the frame at the default camera, so it only shows at extreme angles. |
| `animate` | `boolean` | `true` | false freezes the field at `uTime`. Forced false when the visitor asks for reduced motion. |
| `brightness` | `number` | `1.2` | Ambient light. 1 is flat, above 1 lifts the whole field. |
| `cAzimuthAngle` | `number` | `180` | Camera azimuth in degrees. |
| `cPolarAngle` | `number` | `90` | Camera polar angle in degrees. |
| `cDistance` | `number` | `3.6` | Camera distance from the origin. |
| `fov` | `number` | `45` | Vertical field of view in degrees. |
| `positionX` | `number` | `-1.4` |  |
| `positionY` | `number` | `0` |  |
| `positionZ` | `number` | `0` |  |
| `rotationX` | `number` | `0` | Mesh rotation in degrees, applied in XYZ order. |
| `rotationY` | `number` | `10` |  |
| `rotationZ` | `number` | `50` |  |
| `uDensity` | `number` | `1.3` | Noise density. Higher packs more folds into the same plane. |
| `uSpeed` | `number` | `0.4` | Noise travel speed. |
| `uStrength` | `number` | `4` | Displacement amplitude. Drives how far color3 pushes into the mix. |
| `uTime` | `number` | `0` | Starting time offset in seconds. Two instances with different offsets never sit on the same frame. |
| `grain` | `boolean` | `true` | Halftone dot screen over the render. This is the upstream `grain` switch. |
| `grainRadius` | `number` | `2` | Halftone dot radius in device pixels. |
| `pixelDensity` | `number` | `1` | Render scale. 1 matches upstream and is enough for a gradient this smooth. |
