Overview
The WeaveMeasureNode class represents visually the distance (scaled) between two points on a Weave.js canvas.
In order to render a scaled distance from pixels to real distance on the real world, it needs:
-
A measure unit, e.g. meters, centimeters, milimeters, or inches.
-
A reference measure. A distance you previously know based on the measure unit.
-
A reference distance. The distance between two points on the canvas that represent the reference
The class extends the WeaveNode class
TypeScript types
type WeaveMeasureNodeProperties = {
style: {
separationLine: {
padding: number;
strokeWidth: number;
dash: number[];
stroke: string;
};
text: {
padding: number;
fontSize: number;
fontFamily: string;
fill: string;
};
intersectionCircle: {
radius: number;
fill: string;
};
measureLine: {
stroke: string;
dash: number[];
strokeWidth: number;
};
handler: {
noSpaceSeparationMultiplier: number;
spaceSeparationMultiplier: number;
};
};
};
type WeaveMeasureNodeParams = {
config: DeepPartial<WeaveMeasureNodeProperties>;
};
Parameters
For WeaveMeasureNodeParams:
| Property | Type | Required | Description |
|---|---|---|---|
|
|
Required |
Config parameters for the node. |
For WeaveMeasureProperties:
| Property | Type | Required | Default | Description |
|---|---|---|---|---|
|
|
|
Defines the padding (in px) from the separator end to put the measure line |
|
|
|
|
Width of the separation line |
|
|
|
|
Defines the dashing properties of the separation line as Konva does |
|
|
|
|
Defines the line color |
|
|
|
|
Defines the padding from the measure line to the measure text |
|
|
|
|
Defines the measure text font size |
|
|
|
|
Defines the measure text font family |
|
|
|
|
Defines the measure text color |
|
|
|
|
Defines the intersection circle between the separator line and the measure line radius |
|
|
|
|
Defines the intersection circle between the separator line and the measure line color |
|
|
|
|
Defines the measure line color |
|
|
|
|
Defines the dashing properties of the measure line as Konva does |
|
|
|
|
Width of the measure line |
|
|
|
|
Multiplier of separation for the separation handler when the text doesn’t fit on the measure line space |
|
|
|
|
Multiplier of separation for the separation handler when the text fit on the measure line space |
Default values
const WEAVE_MEASURE_NODE_DEFAULT_CONFIG: WeaveMeasureNodeProperties = {
style: {
separationLine: {
padding: 0,
strokeWidth: 1,
dash: [],
stroke: "#FF3366",
},
text: {
padding: 10,
fontSize: 14,
fontFamily: "monospace",
fill: "#FF3366",
},
intersectionCircle: {
radius: 3,
fill: "#FF3366",
},
measureLine: {
stroke: "#FF3366",
dash: [4, 4],
strokeWidth: 1,
},
handler: {
noSpaceSeparationMultiplier: 2.5,
spaceSeparationMultiplier: 1.5,
},
},
};