npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

dotimation

v0.7.3

Published

Animate anything with dots

Readme

dotimation

npm CI license

Animate anything with dots

Installation

bun add dotimation

Usage

import { Dotimation } from 'dotimation'

function Component() {
  return (
    <Dotimation
      item={{ type: 'text', data: 'Hello' }}
      width={256}
      height={256}
      backend="auto"          // 'auto' | 'webgpu' | 'webgl2' | 'canvas2d'
      motion={{ jitter: 0 }}  // calm/static once settled (see "Idle & performance")
    />
  )
}

Or let the component track its parent's size:

<div style={{ width: '100%', height: 400 }}>
  <Dotimation item={{ type: 'text', data: 'Hello' }} fill />
</div>

Props

| Prop | Required | Default | Description | |------|----------|---------|-------------| | item | yes | — | AnimateItem{ type: 'text', data, fontSize?, fontFamily?, textColor? } or { type: 'image', data, invert?, maxWidth?, maxHeight? } | | width | yes* | — | Canvas width in CSS pixels (omit both when using fill) | | height | yes | — | Canvas height in CSS pixels | | fill | no | — | Size to the parent box instead of width/height, tracked live via ResizeObserver | | ref | no | — | Ref to the underlying <canvas> element (React 19 ref-as-prop) | | ariaLabel | no | text content | Accessible name for the canvas (rendered with role="img"); supply one for image items | | className / style | no | — | Passed to the canvas (style excludes width/height — sizing is prop-driven) | | defaultFontFamily | no | 'sans-serif' | Fallback font when item.fontFamily is not set | | dots | no | — | Dot field appearance/sampling — see Dot field | | motion | no | — | Motion feel: shimmer, morph speed, damping, fade — see Motion feel | | backend | no | 'auto' | Rendering backend: 'auto' \| 'webgpu' \| 'webgl2' \| 'canvas2d' | | matching | no | 'swarm' | Particle-to-dot assignment on content change: 'swarm' is a chaotic cloud, 'nearest' pairs each particle with a nearby destination for a calmer, directed morph | | maxDpr | no | 2 | Density cap for the canvas backing store; raise for full sharpness on 3× displays | | reducedMotion | no | OS setting | Force reduced-motion behavior on/off; omit to follow prefers-reduced-motion | | onStats | no | — | (stats: { backend: 'webgpu' \| 'webgl2' \| 'canvas2d'; particles: number }) => void — fires on engine creation and each field update; reveals which backend 'auto' resolved to and the live particle count |

Dot field

dots (type DotOptions, exported from the package root) controls sampling and appearance. Every field is optional; out-of-range input is sanitized silently — clamped to the nearest valid value (or the default, for non-finite input) rather than thrown.

| Field | Default | Description | |-------|---------|--------------| | size | 1 | Dot footprint in CSS px (scales with devicePixelRatio — same visual size at every density), or 'hairline' for exactly 1 device pixel at any DPR (the crispest possible dots). Non-positive or non-finite numbers fall back to the default | | spacing | 2 | Sampling grid step in CSS px; larger = fewer, sparser dots. Floored at 1 | | threshold | 128 | Alpha cutoff (0–255) a source pixel must exceed to become a dot. Clamped to [0, 255] | | max | unbounded | Cap on total particles (uniform random subset after sampling); trades fidelity for performance |

<Dotimation
  item={{ type: 'text', data: 'Hello' }}
  width={256}
  height={256}
  dots={{ size: 1.5, spacing: 3, threshold: 100 }}
/>

Motion feel

motion (type MotionOptions, exported from the package root) controls the spring physics driving each morph and the idle shimmer. Every field is optional and sanitized silently.

| Field | Default | Description | |-------|---------|--------------| | jitter | 1 | Shimmer amplitude in px per physics step; 0 disables it — particles go still once a morph settles. Clamped to >= 0 | | settleTime | 0.85 | Seconds for a morph to converge. Floored at 0.2 (integrator stability) | | damping | 1 | Damping ratio: 1 = no overshoot, lower = bouncier. Clamped to [0.3, 1] | | fade | 2 | Opacity ease rate per second for fade-in/out |

A few tuned starting points:

// calm — gentle shimmer, slow, deliberate morphs
<Dotimation item={item} width={256} height={256} motion={{ jitter: 0.3, settleTime: 1.2 }} />

// snappy — default shimmer, fast morphs
<Dotimation item={item} width={256} height={256} motion={{ settleTime: 0.35 }} />

// bouncy — default shimmer/timing, springy overshoot
<Dotimation item={item} width={256} height={256} motion={{ damping: 0.5 }} />

Idle & performance

There is no idle prop — the rAF loop's lifetime is derived from motion.jitter:

  • jitter > 0 (the default): the shimmer never converges, so the loop keeps running for as long as the canvas is on-screen — gated by an IntersectionObserver, so a scrolled-away instance costs ~0%, and background tabs are throttled by the browser like any other requestAnimationFrame loop.
  • jitter === 0 (or reduced motion, which forces it): the loop stops shortly after the field settles — ~0% idle CPU — and wakes again automatically on the next content, size, or motion change.

Rendering backends

backend="auto" picks the best available tier — WebGPU (compute shader), then WebGL2 (transform feedback), then Canvas2D (always available). An explicit request pins the starting tier and keeps everything below it as fallback, so backend="webgpu" on a machine without WebGPU still gets WebGL2. All tiers render identically (same blending, device-pixel snapping, and dot sizing); onStats tells you which one is active.

Accessibility

The canvas renders with role="img". Text items get an accessible name from their content automatically; pass ariaLabel for image items (or to override). The component honors prefers-reduced-motion out of the box: morphs complete instantly and the idle shimmer is disabled, so content changes become short opacity fades with no movement. Use the reducedMotion prop to wire it to your app's own motion setting instead.

Web fonts

Text using a custom fontFamily that hasn't finished loading is rasterized with fallback metrics first, then automatically re-rasterized once the font arrives — no wiring needed.

Migrating from 0.6

0.7 groups the flat tuning props into dots and motion, and removes idle/canvasRef:

| 0.6 | 0.7 | | --- | --- | | dotSize={1.5} | dots={{ size: 1.5 }} | | pointSpacingCss={2} | dots={{ spacing: 2 }} | | alpha={128} | dots={{ threshold: 128 }} | | maxParticles={20000} | dots={{ max: 20000 }} | | idle="sleep" (freeze after settle) | motion={{ jitter: 0 }} (calm/static) | | idle="animate" | default behavior — remove the prop | | canvasRef={ref} | ref={ref} |

Contributing

Please see CONTRIBUTING.md for contribution guidelines.

License

MIT