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

@rdna/dithwather-core

v0.0.1

Published

Pure JS dithering engine with classic algorithms

Readme

@dithwather/core

Pure JavaScript dithering engine with Bayer ordered dithering, gradient rendering, and color utilities.

Install

npm install @dithwather/core

Quick Start

Render a dithered gradient to ImageData

import { renderGradientDither, resolveGradient } from '@dithwather/core'

const gradient = resolveGradient(
  { type: 'linear', stops: [{ color: '#000000' }, { color: '#ffffff' }] },
  undefined,
  undefined
)

const imageData = renderGradientDither({
  gradient,
  algorithm: 'bayer4x4',
  width: 256,
  height: 256,
})

// imageData is a standard ImageData you can draw onto a <canvas>

Render a dithered gradient to a data URL

import { renderGradientToDataURL, resolveGradient } from '@dithwather/core'

const gradient = resolveGradient('linear', ['#000000', '#ffffff'], 90)

const dataURL = renderGradientToDataURL({
  gradient,
  algorithm: 'bayer8x8',
  width: 512,
  height: 256,
  pixelScale: 2,
})

document.getElementById('img').src = dataURL

Exports

Algorithms

| Export | Description | | --- | --- | | applyDither | Apply dithering to pixel data (auto-selects algorithm) | | applyBayerDither | Apply Bayer ordered dithering | | applyFloydSteinbergDither | Apply Floyd-Steinberg error diffusion | | getBayerMatrix | Get a Bayer threshold matrix by size | | isOrderedAlgorithm | Type guard for ordered algorithm strings | | BAYER_2X2, BAYER_4X4, BAYER_8X8 | Pre-computed Bayer matrices |

Gradients

| Export | Description | | --- | --- | | resolveGradient | Build a ResolvedGradient from shorthand or full config | | resolveStops | Auto-distribute stop positions | | renderGradientDither | Render dithered gradient to ImageData | | renderGradientToDataURL | Render dithered gradient to a data URL string | | gradientValue | Unified distance function (dispatches by type) | | linearGradientValue, radialGradientValue, ... | Per-type distance functions | | findStopSegment | Find which two stops a gradient value falls between |

Tiles

| Export | Description | | --- | --- | | getTileDataURL | Generate a repeating Bayer tile as a data URL | | getTileBits | Get raw tile bit pattern | | getTileSize | Get tile pixel dimensions | | thresholdToLevel | Map a 0-1 threshold to a discrete tile level | | clearTileCache | Free cached tile data URLs |

Utils

| Export | Description | | --- | --- | | hexToRgb / rgbToHex | Convert between hex strings and RGB objects | | luminance | Relative luminance of an RGB color | | lerpColor | Linearly interpolate between two RGB colors | | adjustBrightness | Shift brightness of an RGB color | | adjustContrast | Adjust contrast of an RGB color |

License

MIT