@fabwcie/free-drawing / utils/recognition
utils/recognition
Functions
recognizeShape()
recognizeShape(
points,minSize?):RecognizedShape|null
Defined in: packages/free-drawing/src/utils/recognition.ts:243
Shape recognized in a freehand stroke: closed stroke near the outline of a rectangle, an ellipse, a triangle (pointing up) or a diamond in its box; open stroke as an arrow (straight shaft and head), or straight as a line
Parameters
points
Vector2d[]
Points of the stroke (pointer path), in drawing coordinates
minSize?
number = 0
Diagonal of the box of the stroke, at least (smaller strokes, as letters, are kept)
Returns
RecognizedShape | null
Shape recognized, null for another stroke
resample()
resample(
path,count,closed?):Vector2d[]
Defined in: packages/free-drawing/src/utils/recognition.ts:88
Points regularly spaced along a path
Parameters
path
Vector2d[]
Points of the path (2 at least)
count
number
Number of points
closed?
boolean = false
Last point joined to the first one
Returns
Vector2d[]
count points, the first one at the start of the path
simplifyPath()
simplifyPath(
path,tolerance):Vector2d[]
Defined in: packages/free-drawing/src/utils/recognition.ts:119
Path simplified (Ramer–Douglas–Peucker): points farther than a tolerance from the line between the kept ones
Parameters
path
Vector2d[]
Points of the path
tolerance
number
Distance of the points left out to the simplified path, at most
Returns
Vector2d[]
Points kept, both ends included