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

@chestnutlabs/gcode-renderer-2d

v0.4.0

Published

Low-resource Canvas 2D layer renderer for the Chestnut Labs G-code viewer (DD-014 / E8): an opt-in current/adjacent-layer 2D view over the existing ToolpathIR for low-GPU/low-memory/WebGL-blocked devices. No three, no framework.

Downloads

432

Readme

@chestnutlabs/gcode-renderer-2d

Low-resource Canvas 2D layer renderer for the Chestnut Labs G-code Preview toolpath stack (DD-014 / Epic E8).

An opt-in current/adjacent-layer 2D view over the existing ToolpathIR, for contexts where the default Three.js renderer is a poor fit: old / low-end mobile, embedded printer touchscreens (Fluidd/Mainsail-class UIs), and locked-down or WebGL-blocked browsers. One parse, one IR, a second lightweight view — no second parser path, no three, no framework. Per-segment color is single-sourced with the 3D renderer via @chestnutlabs/gcode-colors, so the two never disagree.

The memory ceiling is the point: drawing is bounded to the active (± adjacent, later phases) layer, never the whole model.

Status: E8 phases 1–3 done. Phase 1 (#212): the Canvas 2D core — draw one layer from the IR, honest color, fit-to-canvas. Phase 2 (#213): current-layer + adjacent "ghost" layers (dimmed preceding layers, adjacentLayers default 1 / floor 0) over one stable model frame. Phase 3 (#214): selectable from the viewer via <GcodePreview renderer="2d" /> (the 3D renderer is loaded on demand, so a 2D-only bundle never ships Three.js), plus a live-progress "completed cut" (setProgress). Still ahead: the low-resource benchmark + capability-honesty UX (#215).

Usage

import { LayerView2D } from '@chestnutlabs/gcode-renderer-2d';

const view = new LayerView2D(canvas, { colorMode: { mode: 'feature', palette, fallback: [0.7, 0.7, 0.7] } });
view.setToolpath(ir); // a ToolpathIR from the worker parser
view.setLayer(12);
view.render(); // clears + redraws the active layer

The drawing core is also exposed as pure functions — drawLayer(ctx, ir, opts), computeLayerFit, layerBounds2D, rgbToCss — which take a minimal Canvas-2D-context interface and are fully testable in Node with a recording mock.

Honesty

A flat per-layer 2D view cannot represent non-XY/CNC toolpaths or 3D-only options. A missing or out-of-range layer draws nothing and reports drawn: false rather than fabricating geometry. Color modes that read an optional IR channel (feature, object, feedrate) must be capability-gated by the caller. The full capability-honesty UX for non-XY / layers: unavailable inputs arrives with the phase-4 work (#215).

License

MIT © Chestnut Labs. See the repository for provenance and the full support policy.