Arrow
new Konva.Arrow(config)
Arrow constructor
Parameters
| Name | Type | Description |
|---|---|---|
| config | Object | |
| points | Array | Flat array of points coordinates. You should define them as [x1, y1, x2, y2, x3, y3]. |
| tension (optional) | Number | Higher values will result in a more curvy line. A value of 0 will result in no interpolation. The default is 0 |
| pointerLength | Number | Arrow pointer length. Default value is 10. |
| pointerWidth | Number | Arrow pointer width. Default value is 10. |
| pointerAtBeginning | Boolean | Do we need to draw pointer on beginning position?. Default false. |
| pointerAtEnding | Boolean | Do we need to draw pointer on ending position?. Default true. |
| fill (optional) | String | fill color |
| fillPatternImage (optional) | Image | fill pattern image |
| fillPatternX (optional) | Number | |
| fillPatternY (optional) | Number | |
| fillPatternOffset (optional) | Object | object with x and y component |
| fillPatternOffsetX (optional) | Number | |
| fillPatternOffsetY (optional) | Number | |
| fillPatternScale (optional) | Object | object with x and y component |
| fillPatternScaleX (optional) | Number | |
| fillPatternScaleY (optional) | Number | |
| fillPatternRotation (optional) | Number | |
| fillPatternRepeat (optional) | String | can be "repeat", "repeat-x", "repeat-y", or "no-repeat". The default is "no-repeat" |
| fillLinearGradientStartPoint (optional) | Object | object with x and y component |
| fillLinearGradientStartPointX (optional) | Number | |
| fillLinearGradientStartPointY (optional) | Number | |
| fillLinearGradientEndPoint (optional) | Object | object with x and y component |
| fillLinearGradientEndPointX (optional) | Number | |
| fillLinearGradientEndPointY (optional) | Number | |
| fillLinearGradientColorStops (optional) | Array | array of color stops |
| fillRadialGradientStartPoint (optional) | Object | object with x and y component |
| fillRadialGradientStartPointX (optional) | Number | |
| fillRadialGradientStartPointY (optional) | Number | |
| fillRadialGradientEndPoint (optional) | Object | object with x and y component |
| fillRadialGradientEndPointX (optional) | Number | |
| fillRadialGradientEndPointY (optional) | Number | |
| fillRadialGradientStartRadius (optional) | Number | |
| fillRadialGradientEndRadius (optional) | Number | |
| fillRadialGradientColorStops (optional) | Array | array of color stops |
| fillEnabled (optional) | Boolean | flag which enables or disables the fill. The default value is true |
| fillPriority (optional) | String | can be color, linear-gradient, radial-graident, or pattern. The default value is color. The fillPriority property makes it really easy to toggle between different fill types. For example, if you want to toggle between a fill color style and a fill pattern style, simply set the fill property and the fillPattern properties, and then use setFillPriority('color') to render the shape with a color fill, or use setFillPriority('pattern') to render the shape with the pattern fill configuration |
| stroke (optional) | String | stroke color |
| strokeWidth (optional) | Number | stroke width |
| fillAfterStrokeEnabled (optional) | Boolean | Should we draw fill AFTER stroke? Default is false. |
| hitStrokeWidth (optional) | Number | size of the stroke on hit canvas. The default is "auto" - equals to strokeWidth |
| strokeHitEnabled (optional) | Boolean | flag which enables or disables stroke hit region. The default is true |
| perfectDrawEnabled (optional) | Boolean | flag which enables or disables using buffer canvas. The default is true |
| shadowForStrokeEnabled (optional) | Boolean | flag which enables or disables shadow for stroke. The default is true |
| strokeScaleEnabled (optional) | Boolean | flag which enables or disables stroke scale. The default is true |
| strokeEnabled (optional) | Boolean | flag which enables or disables the stroke. The default value is true |
| lineJoin (optional) | String | can be miter, round, or bevel. The default is miter |
| lineCap (optional) | String | can be butt, round, or square. The default is butt |
| shadowColor (optional) | String | |
| shadowBlur (optional) | Number | |
| shadowOffset (optional) | Object | object with x and y component |
| shadowOffsetX (optional) | Number | |
| shadowOffsetY (optional) | Number | |
| shadowOpacity (optional) | Number | shadow opacity. Can be any real number between 0 and 1 |
| shadowEnabled (optional) | Boolean | flag which enables or disables the shadow. The default value is true |
| dash (optional) | Array | |
| dashEnabled (optional) | Boolean | flag which enables or disables the dashArray. The default value is true |
| x (optional) | Number | |
| y (optional) | Number | |
| width (optional) | Number | |
| height (optional) | Number | |
| visible (optional) | Boolean | |
| listening (optional) | Boolean | whether or not the node is listening for events |
| id (optional) | String | unique id |
| name (optional) | String | non-unique name |
| opacity (optional) | Number | determines node opacity. Can be any number between 0 and 1 |
| scale (optional) | Object | set scale |
| scaleX (optional) | Number | set scale x |
| scaleY (optional) | Number | set scale y |
| rotation (optional) | Number | rotation in degrees |
| offset (optional) | Object | offset from center point and rotation point |
| offsetX (optional) | Number | set offset x |
| offsetY (optional) | Number | set offset y |
| draggable (optional) | Boolean | makes the node draggable. When stages are draggable, you can drag and drop the entire stage by dragging any portion of the stage |
| dragDistance (optional) | Number | |
| dragBoundFunc (optional) | function |
Inherited from: Konva.Line
Own Methods
pointerLength(Length)
get/set pointerLength
Parameters:
Length(Number): of pointer of arrow. The default is 10.
Returns: Number
Example:
// get length
var pointerLength = line.pointerLength();
// set length
line.pointerLength(15);
pointerWidth(Width)
get/set pointerWidth
Parameters:
Width(Number): of pointer of arrow. The default is 10.
Returns: Number
Example:
// get width
var pointerWidth = line.pointerWidth();
// set width
line.pointerWidth(15);
pointerAtBeginning(Should)
get/set pointerAtBeginning
Parameters:
Should(Number): pointer displayed at beginning of arrow. The default is false.
Returns: Boolean
Example:
// get value
var pointerAtBeginning = line.pointerAtBeginning();
// set value
line.pointerAtBeginning(true);
pointerAtEnding(Should)
get/set pointerAtEnding
Parameters:
Should(Number): pointer displayed at ending of arrow. The default is true.
Returns: Boolean
Example:
// get value
var pointerAtEnding = line.pointerAtEnding();
// set value
line.pointerAtEnding(false);
Inherited Methods
closed(closed)
get/set closed flag. The default is false
Parameters:
closed(Boolean)
Returns: Boolean
Inherited from: Konva.Line#closed
Example:
// get closed flag
var closed = line.closed();
// close the shape
line.closed(true);
// open the shape
line.closed(false);
bezier(bezier)
get/set bezier flag. The default is false
Parameters:
bezier(Boolean)
Returns: Boolean
Inherited from: Konva.Line#bezier
Example:
// get whether the line is a bezier
var isBezier = line.bezier();
// set whether the line is a bezier
line.bezier(true);
tension(tension)
get/set tension
Parameters:
tension(Number): Higher values will result in a more curvy line. A value of 0 will result in no interpolation. The default is 0
Returns: Number
Inherited from: Konva.Line#tension
Example:
// get tension
var tension = line.tension();
// set tension
line.tension(3);
points(points)
get/set points array. Points is a flat array [x1, y1, x2, y2]. It is flat for performance reasons.
Parameters:
points(Array)
Returns: Array
Inherited from: Konva.Line#points
Example:
// get points
var points = line.points();
// set points
line.points([10, 20, 30, 40, 50, 60]);
// push a new point
line.points(line.points().concat([70, 80]));
getContext()
Inherited from: Konva.Shape#getContext
getCanvas()
Inherited from: Konva.Shape#getCanvas
hasShadow()
returns whether or not a shadow will be rendered
Returns: Boolean
Inherited from: Konva.Shape#hasShadow
hasFill()
returns whether or not the shape will be filled
Returns: Boolean
Inherited from: Konva.Shape#hasFill
hasStroke()
returns whether or not the shape will be stroked
Returns: Boolean
Inherited from: Konva.Shape#hasStroke
intersects(point)
determines if point is in the shape, regardless if other shapes are on top of it. Note: because this method clears a temporary canvas and then redraws the shape, it performs very poorly if executed many times consecutively. Please use the Konva.Stage#getIntersection method if at all possible because it performs much better
Parameters:
point(Object)point.x(Number)point.y(Number)
Returns: Boolean
Inherited from: Konva.Shape#intersects
getSelfRect()
return self rectangle (x, y, width, height) of shape. This method are not taken into account transformation and styles.
Returns: Object rect with {x, y, width, height} properties
Inherited from: Konva.Shape#getSelfRect
Example:
rect.getSelfRect(); // return {x:0, y:0, width:rect.width(), height:rect.height()}
circle.getSelfRect(); // return {x: - circle.width() / 2, y: - circle.height() / 2, width:circle.width(), height:circle.height()}