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
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 docsArchitecture
This is a yarn workspaces monorepo with two packages:
packages/perfect-freehand/- The published npm librarypackages/dev/- Development/example React app (Vite, runs on port 5420)
Library Core (packages/perfect-freehand/src/)
The library has a simple pipeline architecture:
getStroke()- Main entry point. Combines the two functions below.getStrokePoints()- Converts raw input points[x, y, pressure?]intoStrokePoint[]objects with computed vectors, distances, and running lengths. Handles streamlining/smoothing.getStrokeOutlinePoints()- TakesStrokePoint[]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 thinningtypes.ts- TypeScript interfaces (StrokeOptions,StrokePoint)
Key Options
The StrokeOptions interface controls stroke appearance:
size- Base diameter of strokethinning- How much pressure affects thickness (negative = thinner with pressure)smoothing- Edge softnessstreamline- Point interpolation amountsimulatePressure- Auto-calculate pressure from velocitystart/end- Tapering and cap options
Build & Tooling
- Library build: Rolldown (
packages/perfect-freehand/rolldown.config.mjs) - outputs dual CJS/ESM todist/ - 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)
Trending
Steady: 0 new projects took it in the last 4 weeks, none the 4 weeks before.thin data
Who's talking about steveruizok/perfect-freehand
- @desertthunder.dev“just so u have this on ur radar: github.com/steveruizok/...”Bluesky · Aug 25, 2026 · 2 likes
- steveruizok/perfect-freehand-dart“Is the elbow removal PR able to be ported to this library?”GitHub · Jan 19, 2024 · 2 reactions
- jgraph/drawio“pressure sensitivity on freehand sketches (tablet support)”GitHub · Nov 1, 2022 · 2 reactions
- dgmjs/dgmjs“Enhance freehand”GitHub · May 10, 2024 · 1 reactions
- tldraw/tldraw“perf: faster freehand lines”GitHub · Sep 19, 2022 · 1 reactions
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
- Jan 19, 2024Is the elbow removal PR able to be ported to this library? — steveruizok/perfect-freehand-dart2 reactions · 1 comment
- Nov 1, 2022pressure sensitivity on freehand sketches (tablet support) — jgraph/drawio2 reactions · 1 comment
- May 10, 2024Enhance freehand — dgmjs/dgmjs1 reaction
- Sep 19, 2022perf: faster freehand lines — tldraw/tldraw1 reaction · 1 comment
- Oct 27, 2026Bump the javascript group with 9 updates — Anonym0os/notak0 reactions
44 more on GitHub
- Oct 23, 2026Bump perfect-freehand from 1.2.0 to 1.2.3 — JohnsonDza/overdraw0 reactions · 1 comment
- Oct 21, 2026chore(deps): bump perfect-freehand from 1.2.0 to 1.2.3 in /shared-editing — FrauH0lle/mevedel0 reactions
- Oct 18, 2026Bump the npm-minor-patch group across 1 directory with 18 updates — earthtojake/text-to-cad0 reactions · 1 comment
- Oct 9, 2026chore(deps): bump the production-deps group across 1 directory with 19 updates — mosli-fight/mosaic0 reactions · 1 comment
- Oct 9, 2026chore(deps): bump the production-deps group with 20 updates — mosli-fight/mosaic0 reactions · 2 comments
- Sep 16, 2026Scale perfect-freehand's end-noise cutoff with stroke size — zsviczian/excalidraw0 reactions · 2 comments
- Aug 18, 2026chore(deps): bump perfect-freehand from 1.0.16 to 1.2.3 — charanquartz/excalidraw0 reactions · 1 comment
- Jul 27, 2026deps(web): bump the npm-all group across 1 directory with 15 updates — themadorg/bedrud0 reactions · 1 comment
- Jul 26, 2026Bump perfect-freehand from 1.2.2 to 1.2.3 — RunWield/runwield0 reactions
- Jul 22, 2026deps(web): bump the npm-all group across 1 directory with 14 updates — themadorg/bedrud0 reactions · 1 comment
- Jul 13, 2026deps(web): bump the npm-all group across 1 directory with 13 updates — themadorg/bedrud0 reactions · 1 comment
- Mar 12, 2026chore(deps):(deps): bump the dependencies-others group across 1 directory with 7 updates — ubichill/ubichill0 reactions · 1 comment
- Mar 6, 2026chore(deps):(deps): bump the dependencies-others group across 1 directory with 5 updates — ubichill/ubichill0 reactions · 1 comment
- Mar 5, 2026chore(deps):(deps): bump the dependencies-others group across 1 directory with 4 updates — ubichill/ubichill0 reactions · 1 comment
- Mar 1, 2026Bump the all-dependencies group across 1 directory with 33 updates — melina-studio/melina-studio0 reactions · 3 comments
- Feb 26, 2026fix(deps): bump perfect-freehand from 1.2.2 to 1.2.3 — opengovsg/FormSG0 reactions · 17 comments
- Feb 6, 2026chore(deps):(deps): bump the dependencies-others group with 2 updates — ubichill/ubichill0 reactions · 1 comment
- Feb 3, 2026chore(deps): bump perfect-freehand from 1.2.2 to 1.2.3 — ludovicm67/simple-whiteboard0 reactions · 1 comment
- Feb 1, 2026Bump the all-dependencies group in /apps/web with 25 updates — melina-studio/melina-studio0 reactions · 3 comments
- Sep 3, 2025Bump perfect-freehand from 1.0.16 to 1.2.2 — simsadam0427/excalidraw0 reactions · 1 comment
- Aug 19, 2025Investigate steveruizok/perfect-freehand — aaronland/fingerprint0 reactions
- Mar 7, 2025build(deps): bump perfect-freehand from 1.0.16 to 1.2.2 in /bbb-export-annotations — bigbluebutton/bigbluebutton0 reactions · 3 comments
- Oct 18, 2024build(deps): bump perfect-freehand from 1.2.0 to 1.2.2 — jauderho/excalidraw0 reactions · 3 comments
- Aug 2, 2024[Snyk] Upgrade perfect-freehand from 1.0.16 to 1.2.2 — YinghanFeng/drawio0 reactions
- Aug 2, 2024pressure sensitivity on freehand sketches (tablet support) — jgraph/drawio0 reactions · 1 comment
- Jun 24, 2024build(deps): bump perfect-freehand from 1.2.0 to 1.2.2 — vignesh-gupta/boardy0 reactions · 2 comments
- Jan 2, 2024Algorithms — hyrious/ink0 reactions · 4 comments
- Mar 1, 2023Sketch Block Update getSvgPathFromStroke — Automattic/block-experiments0 reactions
- Sep 25, 2022[Bug] Backtracking creates dots on end of lines — excalidraw/excalidraw0 reactions
- Sep 20, 2022chore(deps): bump perfect-freehand from 1.0.16 to 1.2.0 — LaoBan-ywcm/custom-excalidraw0 reactions · 1 comment
- Sep 11, 2022Bump perfect-freehand from 0.4.7 to 1.2.0 — rohit1309d/enthire0 reactions · 1 comment
- Sep 11, 2022chore(deps): bump perfect-freehand from 1.0.16 to 1.2.0 — CompuIves/excalidraw0 reactions · 1 comment
- Sep 11, 2022chore(deps): bump perfect-freehand from 1.0.16 to 1.2.0 — jauderho/excalidraw0 reactions · 2 comments
- Sep 11, 2022Bump perfect-freehand from 1.0.16 to 1.2.0 — WillCAI2020/excalidraw0 reactions · 1 comment
- Sep 11, 2022chore(deps): bump perfect-freehand from 1.0.6 to 1.2.0 — jai-dewani/excalidraw0 reactions · 1 comment
- Aug 25, 2022chore(deps): bump perfect-freehand from 1.0.16 to 1.1.0 — CompuIves/excalidraw0 reactions · 2 comments
- Aug 22, 2022Dots at end of strokes — TodePond/PaintPond0 reactions · 1 comment
- Jun 5, 2022Bump perfect-freehand from 1.0.16 to 1.1.0 — WillCAI2020/excalidraw0 reactions · 2 comments
- Jun 5, 2022chore(deps): bump perfect-freehand from 1.0.6 to 1.1.0 — jai-dewani/excalidraw0 reactions · 2 comments
- Jun 5, 2022chore(deps): bump perfect-freehand from 1.0.16 to 1.1.0 — jauderho/excalidraw0 reactions · 2 comments
- Jan 3, 2022Replace freehand — jgraph/drawio0 reactions
- Aug 8, 2021Check out the perfect-freehand tool, with perfect pen pressure — ctwhome/notesone0 reactions
- Apr 13, 2021Améliorer les tracés à la main — l-atelier-des-chercheurs/dodoc0 reactions · 4 comments
- Mar 14, 2021Add "perfect-freehand" library as a tool — theknarf-experiments/el-vectr0 reactions
On Bluesky · 1
- Aug 25, 2026just so u have this on ur radar: github.com/steveruizok/... — @desertthunder.dev2 likes and reposts · 1 reply
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.

