agentleFS
steveruizoksteveruizok/perfect-freehand/CLAUDE.md

perfect-freehand

CLAUDE.md5.8k starsChanged 5 years agoMITView on GitHub

perfect-freehand is a TypeScript library for drawing pressure-sensitive freehand lines. It takes input points (from mouse/stylus) and generates polygon outline points that can be rendered as SVG paths or canvas shapes. This is a yarn workspaces monorepo with two packages: The library has a simple pipeline architecture: Supporting modules: The StrokeOptions interface controls stroke appearance:

Files
CLAUDE.md

CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

Project Overview

perfect-freehand is a TypeScript library for drawing pressure-sensitive freehand lines. It takes input points (from mouse/stylus) and generates polygon outline points that can be rendered as SVG paths or canvas shapes.

Commands

# Install dependencies (uses yarn workspaces)
yarn

# Start development server (runs both dev app and library watch)
yarn start

# Run all tests
yarn test

# Run tests in watch mode
yarn test:watch

# Run a single test file
yarn test packages/perfect-freehand/src/test/getStroke.spec.ts

# Run benchmarks
yarn bench

# Build the library
yarn build:packages

# Lint the library
cd packages/perfect-freehand && yarn lint

# Format code with Prettier
yarn format

# Check formatting without making changes
yarn format:check

# Generate API documentation
cd packages/perfect-freehand && yarn docs

Architecture

This is a yarn workspaces monorepo with two packages:

  • packages/perfect-freehand/ - The published npm library
  • packages/dev/ - Development/example React app (Vite, runs on port 5420)

Library Core (packages/perfect-freehand/src/)

The library has a simple pipeline architecture:

  1. getStroke() - Main entry point. Combines the two functions below.
  2. getStrokePoints() - Converts raw input points [x, y, pressure?] into StrokePoint[] objects with computed vectors, distances, and running lengths. Handles streamlining/smoothing.
  3. getStrokeOutlinePoints() - Takes StrokePoint[] and generates the final polygon outline points. Handles pressure simulation, tapering, caps, and sharp corner detection.

Supporting modules:

  • vec.ts - 2D vector math utilities (add, sub, mul, dist, per, etc.)
  • getStrokeRadius.ts - Calculates radius based on pressure and thinning
  • types.ts - TypeScript interfaces (StrokeOptions, StrokePoint)

Key Options

The StrokeOptions interface controls stroke appearance:

  • size - Base diameter of stroke
  • thinning - How much pressure affects thickness (negative = thinner with pressure)
  • smoothing - Edge softness
  • streamline - Point interpolation amount
  • simulatePressure - Auto-calculate pressure from velocity
  • start/end - Tapering and cap options

Build & Tooling

  • Library build: Rolldown (packages/perfect-freehand/rolldown.config.mjs) - outputs dual CJS/ESM to dist/
  • Dev app: Vite with React plugin
  • Task orchestration: lazyrepo (lazy.config.js)
  • Testing: Vitest with jsdom environment
  • Git hooks: Husky (pre-commit runs lint-staged, pre-push runs tests, commit-msg runs commitlint for conventional commits)

Download now (ZIP)

Trending

Steady: 0 new projects took it in the last 4 weeks, none the 4 weeks before.thin data

Week of Aug 30: 0 new projectsWeek of Sep 6: 0 new projectsWeek of Sep 13: 0 new projectsWeek of Sep 20: 0 new projectsWeek of Sep 27: 0 new projectsWeek of Oct 4: 0 new projectsWeek of Oct 11: 0 new projectsWeek of Oct 18: 0 new projects
Aug 2026Sep 2026Oct 2026
New projects taking a version of this file each week, over the 8 weeks our latest run read: only 0 in all, so this is a hint, not a trend.

Who's talking about steveruizok/perfect-freehand

The biggest 5 of 50 mentions linking to the repository that our crawl found. Each line is their own headline.

See all 50

Talked about on GitHub and Bluesky (50 times).

On GitHub · 49

44 more on GitHub

On Bluesky · 1

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

Reviews can't be read right now.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.