Class: PencilBrush

fabric.PencilBrush

new PencilBrush()

PencilBrush class
Source:

Extends

Members

color :String

Color of a brush
Type:
  • String
Inherited From:
Default Value:
  • rgb(0, 0, 0)
Source:

shadow :fabric.Shadow

Shadow object representing shadow of this shape. Backwards incompatibility note: This property replaces "shadowColor" (String), "shadowOffsetX" (Number), "shadowOffsetY" (Number) and "shadowBlur" (Number) since v1.2.12
Type:
Inherited From:
Source:

strokeDashArray :Array

Stroke Dash Array.
Type:
  • Array
Inherited From:
Source:

strokeLineCap :String

Line endings style of a brush (one of "butt", "round", "square")
Type:
  • String
Inherited From:
Default Value:
  • round
Source:

strokeLineJoin :String

Corner style of a brush (one of "bevel", "round", "miter")
Type:
  • String
Inherited From:
Default Value:
  • round
Source:

strokeMiterLimit :Number

Maximum miter length (used for strokeLineJoin = "miter") of a brush's
Type:
  • Number
Inherited From:
Default Value:
  • 10
Source:

width :Number

Width of a brush
Type:
  • Number
Inherited From:
Default Value:
  • 1
Source:

Methods

_finalizeAndAddPath()

On mouseup after drawing the path on contextTop canvas we use the points captured to create an new fabric path object and add it to the fabric canvas.
Source:

convertPointsToSVGPath(points) → {String}

Converts points to SVG path
Parameters:
Name Type Description
points Array Array of points
Source:
Returns:
SVG path
Type
String

createPath(pathData) → {fabric.Path}

Creates fabric.Path object to add on canvas
Parameters:
Name Type Description
pathData String Path data
Source:
Returns:
Path to add on canvas
Type
fabric.Path

initialize(canvas) → {fabric.PencilBrush}

Constructor
Parameters:
Name Type Description
canvas fabric.Canvas
Source:
Returns:
Instance of a pencil brush
Type
fabric.PencilBrush

onMouseDown(pointer)

Inovoked on mouse down
Parameters:
Name Type Description
pointer Object
Source:

onMouseMove(pointer)

Inovoked on mouse move
Parameters:
Name Type Description
pointer Object
Source:

onMouseUp()

Invoked on mouse up
Source:

setShadow(optionsopt) → {fabric.Object}

Sets shadow of an object
Parameters:
Name Type Attributes Description
options Object | String <optional>
Options object or string (e.g. "2px 2px 10px rgba(0,0,0,0.2)")
Inherited From:
Source:
Returns:
thisArg
Type
fabric.Object