Fuderu
Stable 1.5.3 canvas drawing engine for the web
Draw directly on the demo canvas and explore pressure-aware brush rendering and layer management.
What Makes Fuderu Special?β
Fuderu is designed for developers who want to build beautiful drawing experiences without the complexity of heavy graphics libraries. Whether you're building a simple sketch pad, a professional annotation tool, or a creative art application, Fuderu gives you the building blocks you need.
Fuderu 1.5.3 brings a complete, professional artist workstation to the browser: featuring Selection Tools (rectangle, ellipse, freehand lasso, and marching ants), Floating Interactive Transformations (move, rotate, scale, and flip with live handles), Cross-Layer & Cross-Document Clipboard Pipeline (cut, copy, paste), a serializable Operation Log & Action Replay Stream API (action:record, stroke:record, replay), first-class Document Persistence with automated schema migrations, layer-level Alpha Lock and Layer Lock, native scanline flood fill, shape primitives, raster text, and typed state event subscriptions.
π¨ Key Capabilitiesβ
Unlike general-purpose canvas libraries, Fuderu combines a standalone brush engine with a full layer compositing stack, artist tools, and document state system:
βοΈ Artist Tools: Selection, Transform & Clipboard (v1.5.0)β
- Selection Tools: Rectangular, elliptical, and freehand lasso selections with Boolean combine modes (
replace,add,subtract,intersect), animated marching ants rendering (renderSelectionOutline), and automatic tool clipping. - Transform Operations: Interactive floating transform sessions (
beginTransform,commitTransform,cancelTransform) with live resize handles, rotation handle stem, center pivot, and one-shot transformation helpers (translate,rotate,scale,flipHorizontal,flipVertical). - Clipboard Pipeline: Unified clipboard store (
ClipboardStore,copy,cut,paste) enabling raster selection and layer region transfers across layers and separate documents, with optional new layer creation, marquee wrapping, and system clipboard interoperability.
π Document Persistence APIβ
Export and import complete canvas state as versioned JSON containing dimensions, layer metadata, active selections, and serialized image data (exportDocument, importDocument), or export flattened PNG composition renders (exportPNG). Includes automatic forward schema migration (migrateDocument).
π Advanced Layer Stack & Alpha Lockβ
16 blend modes, opacity, visibility, layer reordering, Alpha Lock (restricting drawing/filling to existing non-transparent pixels), and Layer Lock (protecting layers against accidental edits or deletions).
πͺ£ Native Raster Operations & Shapesβ
Built-in scanline flood fill (floodFill), vector shape primitives (drawRectangle, drawEllipse, drawLine), raster text rendering (drawText), and pixel color sampling (getColorAt).
β‘ Reactive Event System & Timeline Historyβ
Subscribe to typed state events (change, stroke:start, stroke:end, layer:change, history:change, selection:change, transform:start, clipboard:copy) with immutable getSnapshot(), and navigate history timeline directly with canvas.history.goTo(index) or sparse memory patches.
π¬ Reliable Action Replay Stream & Artwork Reset (v1.5.3)β
Record every user interaction as a serializable action log and play it back programmatically at adjustable speeds (canvas.replay()), with synchronous point flushing (Brush.flush()), base layer identity preservation across resets (canvas.resetArtwork()), and active layer fallbacks for multiplayer or cross-canvas playback.
β¨ Smooth Interpolation & Adaptive Spacingβ
Natural-looking strokes that connect points intelligently, eliminating jagged lines using Bezier curve algorithms with adaptive brush stamp density for consistent texture at any drawing speed.
π±οΈ Pressure Sensitivity & Image Brushesβ
Real pen pressure support with intelligent mouse/touch simulation, plus PNG/WebP custom stamp tips with recoloring and rotation capabilities.
π§© Built for Integrationβ
Fuderu is deliberately framework-agnostic - use it with:
- βοΈ React
- π Vue
- π Svelte
- π Vanilla JS/TS
- β‘ Next.js
- π Plain HTML
What You'll Learnβ
This documentation is organized around the core experience that matters most for a first stable release:
- Create a canvas with the Canvas wrapper
- Work with layers for non-destructive composition and blend modes
- Tune brush behavior for pressure, spacing, and stroke dynamics
- Extend the experience with built-in modules when needed
Getting Started in 60 Secondsβ
Here's the fastest way to see Fuderu in action:
npm install fuderu
<canvas id="my-canvas" style="width: 600px; height: 400px"></canvas>
import { Canvas } from "fuderu";
const painter = new Canvas({
canvas: "#my-canvas",
document: {
width: 1200,
height: 800,
},
brush: {
color: "#2563eb",
size: 24,
spacing: 0.25,
},
});
// Start drawing immediately!
// Try changing colors, sizes, or try the eraser mode
painter.loadConfig({
color: "#dc2626",
size: 12,
});
π‘ Tip: Try pressing harder with your stylus (or moving your mouse faster/slower) to see pressure sensitivity in action!
Ready to Dive In?β
Start with our Quick Start tutorial to build your first drawing application, or jump straight to the feature that interests you most:
- Canvas API - High-level wrapper with built-in event handling
- Brush API - Low-level brush engine for custom integrations
- Layer System - Professional non-destructive editing
- Image Brushes - Stamp with custom textures
- Modules - Add special effects to your brushes
π Let's Get Started!
Head over to the Quick Start guide to build your first drawing application in just minutes!