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

halftone-print

v0.1.0

Published

Turn any image into halftone dots on canvas — rotated screen, ink gain, jitter and noise for a printed look.

Readme

halftone-print

Turn any image into halftone dots on a canvas: a rotated screen with ink gain, positional jitter and size noise, for a printed rather than digital look. Works with SVG, PNG, JPEG, canvases, video frames — anything canvas can draw.

npm install halftone-print

Usage

import { loadImage, renderHalftone } from 'halftone-print';

const img = await loadImage('/logo.svg'); // URL or Blob (e.g. a File from an <input>)
const canvas = document.querySelector('canvas')!;
canvas.style.width = canvas.style.height = '240px';

renderHalftone(canvas, img, { width: 240, height: 240, color: '#5a7fb0', pitch: 2.2 });

Compose your own source first (text, multiple images) by drawing to a canvas and halftoning that:

const src = document.createElement('canvas');
// …draw anything onto src…
renderHalftone(canvas, src, { width: 300, height: 300, fit: 'fill', seed: 'my-tile' });

Need the dots rather than pixels (SVG export, animation, custom drawing)?

import { halftone, drawDots } from 'halftone-print';

const { dots } = halftone(img, { width: 200, height: 200 }); // packed [x, y, r, …] in CSS px
drawDots(ctx, dots, '#222');

Options

| Option | Default | | |---|---|---| | width, height | — | Output size in CSS px | | fit | 'contain' | 'contain', 'cover' or 'fill' | | pitch | 2.2 | Dot spacing in CSS px | | angle | 45 | Screen angle, degrees | | gain | 1.2 | Ink spread; > 1 lets solids close up | | minDot | 0.12 | Dots smaller than this fraction of pitch don't print | | jitter | 0.08 | Dot position wobble, fraction of pitch | | noise | 0.15 | Dot size wobble, fraction of radius | | seed | 1 | Number or string; same seed, same dots | | invert | false | Ink light areas instead of dark | | sampleScale | 2 | Source samples per CSS px | | color | '#000' | renderHalftone only | | dpr | devicePixelRatio (≤ 3) | renderHalftone only |

Ink density is alpha × (1 − luminance): dark, opaque pixels print; colour maps to tone (yellow barely prints). Dot area is proportional to the average density of its screen cell.

Notes

  • loadImage adds a size to SVGs without width/height, which Firefox otherwise refuses to draw to canvas.
  • Pitch is in CSS px so dots look the same physical size on every display; renderHalftone sizes the canvas backing store for the device pixel ratio.
  • The low-level maths (screenDots, densityFromRGBA, …) is pure and runs anywhere, including Node and workers.
  • Tested in Chromium, Firefox and WebKit.

Releasing

npm version patch   # or minor / major
git push --follow-tags

The tag triggers .github/workflows/publish.yml, which runs all tests and publishes via npm trusted publishing.

License

MIT