Overview
The WeaveStrokeNode class represents a multi-point continuous line or path on the Weave.js canvas. It is a versatile and essential node type for building tools like freehand drawing.
Built on top of Konva’s Shape class shape under the hood, the WeaveStrokeNode offers full control over the line’s geometry, style, and behavior—all synchronized in real time across users.
The class extends the WeaveNode class
TypeScript types
type WeaveNodeTransformerProperties = Konva.TransformerConfig;
type WeaveStrokeProperties = {
splineResolution: number; // Minimum subdivisions per curved spline span
splineTargetEdge: number; // Target rendered edge length, in canvas units
splineMaxSteps: number; // Upper bound on subdivisions for a single span
resamplingSpacing: number; // Spacing for resampling points
isEraser?: boolean; // Whether the stroke is an eraser
transform?: WeaveNodeTransformerProperties;
};
type WeaveStrokeNodeParams = {
config: Partial<WeaveStrokeProperties>;
};
type WeaveStrokePoint = {
x: number;
y: number;
pressure: number;
};
Parameters
For WeaveStrokeNodeParams:
| Property | Type | Required | Description |
|---|---|---|---|
|
|
Required |
Config parameters for the node. |
For WeaveStrokeProperties:
| Property | Type | Required | Default | Description |
|---|---|---|---|---|
|
|
|
Minimum number of subdivisions used for a curved span of the smoothed curve. Longer spans are subdivided further, by arc length, so that rendered smoothness does not depend on how far apart the recorded points happen to be. |
|
|
|
|
Target length, in canvas units, of a single rendered edge. Lower values produce a smoother silhouette at the cost of proportionally more rendered vertices. |
|
|
|
|
Upper bound on the subdivisions used for one span, so an unusually long span cannot inflate the vertex count without limit. |
|
|
|
|
Minimum spacing between the control points fed to the spline. Applied after simplification, so it mainly guards against duplicate and near-duplicate samples. |
|
|
|
|
Whether the stroke behaves as an eraser. |
|
|