Skip to main content

Module handdraw

Module handdraw 

Source
Expand description

Recognize freehand strokes as lines, circles, arcs, or cubic Beziers.

Classification tolerances scale with the stroke’s bounding-box extent. Open strokes near their endpoint chord become lines. A good least-squares circle fit produces a circle for closed strokes or an arc for open strokes. The fallback cubic uses endpoints and samples at one-third and two-thirds of the stroke’s arc length.

Enums§

HandDrawShape
A recognized handdraw shape, in plane (u, v) coordinates. Point semantics match the solver’s geometry (line = [a, b], circle = [center, rim], arc = [center, start, end], bezier = [p0, c1, c2, p1]).

Functions§

emit_shape
Materialize a recognized HandDrawShape into doc: mint its points (endpoints snap to an existing PRE-STROKE point within snap_radius so a stroke drawn onto prior geometry coincides) and append the geometry (non-construction; the bezier fallback also adds its two dashed control-handle guide lines, matching the bezier tool). Never solves; the caller re-solves.
recognize
Classify a raw uv stroke into one recognized HandDrawShape. See the module docs for the tolerance rules. A stroke of fewer than 2 samples degenerates to a zero-length line (callers guard against tiny strokes before recognizing).
stroke_extent
The bounding-box diagonal of a uv stroke — the relative-tolerance scale (and the engine’s “too tiny to recognize” gauge).