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
丢弃距离小于“decimate”像素的点
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”(数量)和“shadowBlur”(数量)从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 = "miter")
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: