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

@ripl/canvas

v1.4.0

Published

Canvas 2D rendering context for Ripl

Readme

@ripl/canvas

npm license size

The Canvas 2D rendering context for Ripl: rasterizes the scene graph to an HTML <canvas> through CanvasRenderingContext2D.

Features

  • Ripl's default backend — implements the Context abstraction on the native Canvas 2D API, so the same drawing code also runs on SVG, the terminal or a custom context.
  • Device pixel ratio handled for you — the backing store scales with the display while every coordinate you author, every bounding box and every pointer payload stays in CSS pixels.
  • Native paint objects — CSS gradient and pattern strings in fill and stroke are parsed and cached into CanvasGradient and CanvasPattern instances, keyed so repeated paints reuse them.
  • Browser hit testingisPointInPath/isPointInStroke run against the browser's own implementation, under both fill rules.
  • Path2D cachingsupportsPathCaching is true here, so a shape whose state has not changed replays its built path instead of re-tracing it each frame.
  • Text along a path and full stroke/fill state: caps, joins, dashes, miter limit, shadows, filters and blend modes.
  • Snapshot export — PNG data URL, Blob object URL, or raw ImageData.

Installation

Most browser projects should install @ripl/web instead. It re-exports this package alongside @ripl/core and registers the browser platform bindings, which this context needs for text measurement and frame scheduling.

# npm
npm install @ripl/canvas

# yarn
yarn add @ripl/canvas

# pnpm
pnpm add @ripl/canvas

Quick start

import {
    createContext,
} from '@ripl/canvas';

import {
    createCircle,
} from '@ripl/core';

const context = createContext('.mount-element');

createCircle({
    fill: 'linear-gradient(135deg, #3a86ff, #8338ec)',
    cx: context.width / 2,
    cy: context.height / 2,
    radius: 50,
}).render(context);

Every context can snapshot its current output through export():

const snapshot = context.export();

const dataUrl = snapshot.toString(); // PNG data URL
const url = snapshot.toURL(); // PNG object URL
const image = await snapshot.toImage(); // ImageData

snapshot.release(); // revokes the object URL

Key API

| Export | What it does | | --- | --- | | createContext | Binds a CanvasContext to a selector, element or existing canvas | | CanvasContext | The context itself, for typing and subclassing | | CanvasPath | Path2D-backed path builder used by every element | | toCanvasGradient / toCanvasPattern | Paint-string conversion into native canvas paints | | rescaleCanvas | Resizes the backing store for a device pixel ratio |

Related packages

  • @ripl/web — the browser entry point, and what most projects should install
  • @ripl/core — the elements and scene graph this context draws
  • @ripl/svg — the same API, rendering to SVG instead
  • @ripl/3d — a 3D context built on this one

Documentation

Guides, live demos and the full API reference are at ripl.run/docs/core/contexts/canvas.

License

MIT