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

textmode.contour.js

v0.1.0

Published

Scharr contour conversion plugin for textmode.js

Readme

textmode.contour.js

textmode.contour.js is an add-on library for textmode.js that registers a cell-space contour conversion mode. It converts image, video, texture, and overlay sources into directional line characters while preserving the usual textmode.js source controls for color, inversion, flips, rotation, and character selection.

Features

  • Add a contour conversion mode through the standard textmode.js plugin system
  • Map cell-space contour orientation to directional characters
  • Preserve characters(), charColorMode(), cellColorMode(), invert(), flipX(), flipY(), and charRotation()
  • Support ESM and UMD consumers with the same ContourConversionPlugin export

Installation

Prerequisites

  • textmode.js 0.16.0 or newer
  • A modern browser with WebGL2 support
  • Node.js 20.8.1+ and npm for ESM installation

UMD

<script src="https://cdn.jsdelivr.net/npm/textmode.js@latest/dist/textmode.umd.js"></script>
<script src="https://cdn.jsdelivr.net/npm/textmode.contour.js@latest/dist/textmode.contour.umd.js"></script>
const t = textmode.create({
	width: window.innerWidth,
	height: window.innerHeight,
	fontSize: 8,
	plugins: [ContourConversionPlugin],
});

t.setup(async () => {
	const image = await t.loadImage('photo.jpg');
	image.characters('-/|\\-/|\\');
	image.conversionMode('contour');
	image.charColorMode('fixed');
	image.charColor('#ffffff');
	image.cellColorMode('fixed');
	image.cellColor('#000000');
});

The UMD bundle exposes ContourConversionPlugin globally.

ESM

npm install textmode.js textmode.contour.js
import { textmode } from 'textmode.js';
import { ContourConversionPlugin } from 'textmode.contour.js';

const t = textmode.create({
	width: 800,
	height: 600,
	fontSize: 8,
	plugins: [ContourConversionPlugin],
});

Source API

Use the core conversionMode() API after installing the plugin:

source.characters('-/|\\-/|\\');
source.conversionMode('contour');

Use contour-specific setters when a source needs different detection parameters:

source.contourThreshold(0.12);
source.contourColorSensitivity(0.75);

These setters update per-source shader uniforms and invalidate the source conversion cache. They do not replace characters() or the core conversionMode('contour') call.

The mode uses cell-space marching squares over an adaptive scalar field. Each text cell picks the strongest local luminance, RGB, or alpha transition, extracts a single contour segment from the cell corners, and maps that segment to a directional glyph. This keeps filled-shape boundaries close to one cell thick without a separate thinning pass.

The mode detects color and luminance transitions. Thick stroked source artwork contains two real transitions, one on each side of the stroke, so use filled shapes or thinner source strokes when you want a single object contour.

The default character order is -/|\\-/|\\. It is interpreted as eight edge-tangent bins: horizontal, / diagonal, vertical, \ diagonal, then the opposite four directions. The shader derives this tangent from the adaptive scalar-field normal in screen coordinates before choosing a character.

Documentation

License

textmode.contour.js is licensed under the MIT License.