Skip to content

@fabwcie/free-drawing / utils/arrow

utils/arrow ​

Variables ​

arrowheadNames ​

const arrowheadNames: Arrowhead[]

Defined in: packages/free-drawing/src/utils/arrow.ts:12

Heads of arrow ends, startHead and endHead attributes of arrows


arrowTypeNames ​

const arrowTypeNames: ArrowType[]

Defined in: packages/free-drawing/src/utils/arrow.ts:15

Paths of arrows, arrowType attribute of arrows (none for straight ones)


curveBend ​

const curveBend: 0.2 = 0.2

Defined in: packages/free-drawing/src/utils/arrow.ts:21

Bend of curved arrows without bend attribute, and least bend of a drawn one: distance of their middle from the straight line, in lengths of the arrow (positive on its left)


maxBend ​

const maxBend: 1.5 = 1.5

Defined in: packages/free-drawing/src/utils/arrow.ts:27

Largest bend given by the handle of a curved arrow

Functions ​

arrowheadAttrs() ​

arrowheadAttrs(heads): object

Defined in: packages/free-drawing/src/utils/arrow.ts:60

Attributes of the heads of an arrow: konva pointers kept for its box (space of heads)

Parameters

heads

Arrowheads

Head of each end

Returns

object

Attributes to set on the arrow

endHead

endHead: Arrowhead = end

pointerAtBeginning

pointerAtBeginning: boolean

pointerAtEnding

pointerAtEnding: boolean

startHead

startHead: Arrowhead = start


arrowheadSvg() ​

arrowheadSvg(arrow, atStart, fill, stroke): string

Defined in: packages/free-drawing/src/utils/arrow.ts:306

Head of an end of an arrow in an svg export, as drawn (see drawHead)

Parameters

arrow

Arrow

Exported arrow

atStart

boolean

Head of the start, else of the end

fill

string

Attribute of the color of filled heads ( fill="...", escaped: colors of files, links and other users)

stroke

string

Attributes of the stroke of the arrow (without dash)

Returns

string

Svg element of the head, empty without head


curveMiddle() ​

curveMiddle(start, end, bend): Vector2d

Defined in: packages/free-drawing/src/utils/arrow.ts:188

Middle of a curve between two points, bent on the left of the way from start to end

Parameters

start

Vector2d

Start of the arrow

end

Vector2d

End of the arrow

bend

number

Distance from the straight line in lengths of the arrow, negative on its right

Returns

Vector2d

Point the curve goes through


elbowDistance() ​

elbowDistance(arrow): number

Defined in: packages/free-drawing/src/utils/arrow.ts:179

Distance an elbow arrow keeps from its linked shapes: room for its heads on the straight part out of them

Parameters

arrow

Arrow

Elbow arrow

Returns

number

elbowMargin at least, more for big heads


getArrowheads() ​

getArrowheads(arrow): Arrowheads

Defined in: packages/free-drawing/src/utils/arrow.ts:45

Heads of the ends of an arrow: its startHead and endHead attributes, else the konva pointers of arrows of previous versions (triangle at the end)

Parameters

arrow

Arrow

Arrow of the drawing

Returns

Arrowheads

Head of each end


getArrowType() ​

getArrowType(arrow): ArrowType

Defined in: packages/free-drawing/src/utils/arrow.ts:72

Path of an arrow

Parameters

arrow

Arrow

Arrow of the drawing

Returns

ArrowType

Its arrowType attribute, straight without it


getBend() ​

getBend(arrow): number

Defined in: packages/free-drawing/src/utils/arrow.ts:157

Bend of a curved arrow

Parameters

arrow

Arrow

Arrow of the drawing

Returns

number

Its bend attribute, curveBend without it


getDrawnBend() ​

getDrawnBend(start, end, path): number

Defined in: packages/free-drawing/src/utils/arrow.ts:201

Bend of a curved arrow being drawn: on the side the pointer went, as far as it went (curveBend at least, maxDrawnBend at most), on the left when it went straight

Parameters

start

Vector2d

Start of the arrow

end

Vector2d

End of the arrow

path

Vector2d[]

Pointer positions since the drawing started

Returns

number

Bend of the arrow (see getBend)


getElbowMid() ​

getElbowMid(arrow): number | undefined

Defined in: packages/free-drawing/src/utils/arrow.ts:168

Position of the middle segment of an elbow arrow chosen with its handle

Parameters

arrow

Arrow

Arrow of the drawing

Returns

number | undefined

Its elbowMid attribute (distance from the middle between its ends), undefined: automatic


getHandlePoint() ​

getHandlePoint(arrow): Vector2d | null

Defined in: packages/free-drawing/src/utils/arrow.ts:281

Place of the handle of a selected arrow: middle point of a curve, middle of the middle segment of an elbow arrow

Parameters

arrow

Arrow

Arrow of the drawing

Returns

Vector2d | null

Point in coordinates of the arrow, null without handle (straight arrow, elbow of one corner)


routeArrow() ​

routeArrow(arrow, start, end, boxes?): void

Defined in: packages/free-drawing/src/utils/arrow.ts:237

Points of an arrow from its ends, by its path: straight line, curve through a point beside its middle (bend), elbow of horizontal and vertical lines leaving the sides of the linked shapes and going around them (see utils/elbow), its middle segment moved by elbowMid

Parameters

arrow

Arrow

Arrow (its arrowType, bend, elbowMid), points and tension set

start

Vector2d

Start of the arrow, in coordinates of the arrow

end

Vector2d

End of the arrow, in coordinates of the arrow

boxes?

EndBoxes = ...

Boxes of the shapes linked to the start and the end, in coordinates of the arrow (elbow arrows)

Returns

void


setupArrows() ​

setupArrows(node): void

Defined in: packages/free-drawing/src/utils/arrow.ts:146

Arrows of a drawing shape drawn with their heads (none, open, triangle, dot, bar): called when shapes are added or loaded (the drawing function is not saved)

Parameters

node

Node

Drawing shape or group

Returns

void


toVectors() ​

toVectors(points): Vector2d[]

Defined in: packages/free-drawing/src/utils/arrow.ts:225

Points of an arrow as vectors

Parameters

points

number[]

Flat list of coordinates (konva points)

Returns

Vector2d[]

Points