weasel API - v0.8.0
    Preparing search index...

    Interface UsePenToolOptions<TPose>

    interface UsePenToolOptions<TPose> {
        adapter: {
            addNode: (pose: TPose) => string;
            setSelection: (ids: string[]) => void;
        };
        autoCommitOnClose?: boolean;
        autoSelect?: boolean;
        closeHitRadius?: number;
        snapPoint?: (p: { x: number; y: number }) => { x: number; y: number };
        wrapPath: (path: PolygonPath, opts: { closed: boolean }) => TPose;
    }

    Type Parameters

    • TPose
    Index

    Properties

    adapter: {
        addNode: (pose: TPose) => string;
        setSelection: (ids: string[]) => void;
    }

    Insert + select adapter.

    autoCommitOnClose?: boolean

    When true (default), clicking the first anchor to close a subpath commits immediately — the closed region renders with its fill right away. When false, the closed subpath stays in scratch so the user can start another subpath; commit then fires on Enter / tool-switch / ⌘-click / double-click, producing a compound path.

    autoSelect?: boolean

    Auto-select the new object after commit. Default true.

    closeHitRadius?: number

    Screen-px hit radius for "click first anchor to close". Default 8. Note: implemented in world space here (divided by view.scale at the call site); aligns with useSelectTool.handleHitRadius.

    snapPoint?: (p: { x: number; y: number }) => { x: number; y: number }

    Optional point snapper applied to every world-space coordinate the pen records or previews — anchor positions (corner clicks, smooth- drag base point), the rubber-band cursor, and the outgoing-handle target. Receives raw world coords; returns snapped world coords. Wire to gridSnapStrategy-style spacing via the consumer:

     snapPoint: (p) => ({
       x: Math.round(p.x / SPACING) * SPACING,
       y: Math.round(p.y / SPACING) * SPACING,
     })
    

    Pen state (anchor handles, etc.) is computed AFTER snapping so the visible geometry stays grid-aligned.

    wrapPath: (path: PolygonPath, opts: { closed: boolean }) => TPose

    Wrap a finished PolygonPath in the consumer's pose type.