metaballs

Up to 20 coloured gooey balls drifting around the centre and merging into smooth organic shapes. The classic metaballs effect.

Preview

live

Install

npm
npm i @devmischief/shaders-svelte

Code

import { Metaballs } from '@devmischief/shaders-svelte';

<Metaballs
  width={1280}
  height={720}
  colors={['#ff006e', '#3a86ff', '#06d6a0', '#ffbe0b']}
  colorBack="#000000"
  count={10}
  size={0.83}
  scale={1}
  rotation={0}
  offsetX={0}
  offsetY={0}
  speed={1}
  fit="contain"
/>
			
			

Shader Props

6
namedescriptiontypevalues
colorsBall colors (up to 8).string[]hex / rgb
colorBackBackground color shown behind the balls.stringhex / rgba
countNumber of balls drifting around.number1 → 20
sizeSize of each ball. Higher values cause balls to merge into smoother organic shapes.number0 → 1
speedAnimation speed of the drifting balls.number0 → 3
fitHow the metaballs world is fit into the canvas.stringnone · cover · contain

Common Props

6
namedescriptiontypevalues
originXReference point for positioning width in the canvas.number0 → 1
originYReference point for positioning height in the canvas.number0 → 1
worldWidthVirtual width of the graphic before it's scaled to fit the canvas.number
worldHeightVirtual height of the graphic before it's scaled to fit the canvas.number
minPixelRatioMinimum pixel ratio used when rendering the shader (default 2).number
maxPixelCountMaximum pixel count the shader may process.number

built with mischief by devmischief

@devmischief/shaders-svelte