Skip to content
On this page

Arrow Shape

TIP

This class is a descendant of Line it also inherits all the options that Line provides.

TIP

This component also supports a return function

To create an arrow shape with fcanvas, we can instantiate a Arrow object.

In addition, this shape also provides a few other parameters:

Require Options

Inherit Line

NameTypeDescription
pointsMayBeRef<number[]>Flat array of points coordinates. You should define them as [x1, y1, x2, y2, x3, y3]

Inherit Shape

NameTypeDescription
xMayBeRef<number>offset x
yMayBeRef<number>offset y

Optional Options

NameTypeDefaultDescription
pointerLengthMayBeRef<number>10Arrow pointer length.
pointerWidthMayBeRef<number>10Arrow pointer width.
pointerAtBeginningMayBeRef<boolean>falseDo we need to draw pointer on beginning position?
pointerAtEndingMayBeRef<boolean>trueDo we need to draw pointer on ending position?

Inherit Line

NameTypeDefaultDescription
tensionMayBeRef<number>0Higher values will result in a more curvy line. A value of 0 will result in no interpolation.
closedMayBeRef<boolean>falseDefines whether or not the line shape is closed, creating a polygon or blob (quadraticCurveTo)
bezierMayBeRef<boolean>falseIf no tension is provided but bezier=true, we draw the line as a bezier using the passed points (bezierCurveTo)

Demo

ts
import { Stage, Layer, Arrow } from "fcanvas"

const stage = new Stage().mount("#app")
const layer = new Layer().addTo(stage)

const arrow = new Arrow({
  x: stage.size.width / 4,
  y: stage.size.height / 4,
  points: [0, 0, stage.size.width / 2, stage.size.height / 2],
  pointerLength: 20,
  pointerWidth: 20,
  fill: "black",
  stroke: "black",
  strokeWidth: 4
}).addTo(layer)

Released under the MIT License.