WeaveStrokeSingleNode
Stroke V2 node API Reference
Overview
The WeaveStrokeSingleNode class represents a single stroke line on the Weave.js canvas. It is a versatile and essential node type for building tools like freehand drawing. It supports also define tips for both stroke ends as:
- Arrow
- Circle
- Square
The class extends the WeaveNode class
Type
This node nodeType property value is stroke-single.
Import
import { WeaveStrokeSingleNode } from "@inditextech/weave-sdk";Instantiation
new WeaveStrokeSingleNode(params?: WeaveStrokeSingleNodeParams);TypeScript types
type WeaveStrokeSingleProperties = {
transform?: WeaveNodeTransformerProperties;
snapAngles: {
angles: number[]; // Angles for snapping in degrees
activateThreshold: number;
releaseThreshold: number;
};
};
type WeaveStrokeSingleNodeParams = {
config: Partial<WeaveStrokeSingleProperties>;
};
type WeaveStrokeSingleNodeTipSideKeys =
keyof typeof WEAVE_STROKE_SINGLE_NODE_TIP_SIDE;
type WeaveStrokeSingleNodeTipSide =
(typeof WEAVE_STROKE_SINGLE_NODE_TIP_SIDE)[WeaveStrokeSingleNodeTipSideKeys];Parameters
For WeaveStrokeSingleNodeParams:
| Prop | Type | Default |
|---|---|---|
config | Partial<WeaveStrokeSingleProperties> | - |
For WeaveStrokeSingleProperties:
| Prop | Type | Default |
|---|---|---|
transform? | object | check default values |
snapAngles.releaseThreshold? | number | 10 |
snapAngles.activateThreshold? | number | 5 |
snapAngles.angles? | number | 10 |
Default values
const WEAVE_STROKE_SINGLE_NODE_DEFAULT_CONFIG = {
snapAngles: {
angles: [0, 45, 90, 135, 180, 225, 270, 315],
activateThreshold: 5,
releaseThreshold: 10,
},
};