Extends
Members
color :String
Color of a brush
画笔的颜色
Type:
- String
- Inherited From:
- Default Value:
- rgb(0, 0, 0)
- Source:
decimate :Number
Discard points that are less than `decimate` pixel distant from each other
丢弃距离小于“抽取”像素的点
Type:
- Number
- Default Value:
- 0.4
- Source:
drawStraightLine :boolean
Draws a straight line between last recorded point to current pointer
Used for `shift` functionality
在上次记录的点与当前指针之间绘制直线
用于“shift”功能
Type:
- boolean
- Default Value:
- false
- Source:
limitedToCanvasSize :Boolean
When `true`, the free drawing is limited to the whiteboard size. Default to false.
当为“true”时,自由绘图将被限制在白板大小内。默认为false。
Type:
- Boolean
- Inherited From:
- Default Value:
- false
- 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
表示此形状的阴影的阴影对象。
向后不兼容注意:这个属性取代了"shadowColor" (String), "shadowOffsetX" (Number),
“shadowOffsetY”(Number)和“shadowBlur”(Number)自v1.2.12
Type:
- Inherited From:
- Source:
straightLineKey :'altKey'|'shiftKey'|'ctrlKey'|'none'|undefined|null
The event modifier key that makes the brush draw a straight line.
If `null` or 'none' or any other string that is not a modifier key the feature is disabled.
使画笔绘制直线的事件修饰符键。
如果' null '或'none'或任何其他不是修饰符键的字符串,则禁用该功能。
Type:
- 'altKey' | 'shiftKey' | 'ctrlKey' | 'none' | undefined | null
- 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
笔刷的最大斜接长度(用于strokeLineJoin = "斜接")
Type:
- Number
- Inherited From:
- Default Value:
- 10
- Source:
width :Number
Width of a brush, has to be a Number, no string literals
画笔的宽度,必须是数字,不能是字符串
Type:
- Number
- Inherited From:
- Default Value:
- 1
- Source:
Methods
_drawSegment(pointer)
Invoked inside on mouse down and mouse move
在鼠标下移和鼠标移动时调用
Parameters:
Name | Type | Description |
---|---|---|
pointer |
Object |
- Source:
_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.
在contextTop画布上绘制路径后点击鼠标
我们使用捕获的点来创建一个新的织物路径对象
并将其添加到织物画布中。
- Source:
convertPointsToSVGPath(points)
Converts points to SVG path
将点转换为SVG路径
Parameters:
Name | Type | Description |
---|---|---|
points |
Array | Array of points点数组 |
- Source:
Returns:
createPath() → {fabric.Path}
Creates fabric.Path object to add on canvas
创建织物。要添加到画布上的路径对象
Parameters:
Type | Description |
---|---|
- Source:
Returns:
Path to add on canvas
- Type
- fabric.Path
decimatePoints()
Decimate points array with the decimate value
使用十进制值抽取点数组
- Source:
initialize(canvas) → {fabric.PencilBrush}
Constructor
构造函数
Parameters:
Name | Type | Description |
---|---|---|
canvas |
fabric.Canvas |
- Source:
Returns:
Instance of a pencil brush
- Type
- fabric.PencilBrush
onMouseDown(pointer)
Invoked on mouse down
按下鼠标调用
Parameters:
Name | Type | Description |
---|---|---|
pointer |
Object |
- Source:
onMouseMove(pointer)
Invoked on mouse move
鼠标移动时调用
Parameters:
Name | Type | Description |
---|---|---|
pointer |
Object |
- Source:
onMouseUp()
Invoked on mouse up
鼠标向上调用
- Source: