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

@onemorestudio/drawing_utils

v1.0.0

Published

Drawing utilities for MediaPipe tasks-vision API with normalized coordinates support

Readme

@onemorestudio/drawingutils

Drawing utilities for MediaPipe tasks-vision API with normalized coordinates support.

This package provides a modern, lightweight alternative to the deprecated @mediapipe/drawing_utils package, designed specifically for the new @mediapipe/tasks-vision API.

Features

  • Normalized Coordinates - Works with MediaPipe's 0-1 coordinate system
  • Modern API - Compatible with @mediapipe/tasks-vision
  • Zero Dependencies - Pure JavaScript, no external dependencies
  • TypeScript Support - Full TypeScript definitions included
  • Multiple Models - Supports Hand, Pose, and Face landmarks
  • Lightweight - Minimal bundle size

Installation

npm install @onemorestudio/drawingutils

Usage

Basic Hand Tracking

import { HandLandmarker, FilesetResolver } from "@mediapipe/tasks-vision";
import {
  drawConnectors,
  drawLandmarks,
  HAND_CONNECTIONS,
} from "@onemorestudio/drawingutils";

// Setup MediaPipe
const vision = await FilesetResolver.forVisionTasks("./wasm");
const handLandmarker = await HandLandmarker.createFromOptions(vision, {
  baseOptions: {
    modelAssetPath: "./hand_landmarker.task",
    delegate: "GPU",
  },
  runningMode: "VIDEO",
  numHands: 2,
});

// In your render loop
const results = handLandmarker.detectForVideo(video, timestamp);

if (results.landmarks) {
  results.landmarks.forEach((landmarks) => {
    // Draw hand connections
    drawConnectors(ctx, landmarks, HAND_CONNECTIONS, {
      color: "#00FF00",
      lineWidth: 3,
    });

    // Draw hand landmarks
    drawLandmarks(ctx, landmarks, {
      color: "#FF0000",
      radius: 5,
      lineWidth: 2,
    });
  });
}

Pose Tracking

import { PoseLandmarker } from "@mediapipe/tasks-vision";
import {
  drawConnectors,
  drawLandmarks,
  POSE_CONNECTIONS,
} from "@onemorestudio/drawingutils";

// After getting pose results
if (results.landmarks) {
  results.landmarks.forEach((landmarks) => {
    drawConnectors(ctx, landmarks, POSE_CONNECTIONS, {
      color: "#00FFFF",
      lineWidth: 2,
    });

    drawLandmarks(ctx, landmarks, {
      color: "#FF00FF",
      radius: 4,
    });
  });
}

API Reference

Functions

drawLandmarks(ctx, landmarks, options)

Draw landmark points on canvas.

Parameters:

  • ctx (CanvasRenderingContext2D) - Canvas 2D context
  • landmarks (Array) - Array of landmark objects with x, y properties (normalized 0-1)
  • options (Object) - Drawing options
    • color (string) - Stroke color (default: "#FF0000")
    • fillColor (string) - Fill color (default: same as color)
    • radius (number) - Circle radius in pixels (default: 5)
    • lineWidth (number) - Stroke width (default: 2)

drawConnectors(ctx, landmarks, connections, options)

Draw connections between landmarks.

Parameters:

  • ctx (CanvasRenderingContext2D) - Canvas 2D context
  • landmarks (Array) - Array of landmark objects
  • connections (Array) - Array of [startIndex, endIndex] pairs
  • options (Object) - Drawing options
    • color (string) - Line color (default: "#00FF00")
    • lineWidth (number) - Line width (default: 2)

drawBoundingBox(ctx, boundingBox, options)

Draw a bounding box.

Parameters:

  • ctx (CanvasRenderingContext2D) - Canvas 2D context
  • boundingBox (Object) - Bounding box with normalized coordinates
    • originX (number) - X origin (0-1)
    • originY (number) - Y origin (0-1)
    • width (number) - Width (0-1)
    • height (number) - Height (0-1)
  • options (Object) - Drawing options
    • color (string) - Stroke color (default: "#00FF00")
    • lineWidth (number) - Line width (default: 2)
    • fillColor (string) - Fill color (optional)
    • fillOpacity (number) - Fill opacity 0-1 (default: 0.2)

drawLabel(ctx, text, position, options)

Draw a text label.

Parameters:

  • ctx (CanvasRenderingContext2D) - Canvas 2D context
  • text (string) - Text to draw
  • position (Object) - Position with normalized coordinates
    • x (number) - X position (0-1)
    • y (number) - Y position (0-1)
  • options (Object) - Drawing options
    • color (string) - Text color (default: "#FFFFFF")
    • font (string) - Font string (default: "16px Arial")
    • backgroundColor (string) - Background color (optional)
    • padding (number) - Background padding (default: 4)

Constants

HAND_CONNECTIONS

Array of hand landmark connection pairs for the 21-point hand model.

POSE_CONNECTIONS

Array of pose landmark connection pairs for the 33-point pose model.

FACE_MESH_TESSELATION

Array of face mesh connection pairs (simplified key contours).

Utility Functions

normalizedToCanvas(point, canvasWidth, canvasHeight)

Convert normalized coordinates (0-1) to canvas pixel coordinates.

canvasToNormalized(point, canvasWidth, canvasHeight)

Convert canvas pixel coordinates to normalized coordinates (0-1).

Examples

Custom Styling

// Neon style
drawConnectors(ctx, landmarks, HAND_CONNECTIONS, {
  color: "#00FFFF",
  lineWidth: 4,
});

drawLandmarks(ctx, landmarks, {
  color: "#FF00FF",
  fillColor: "#FFFFFF",
  radius: 6,
  lineWidth: 3,
});

With Bounding Box

if (results.landmarks && results.worldLandmarks) {
  // Draw bounding box
  const boundingBox = {
    originX: 0.2,
    originY: 0.2,
    width: 0.6,
    height: 0.6,
  };

  drawBoundingBox(ctx, boundingBox, {
    color: "#FFFF00",
    lineWidth: 3,
    fillColor: "#FFFF00",
    fillOpacity: 0.1,
  });
}

With Labels

results.landmarks.forEach((landmarks, index) => {
  drawConnectors(ctx, landmarks, HAND_CONNECTIONS);
  drawLandmarks(ctx, landmarks);

  // Add label
  drawLabel(ctx, `Hand ${index + 1}`, landmarks[0], {
    color: "#FFFFFF",
    font: "bold 18px Arial",
    backgroundColor: "#000000",
    padding: 6,
  });
});

Compatibility

  • Works with @mediapipe/tasks-vision v0.10.0+
  • Compatible with all modern browsers supporting Canvas API
  • Node.js 14.0.0+

Migration from @mediapipe/drawing_utils

The API is designed to be similar to the old @mediapipe/drawing_utils, but with support for normalized coordinates:

// Old (deprecated)
import { drawConnectors, drawLandmarks } from "@mediapipe/drawing_utils";
import { HAND_CONNECTIONS } from "@mediapipe/hands";

// New
import {
  drawConnectors,
  drawLandmarks,
  HAND_CONNECTIONS,
} from "@onemorestudio/drawingutils";

The main difference is that this package automatically handles the coordinate conversion from normalized (0-1) to canvas pixels.

License

MIT

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Support

For issues and questions, please open an issue on GitHub.