AnimationUpdated in v15

Splash Cursor

A fluid simulation that splashes colour where the pointer moves.

Installation

Import the class, and @use the entry point in your global styles: without it the component renders unstyled.

import { Component } from '@angular/core';
import { WrSplashCursor } from 'ngwr/bits/splash-cursor';

@Component({ imports: [WrSplashCursor] })
export class MyComponent {}
Angular adaptation of an effect by David Haz / reactbits.dev.

Playground

Move the pointer through the box, or turn on fullscreen to cover the page.

Move your mouse in here

<wr-splash-cursor [fullscreen]="false" [splatRadius]="0.2" [curl]="3" />

Customize

Rainbow
Color
Splat Radius
0.20
Curl
3
Fullscreen overlay

Gotchas

  • With fullscreen off, it fills the nearest positioned parent.
  • It draws nothing with prefers-reduced-motion or without WebGL.

API

NameDescriptionTypeDefault
fullscreenCover the viewport, or fill the nearest positioned parent.booleantrue
simResolutionVelocity / pressure grid resolution.number128
dyeResolutionDye texture resolution (visible detail).number1440
densityDissipationDye fade speed — higher, shorter trails.number3.5
velocityDissipationHow fast motion settles.number2
pressurePressure retained between frames.number0.1
pressureIterationsJacobi iterations for the pressure solve.number20
curlVorticity confinement — swirliness.number3
splatRadiusSplat size.number0.2
splatForceVelocity a pointer move injects.number6000
shadingPseudo-3D shading on the dye.booleantrue
colorUpdateSpeedHow fast the splat colour cycles.number10
rainbowCycle splat colours through the rainbow.booleantrue
colorFixed splat colour when rainbow is off.string'#ff0000'

See also