new IText() → {fabric.IText}
IText类(在v1.4中引入)事件也用"text:"触发:
在观察画布时使用前缀。
- Mixes In:
- Source:
- See:
-
-
fabric.IText#initialize for constructor definition
Supported key combinations:
Move cursor: left, right, up, down Select character: shift + left, shift + right Select text vertically: shift + up, shift + down Move cursor by word: alt + left, alt + right Select words: shift + alt + left, shift + alt + right Move cursor to line start/end: cmd + left, cmd + right or home, end Select till start/end of line: cmd + shift + left, cmd + shift + right or shift + home, shift + end Jump to start/end of text: cmd + up, cmd + down Select till start/end of text: cmd + shift + up, cmd + shift + down or shift + pgUp, shift + pgDown Delete character: backspace Delete word: alt + backspace Delete line: cmd + backspace Forward delete: delete Copy text: ctrl/cmd + c Paste text: ctrl/cmd + v Cut text: ctrl/cmd + x Select entire text: ctrl/cmd + a Quit editing tab or esc
Supported mouse/touch combination
Position cursor: click/touch Create selection: click/touch & drag Create selection: click & shift + click Select word: double click Select line: triple click
-
fabric.IText#initialize for constructor definition
Fires:
- event:changed
- selection:changed
- editing:entered
- editing:exited
Returns:
thisArg
- Type
- fabric.IText
Extends
Members
__corner :number|string|any
在鼠标移动期间保持最后一个悬停角的值。
0没有角,或者'mt', 'ml', 'mtr'等。
它应该是私人的,但把它当作
只读属性。
Type:
- number | string | any
- Inherited From:
- Default Value:
-
- 0
- Source:
_measuringContext :CanvasRenderingContext2D
引用上下文来测量文本字符或几个字符
如果对象不在画布上,则使用画布的cacheContext或新创建的cacheContext
一旦创建,它将在织物上被引用。_measuuringcontext避免为每一个创建画布
创建文本对象。
Type:
- CanvasRenderingContext2D
- Inherited From:
- Source:
_styleProperties :Array
定义样式单元('styles')的属性数组。
Type:
- Array
- Inherited From:
- Default Value:
-
-
["stroke","strokeWidth","fill","fontFamily","fontSize","fontWeight","fontStyle","underline","overline","linethrough","deltaY","textBackgroundColor"]
-
- Source:
absolutePositioned :boolean
只有当对象用作clipPath时才有意义。
如果为true,则clipPath的顶部和左侧相对于画布
不受对象变换的影响。这将使clipPath相对
到画布,但是只裁剪一个特定的对象。
警告:这是测试版,此功能可能会更改或重命名。
自从测试盒框
Type:
- boolean
- Inherited From:
- Default Value:
-
- false
- Source:
aCoords
在画布对象绝对坐标中描述对象的角位置
属性是tl,tr,bl,br和描述四个主要角。
每个属性都是一个对象,有x, y, Fabric.Point的实例。
坐标取决于以下属性:宽度,高度,scaleX, scaleY
skewX, skewY, angle, strokeWidth, top, left。
这些坐标对于了解物体的位置很有用。它们会更新
使用ocoord,但是当缩放或平移改变时,它们不需要更新。
坐标通过@method setcoord得到更新。
你可以使用@method calcACoords()计算它们而不需要更新;
- Inherited From:
- Source:
backgroundColor :String
对象的背景颜色。
取css颜色https://www.w3.org/TR/css-color-3/
Type:
- String
- Inherited From:
- Source:
borderColor :String
控制对象边界的颜色(当它处于活动状态时)
Type:
- String
- Inherited From:
- Default Value:
-
- rgb(178,204,255)
- Source:
borderDashArray :Array
指定对象边界的破折号模式的数组(hasBorder必须为true)
Type:
- Array
- Since:
-
- 1.6.2
- Inherited From:
- Source:
borderOpacityWhenMoving :Number
当物体处于活动和移动状态时,物体控制边界的不透明度
Type:
- Number
- Inherited From:
- Default Value:
-
- 0.4
- Source:
borderScaleFactor :Number
对象控制边界的比例因子
数字越大边框越粗
Border是1,这是边框的厚度
因为没有办法改变边界本身。
Type:
- Number
- Inherited From:
- Default Value:
-
- 1
- Source:
caching :Boolean
指示是否可以缓存内部文本字符宽度
Type:
- Boolean
- Default Value:
-
- true
- Source:
centeredRotation :Boolean
当为true时,该对象将使用中心点作为转换的原点
当通过控件旋转时。
向后不兼容注意:此属性取代"centerTransform"(布尔值)。
Type:
- Boolean
- Since:
-
- 1.3.4
- Inherited From:
- Default Value:
-
- true
- Source:
centeredScaling :Boolean
当为true时,该对象将使用中心点作为转换的原点
当通过控件缩放时。
向后不兼容注意:此属性取代"centerTransform"(布尔值)。
Type:
- Boolean
- Since:
-
- 1.3.4
- Inherited From:
- Source:
clipPath :fabric.Object
一个没有描边的fabricObject,用它们的形状定义一个裁剪区域。用黑色填充
clipPath对象在对象呈现完毕时使用,并且上下文被放置在中心位置
对象cacheccanvas。
如果您希望clipPath的0,0与对象中心对齐,请使用clipPath。originX/Y到'center'
Type:
- Inherited From:
- Source:
cornerColor :String
对象控制角的颜色(当它处于活动状态时)
Type:
- String
- Inherited From:
- Default Value:
-
- rgb(178,204,255)
- Source:
cornerDashArray :Array
指定对象控件的破折号模式的数组(hasBorder必须为true)
Type:
- Array
- Since:
-
- 1.6.2
- Inherited From:
- Source:
cornerStrokeColor :String
对象控制角的颜色(当它处于活动状态且为transparentCorners false时)
Type:
- String
- Since:
-
- 1.6.2
- Inherited From:
- Source:
ctrlKeysMapDown
用于键down + ctrl || cmd上的功能
- Source:
ctrlKeysMapUp
键up + ctrl || cmd的功能
- Source:
cursorColor :String
编辑模式下文本光标的颜色。
如果没有设置(默认)将从文本中获取颜色。
如果设置为织物可以理解的颜色值,它就会
用来代替当前位置文本的颜色。
Type:
- String
- Source:
cursorDelay :Number
光标闪烁间隔时间(毫秒)
Type:
- Number
- Default Value:
-
- 1000
- Source:
cursorDuration :Number
光标淡出时间(单位:ms)
Type:
- Number
- Default Value:
-
- 600
- Source:
cursorWidth :Number
光标宽度(单位:px)
Type:
- Number
- Default Value:
-
- 2
- Source:
direction :String
警告:实验。暂不支持
确定文本的方向。
这必须与textAlign和originX一起手动设置
体验。
未来会有一些有趣的联系
https://www.w3.org/International/questions/qa-bidi-unicode-controls
Type:
- String
- Since:
-
- 4.5.0
- Inherited From:
- Default Value:
-
- ltr
- Source:
dirty :Boolean
当设置为“true”时,对象的缓存将在下一次渲染调用中重新渲染。
自从1.7.0
Type:
- Boolean
- Inherited From:
- Default Value:
-
- true
- Source:
editable :Boolean
指示文本是否可以编辑
Type:
- Boolean
- Default Value:
-
- true
- Source:
editingBorderColor :String
文本对象在编辑模式时的边框颜色
Type:
- String
- Default Value:
-
- rgba(102,153,255,0.25)
- Source:
evented :Boolean
当设置为“false”时,对象不能成为事件的目标。所有事件都通过它传播。在v1.3.4中引入
Type:
- Boolean
- Inherited From:
- Default Value:
-
- true
- Source:
excludeFromExport :Boolean
当' true '时,object不会在object /JSON中导出
Type:
- Boolean
- Since:
-
- 1.6.3
- Inherited From:
- Source:
fill :String
物体填充的颜色
取css颜色https://www.w3.org/TR/css-color-3/
Type:
- String
- Inherited From:
- Default Value:
-
- rgb(0,0,0)
- Source:
fillRule :String
填充规则,用于填充对象
可接受的值是非零、偶奇
向后不兼容注意:此属性在v1.4.12之前用于设置globalCompositeOperation(使用' fabric. info ')。对象# globalCompositeOperation '而不是)
Type:
- String
- Inherited From:
- Default Value:
-
- nonzero
- Source:
fontStyle :String
字体样式。取值为“normal”、“italic”或“斜向”。
Type:
- String
- Inherited From:
- Default Value:
-
- normal
- Source:
fontWeight :Number|String
字体粗细(如粗体、正常、400、600、800)
Type:
- Number | String
- Inherited From:
- Default Value:
-
- normal
- Source:
globalCompositeOperation :String
用于画布的复合规则
Type:
- String
- Inherited From:
- Default Value:
-
- source-over
- Source:
hasBorders :Boolean
当设置为“false”时,不渲染对象的控制边界
Type:
- Boolean
- Inherited From:
- Default Value:
-
- true
- Source:
hasControls :Boolean
当设置为' false '时,对象的控件不显示,并且不能用于操作对象
Type:
- Boolean
- Inherited From:
- Default Value:
-
- true
- Source:
hiddenTextareaContainer :HTMLElement
DOM容器来附加hiddenTextarea。
附加到document.body的替代方法。
有助于减少整个文档的延迟重绘。主体树和
还有情态事件捕捉,它不会让文本区聚焦。
Type:
- HTMLElement
- Source:
includeDefaultValues :Boolean
当' false '时,默认对象的值不包含在其序列化中
Type:
- Boolean
- Inherited From:
- Default Value:
-
- true
- Source:
inCompositionMode
帮助确定文本何时处于合成状态,以便光标
渲染被改变了。
- Source:
inverted :boolean
只有当对象用作clipPath时才有意义。
如果为true,则该clipPath将使对象剪辑到clipPath的外部
自从测试盒框
Type:
- boolean
- Inherited From:
- Default Value:
-
- false
- Source:
isEditing :Boolean
指示文本是否处于编辑模式
Type:
- Boolean
- Source:
keysMap
键下的功能
将一个特殊的键映射到实例/原型的一个函数
如果您需要ESC或TAB或箭头的不同行为,则必须更改
这个映射设置了在fabric上构建的函数的名称。Itext或
你的原型。
地图的改变将影响所有的实例,除非你只需要一些文本实例
在这种情况下,你必须克隆这个对象并分配你的实例。
这一点。keysMap = fabric.util.object.clone(this.keysMap);
该函数必须在fabric. txt .prototype. myfunction中,并将作为参数接收事件[0]
- Source:
left :Number
对象的左侧位置。注意,默认情况下它是相对于左对象的。你可以通过设置originX={left/center/right}来改变它
Type:
- Number
- Inherited From:
- Source:
noScaleCache :Boolean
当为true时,缓存在扩展期间不会更新。如果缩放,这幅画会变得块状
太多,将在缩放结束时用正确的细节重新绘制。
此设置依赖于性能和应用程序。
默认为true
自从1.7.0
Type:
- Boolean
- Inherited From:
- Default Value:
-
- true
- Source:
objectCaching :Boolean
当为true时,对象被缓存在另一个画布上。
当' false '时,对象不缓存,除非必要(clipPath)
默认为true
Type:
- Boolean
- Since:
-
- 1.7.0
- Inherited From:
- Default Value:
-
- true
- Source:
oCoords
在画布元素坐标中描述对象的角位置。
属性依赖于控制键和填充主控件。
每个属性都是一个具有x, y和角的对象。
' corner '属性以类似的方式包含
角落的互动区域。
坐标依赖于控件positionHandler并被使用
绘制和定位控件
- Inherited From:
- Source:
originX :String
对象转换的水平原点(“左”、“右”、“中”之一)
请参阅http://jsfiddle.net/1ow02gea/244/了解originX/originY如何影响组中的对象
Type:
- String
- Inherited From:
- Default Value:
-
- left
- Source:
originY :String
对象变换的垂直原点(“顶”、“底”、“中”之一)
请参阅http://jsfiddle.net/1ow02gea/244/了解originX/originY如何影响组中的对象
Type:
- String
- Inherited From:
- Default Value:
-
- top
- Source:
paintFirst :String
确定是先绘制填充还是描边("fill"或"stroke"中的一个)
Type:
- String
- Inherited From:
- Default Value:
-
- fill
- Source:
path :fabric.Path
织物。文本应该遵循的路径。
从4.6.0开始,路径将自动绘制。
如果你想让路径可见,给它一个stroke和strokeWidth或fill值
如果你想隐藏它,给路径指定visible = false。
该特性还处于BETA阶段,目前还不支持SVG导入/导出。
Type:
- Inherited From:
- Source:
Example
var textPath = new fabric.Text('Text on a path', {
top: 150,
left: 150,
textAlign: 'center',
charSpacing: -50,
path: new fabric.Path('M 0 0 C 50 -100 150 -100 200 0', {
strokeWidth: 1,
visible: false
}),
pathSide: 'left',
pathStartOffset: 0
});
pathAlign :String
文本如何与路径对齐。这个属性决定了
每个字符相对于路径的垂直位置。
(“基线”、“中心”、“上升点”、“下降点”之一)
此功能处于BETA测试阶段,其行为可能会发生变化
Type:
- String
- Inherited From:
- Default Value:
-
- baseline
- Source:
perPixelTargetFind :Boolean
当设置为“true”时,对象是按像素在画布上“找到”的,而不是根据边界框
Type:
- Boolean
- Inherited From:
- Source:
selectable :Boolean
当设置为“false”时,不能选择对象进行修改(使用基于点点击或基于组的选择)。
但事件仍在发生。
Type:
- Boolean
- Inherited From:
- Default Value:
-
- true
- Source:
selectionBackgroundColor :String
选择对象的背景颜色。当对象处于活动状态时,它后面的彩色图层。
不能很好地与globalCompositeOperation方法混合使用。
Type:
- String
- Inherited From:
- Source:
selectionColor :String
文本选择的颜色
Type:
- String
- Default Value:
-
- rgba(17,119,255,0.3)
- Source:
selectionEnd :Number
文本选择结束的索引
Type:
- Number
- Source:
selectionStart :Number
索引文本选择开始的位置(或者没有选择时光标所在的位置)
Type:
- Number
- Source:
shadow :fabric.Shadow
表示此形状的阴影的阴影对象。
向后不兼容注意:此属性在v1.2.11之前被命名为"textShadow" (String)
Type:
- Inherited From:
- Source:
statefullCache :Boolean
当' true '时,将检查对象属性是否缓存无效。在某些方面
您可能希望禁用此功能的情况(喷雾刷,非常大,组)
或者如果您的应用程序不允许您修改您想要的组子的属性
为组禁用它。
默认为false
自从1.7.0
Type:
- Boolean
- Inherited From:
- Default Value:
-
- false
- Source:
stateProperties :Array
检查时要考虑的属性列表
对象的状态被改变(fabric. object# hasstatechange)
以及用于历史(撤销/重做)目的
Type:
- Array
- Inherited From:
- Source:
stroke :String
定义后,对象通过描边呈现,此属性指定其颜色。
向后不兼容注意:这个属性在v1.1.6之前被命名为“strokeStyle”
Type:
- String
- Inherited From:
- Source:
strokeLineCap :String
对象笔画的行尾样式(“尾”、“圆”、“方”之一)
Type:
- String
- Inherited From:
- Default Value:
-
- butt
- Source:
strokeLineJoin :String
对象描边的角样式("bevel", "round", "miter"之一)
Type:
- String
- Inherited From:
- Default Value:
-
- miter
- Source:
strokeMiterLimit :Number
对象笔画的最大斜接长度(用于strokeLineJoin = "斜接")
Type:
- Number
- Inherited From:
- Default Value:
-
- 4
- Source:
strokeUniform :Boolean
当为“false”时,斯托克宽度将随对象缩放。
当为true时,笔画将始终与输入笔画宽度的精确像素大小相匹配。
此属性不适用于使用strokeText,fillText方法的文本类或绘图调用
默认为false
Type:
- Boolean
- Since:
-
- 2.6.0
- Inherited From:
- Default Value:
-
- false
- Source:
subscript :Object
下标模式对象(最小重叠)
Type:
- Object
- Inherited From:
- Default Value:
-
-
{"size":0.6,"baseline":0.11}
-
- Source:
superscript :Object
上标模式对象(最小重叠)
Type:
- Object
- Inherited From:
- Default Value:
-
-
{"size":0.6,"baseline":""}
-
- Source:
textAlign :String
文本对齐。取值范围:left, center, right, justify,
"justify-left", "justify-center"或"justify-right"。
Type:
- String
- Inherited From:
- Default Value:
-
- left
- Source:
top :Number
对象的顶部位置。注意,默认情况下它是相对于对象top的。你可以通过设置originY={top/center/bottom}来改变它
Type:
- Number
- Inherited From:
- Source:
transparentCorners :Boolean
当为true时,对象的控制角被渲染为透明的内部(即描边而不是填充)
Type:
- Boolean
- Inherited From:
- Default Value:
-
- true
- Source:
type :String
对象的类型
Type:
- String
- Overrides:
- Default Value:
-
- i-text
- Source:
Methods
(static) fromObject(object, callbackopt)
返回织物。对象表示的ittext实例
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
object |
Object | 对象以从中创建实例 | |
callback |
function |
<optional> |
以新实例作为参数调用 |
- Source:
_calcRotateMatrix() → {Array}
计算对象的旋转矩阵
- Inherited From:
- Source:
Returns:
rotation matrix for the object
- Type
- Array
_calcTranslateMatrix() → {Array}
计算对象变换的平移矩阵
- Inherited From:
- Source:
Returns:
rotation matrix for the object
- Type
- Array
_drawClipPath(ctx, clipPath)
准备clipPath状态和缓存,并在实例的缓存上绘制它
Parameters:
Name | Type | Description |
---|---|---|
ctx |
CanvasRenderingContext2D | |
clipPath |
fabric.Object |
- Inherited From:
- Source:
_getCoords(absolute) → {Object}
返回交点的正确坐标集
这将返回acoord或linecoord。
Parameters:
Name | Type | Description |
---|---|---|
absolute |
Boolean | 如果为true或lineCoords |
- Inherited From:
- Source:
Returns:
{tl, tr, br, bl} points
- Type
- Object
_getFontDeclaration(styleObjectopt) → {String}
返回画布上下文的字体声明字符串
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
styleObject |
Object |
<optional> |
对象 |
- Inherited From:
- Source:
Returns:
font declaration formatted for canvas context.
- Type
- String
_getSelectionForOffset(e, isRight) → {Number}
私人
帮助查找是否应该从开始或结束计算偏移量
Parameters:
Name | Type | Description |
---|---|---|
e |
Event | 事件对象 |
isRight |
Boolean |
- Source:
Returns:
- Type
- Number
_getStyleDeclaration(lineIndex, charIndex) → {Object}
获取给定字符的样式对象的引用,而不是克隆
Parameters:
Name | Type | Description |
---|---|---|
lineIndex |
Number | |
charIndex |
Number |
- Inherited From:
- Source:
Returns:
style object
- Type
- Object
_limitCacheSize(dims) → {Object|Object|Object|Object}
限制缓存尺寸,使X * Y不跨越fabric.perfLimitSizeTotal
并且每条边都不跨越fabric.cacheSideLimit
这些数字是可配置的,因此您可以获得尽可能多的细节
与演出讨价还价。
Parameters:
Name | Type | Description |
---|---|---|
dims |
Object | 帆布宽度帆布高度zoomX缩放值用于在绘制缓存之前取消画布的缩放缩放值用于在绘制缓存之前取消画布的缩放 属性 名字 类型 描述 宽度 对象 帆布宽度 高度 对象 帆布高度 zoomX 对象 zoomX缩放值用于在绘制缓存之前取消画布的缩放 利用促镜拍摄的 对象 缩放值用于在绘制缓存之前取消画布的缩放 |
- Inherited From:
- Source:
Returns:
-
.width width of canvas
- Type
- Object
-
.height height of canvas
- Type
- Object
-
.zoomX zoomX zoom value to unscale the canvas before drawing cache
- Type
- Object
-
.zoomY zoomY zoom value to unscale the canvas before drawing cache
- Type
- Object
_measureLine(lineIndex) → {Object|Object}
测量一行的每个字素,填充__charBounds
Parameters:
Name | Type | Description |
---|---|---|
lineIndex |
Number |
- Inherited From:
- Source:
Returns:
-
object.width total width of characters
- Type
- Object
-
object.widthOfSpaces length of chars that match this._reSpacesAndTabs
- Type
- Object
_mouseDownHandler()
_mouseDown所需基本功能的默认事件处理程序
可以被重写以执行不同的操作。
此实现的范围是:查找点击位置,设置selectionStart
找到selectionEnd,初始化光标或选择区域的绘制
在文本区域初始化鼠标按下将取消织物的知识
当前compositionMode。它将被设置为false。
- Source:
_mouseDownHandlerBefore()
mousedown:before所需基本功能的默认事件处理程序
可以被重写以执行不同的操作。
这个实现的作用域是:当鼠标向下移动时,验证对象是否已经被选中
- Source:
_moveCursorLeftOrRight(direction, e)
向左或向右移动光标,触发事件
Parameters:
Name | Type | Description |
---|---|---|
direction |
String | “左”、“右” |
e |
Event | 事件对象 |
- Source:
_moveCursorUpOrDown(direction, e)
向上或向下移动光标,触发事件
Parameters:
Name | Type | Description |
---|---|---|
direction |
String | “上”或“下” |
e |
Event | 事件对象 |
- Source:
_renderControls(ctx, styleOverrideopt)
渲染对象的控件和边框
这里的上下文没有被转换
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
ctx |
CanvasRenderingContext2D | 要渲染的上下文 | |
styleOverride |
Object |
<optional> |
属性来覆盖对象样式 |
- Inherited From:
- Source:
_setupCompositeOperation(ctx)
为特定对象设置画布globalCompositeOperation
可以使用globalCompositeOperation属性指定特定对象的自定义组合操作
Parameters:
Name | Type | Description |
---|---|---|
ctx |
CanvasRenderingContext2D | 渲染画布上下文 |
- Inherited From:
- Source:
_splitTextIntoLines(text) → {Array}
将文本作为行数组返回。
Parameters:
Name | Type | Description |
---|---|---|
text |
String | 要分割的文本 |
- Inherited From:
- Source:
Returns:
Lines in the text
- Type
- Array
_toSVG(reviveropt) → {String}
返回实例的SVG表示形式
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
reviver |
function |
<optional> |
进一步解析svg表示的方法。 |
- Inherited From:
- Source:
Returns:
svg representation of an instance
- Type
- String
abortCursorAnimation()
中止光标动画并清除所有超时
- Source:
animate(property, value) → {fabric.Object|fabric.AnimationContext|Array.<fabric.AnimationContext>}
动画对象的属性
Parameters:
Name | Type | Description |
---|---|---|
property |
String | Object | 动画属性(if string)或动画属性(if object) |
value |
Number | Object | 动画属性的值(如果先给出字符串)或选项对象 |
- Inherited From:
- Source:
- Tutorials:
Returns:
-
thisArg
- Type
- fabric.Object
-
animation context (or an array if passed multiple properties) As object — multiple properties object.animate({ left: ..., top: ... }); object.animate({ left: ..., top: ... }, { duration: ... }); As string — one property object.animate('left', ...); object.animate('left', { duration: ... });
- Type
- fabric.AnimationContext | Array.<fabric.AnimationContext>
bringForward(intersectingopt) → {fabric.Object}
在绘制的对象堆栈中向上移动一个对象
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
intersecting |
Boolean |
<optional> |
如果' true ',则将对象发送到下一个上部相交对象的前面 |
- Inherited From:
- Source:
Returns:
thisArg
- Type
- fabric.Object
bringToFront() → {fabric.Object}
将一个对象移动到绘制对象堆栈的顶部
- Inherited From:
- Source:
Returns:
thisArg
- Type
- fabric.Object
calcOwnMatrix() → {Array}
计算表示从的当前变换的变换矩阵
对象的属性,这个矩阵不包括群变换
- Inherited From:
- Source:
Returns:
transform matrix for the object
- Type
- Array
calcTransformMatrix(skipGroupopt) → {Array}
计算表示从的当前变换的变换矩阵
对象的属性。
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
skipGroup |
Boolean |
<optional> |
返回对象的变换矩阵,不包括父变换 在某些情况下,这有助于避免假旋转。 |
- Inherited From:
- Source:
Returns:
transform matrix for the object
- Type
- Array
center() → {fabric.Object}
对象在最后添加到的画布上垂直和水平居中
你可能需要在定心之后在一个对象上调用setcoord来更新控件区域。
- Inherited From:
- Source:
Returns:
thisArg
- Type
- fabric.Object
centerH() → {fabric.Object}
将对象水平居中于最后添加到的画布上。
你可能需要在定心之后在一个对象上调用setcoord来更新控件区域。
- Inherited From:
- Source:
Returns:
thisArg
- Type
- fabric.Object
centerV() → {fabric.Object}
将对象垂直放置在最后添加到的画布上。
你可能需要在定心之后在一个对象上调用setcoord来更新控件区域。
- Inherited From:
- Source:
Returns:
thisArg
- Type
- fabric.Object
cleanStyle(property)
检查文本中的字符是否具有属性值
其值与该属性的文本框的值相匹配。如果是这样,
删除字符级属性。如果字符
没有其他属性,则也将其删除。最后,
如果包含该字符的行没有其他字符
然后它也被删除了。
Parameters:
Name | Type | Description |
---|---|---|
property |
string | 用于比较字符和文本的属性。 |
- Inherited From:
- Source:
clearContextTop()
准备和清洁contextTop
- Source:
clone(callback, propertiesToIncludeopt)
克隆一个实例,使用回调方法将适用于每个对象。
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
callback |
function | 使用克隆作为第一个参数调用回调 | |
propertiesToInclude |
Array |
<optional> |
您可能希望在输出中额外包含的任何属性 |
- Inherited From:
- Source:
cloneAsImage(callback, optionsopt) → {fabric.Object}
创建fabric实例。一个物体的图像
使用toCanvasElement。
一旦这个方法是基于toDataUrl和loadImage,那么它也有一个质量
和格式选项。toCanvasElement更快,并且不会产生质量损失。
如果您需要从对象中获取真正的Jpeg或Png,那么使用toDataURL是正确的方法。
toCanvasElement,然后从获得的画布toBlob也是一个不错的选择。
这个方法现在是同步的,但仍然支持回调,因为我们不想中断。
当计划发布fabricJS 5.0时,这可能会被更改为没有回调。
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
callback |
function | 回调,使用实例作为第一个参数调用 | |
options |
Object |
<optional> |
乘数乘以裁剪左偏移。在v1.2.14中引入裁剪顶部偏移。在v1.2.14中引入裁剪宽度。在v1.2.14中引入种植的高度。在v1.2.14中引入启用视网膜缩放克隆图像。1.6.4引入移除当前对象变换(无缩放、无角度、无翻转、无倾斜)。在2.3.4中引入移除当前对象阴影。2.4.2引入将克隆作为图像传递给toDataURL 属性 名字 类型 属性 默认的 描述 乘数 数量 1 乘数乘以 左 数量 裁剪左偏移。在v1.2.14中引入 前 数量 裁剪顶部偏移。在v1.2.14中引入 宽度 数量 裁剪宽度。在v1.2.14中引入 高度 数量 种植的高度。在v1.2.14中引入 enableRetinaScaling 布尔 启用视网膜缩放克隆图像。1.6.4引入 withoutTransform 布尔 移除当前对象变换(无缩放、无角度、无翻转、无倾斜)。在2.3.4中引入 withoutShadow 布尔 移除当前对象阴影。2.4.2引入 |
- Inherited From:
- Source:
Returns:
thisArg
- Type
- fabric.Object
containsPoint(point, linesopt, absoluteopt, calculateopt) → {Boolean}
检查point是否在对象内部
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
point |
fabric.Point | 指向核对 | |
lines |
Object |
<optional> |
从@method _getImageLines返回的对象 |
absolute |
Boolean |
<optional> |
使用不带viewportTransform的坐标 |
calculate |
Boolean |
<optional> |
使用当前位置的坐标而不是。ocoordinates |
- Inherited From:
- Source:
Returns:
true if point is inside the object
- Type
- Boolean
copy(e)
拷贝选定文本
Parameters:
Name | Type | Description |
---|---|---|
e |
Event | 事件对象 |
- Source:
doubleClickHandler()
默认处理程序为双击,选择一个单词
- Source:
drawBorders(ctx, styleOverride) → {fabric.Object}
绘制对象的边界框的边界。
需要公共属性:宽度,高度
需要公共选项:padding, borderColor
Parameters:
Name | Type | Description |
---|---|---|
ctx |
CanvasRenderingContext2D | 要借鉴的背景 |
styleOverride |
Object | 对象来覆盖对象样式 |
- Inherited From:
- Source:
Returns:
thisArg
- Type
- fabric.Object
drawBordersInGroup(ctx, options, styleOverride) → {fabric.Object}
当对象处于组中时,绘制对象的边界框的边界。
需要公共属性:宽度,高度
需要公共选项:padding, borderColor
Parameters:
Name | Type | Description |
---|---|---|
ctx |
CanvasRenderingContext2D | 要借鉴的背景 |
options |
object | 对象,表示当前对象参数 |
styleOverride |
Object | 对象来覆盖对象样式 |
- Inherited From:
- Source:
Returns:
thisArg
- Type
- fabric.Object
drawCacheOnCanvas(ctx)
在目标上下文中绘制对象的缓存副本。
Parameters:
Name | Type | Description |
---|---|---|
ctx |
CanvasRenderingContext2D | 要渲染的上下文 |
- Inherited From:
- Source:
drawClipPathOnCache(ctx, clipPath)
执行对象clipPath的绘图操作
Parameters:
Name | Type | Description |
---|---|---|
ctx |
CanvasRenderingContext2D | 要渲染的上下文 |
clipPath |
fabric.Object |
- Inherited From:
- Source:
drawControls(ctx, styleOverride) → {fabric.Object}
绘制对象边界框的角。
需要公共属性:宽度,高度
需要公共选项:cornerSize, padding
Parameters:
Name | Type | Description |
---|---|---|
ctx |
CanvasRenderingContext2D | 要借鉴的背景 |
styleOverride |
Object | 对象来覆盖对象样式 |
- Inherited From:
- Source:
Returns:
thisArg
- Type
- fabric.Object
drawObject(ctx)
在指定的上下文中对对象执行绘图操作
Parameters:
Name | Type | Description |
---|---|---|
ctx |
CanvasRenderingContext2D | 要渲染的上下文 |
- Inherited From:
- Source:
drawSelectionBackground(ctx) → {fabric.Object}
在对象后面的选择边界内绘制一个彩色图层。
需要公共选项:padding, selectionBackgroundColor
在转换上下文时调用此函数
当对象在静态画布上时,是否有检查要跳过
Parameters:
Name | Type | Description |
---|---|---|
ctx |
CanvasRenderingContext2D | 要借鉴的背景 |
- Inherited From:
- Source:
Returns:
thisArg
- Type
- fabric.Object
enterEditing() → {fabric.IText}
进入编辑状态
- Source:
Returns:
thisArg
- Type
- fabric.IText
exitEditing() → {fabric.IText}
退出编辑状态
- Source:
Returns:
thisArg
- Type
- fabric.IText
findLineBoundaryLeft(startFrom) → {Number}
根据当前选择索引查找表示当前行起始的新选择索引
Parameters:
Name | Type | Description |
---|---|---|
startFrom |
Number | 当前选择指标 |
- Source:
Returns:
New selection index
- Type
- Number
findLineBoundaryRight(startFrom) → {Number}
根据当前选择索引查找表示当前行结束的新选择索引
Parameters:
Name | Type | Description |
---|---|---|
startFrom |
Number | 当前选择指标 |
- Source:
Returns:
New selection index
- Type
- Number
findWordBoundaryLeft(startFrom) → {Number}
根据当前选择索引查找代表当前单词开头的新选择索引
Parameters:
Name | Type | Description |
---|---|---|
startFrom |
Number | 当前选择指标 |
- Source:
Returns:
New selection index
- Type
- Number
findWordBoundaryRight(startFrom) → {Number}
根据当前选择索引查找代表当前单词结尾的新选择索引
Parameters:
Name | Type | Description |
---|---|---|
startFrom |
Number | 当前选择指标 |
- Source:
Returns:
New selection index
- Type
- Number
fire(eventName, optionsopt) → {Self}
用可选的options对象触发事件
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
eventName |
String | 事件名称触发 | |
options |
Object |
<optional> |
选择对象 |
- Mixes In:
- Source:
Returns:
thisArg
- Type
- Self
forEachControl(fn)
为每个控件调用一个函数。函数被调用,
对于控件,调用迭代器的对象和控件的键
Parameters:
Name | Type | Description |
---|---|---|
fn |
function | 函数来迭代控件 |
- Inherited From:
- Source:
fromGraphemeToStringSelection()
将织物值转换为文本区域值
- Source:
fromStringToGraphemeSelection()
将文本区索引转换为字形索引
- Source:
fxStraighten(callbacks) → {fabric.Object}
与fabric. object .prototype.straight相同,但带有动画
Parameters:
Name | Type | Description |
---|---|---|
callbacks |
Object | 完成时调用在动画的每一步调用具有回调函数的对象 属性 名字 类型 属性 描述 onComplete 函数 完成时调用 onChange 函数 在动画的每一步调用 |
- Inherited From:
- Source:
Returns:
thisArg
- Type
- fabric.Object
get2DCursorLocation(selectionStartopt, skipWrappingopt)
返回光标(或选择开始)的2d表示形式(lineIndex和charIndex)
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
selectionStart |
Number |
<optional> |
可选的指数。如果未指定,则使用当前的selectionStart。 |
skipWrapping |
Boolean |
<optional> |
考虑打开的行的位置。用于管理样式。 |
- Inherited From:
- Source:
getBoundingRect(absoluteopt, calculateopt) → {Object}
返回对象的边界矩形的坐标(左,上,宽,高)
该框要与画布的轴线对齐。
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
absolute |
Boolean |
<optional> |
使用不带viewportTransform的坐标 |
calculate |
Boolean |
<optional> |
使用当前位置的坐标,而不是. ocoordinates / . acoord |
- Inherited From:
- Source:
Returns:
Object with left, top, width, height properties
- Type
- Object
getCompleteStyleDeclaration(lineIndex, charIndex) → {Object}
返回一个包含字符所有样式属性的新对象
返回的对象是新创建的
Parameters:
Name | Type | Description |
---|---|---|
lineIndex |
Number | 字符所在行的 |
charIndex |
Number | 字符在行中的位置 |
- Inherited From:
- Source:
Returns:
style object
- Type
- Object
getCoords() → {Array}
返回交点的正确坐标集
这将返回acoord或linecoord。
字符串以数组形式返回。
- Inherited From:
- Source:
Returns:
[tl, tr, br, bl] of points
- Type
- Array
getCurrentCharColor() → {String|fabric.Gradient|fabric.Pattern}
高级功能,知道光标的颜色。
currentChar是光标前面的那个
返回当前光标处char的颜色(填充)
如果文本对象具有填充符的模式或渐变,则返回该模式或渐变。
未使用的库,是为最终用户提供的
- Source:
Returns:
Character color (fill)
- Type
- String | fabric.Gradient | fabric.Pattern
getCurrentCharFontSize() → {Number}
高级函数,可以知道光标的高度。
currentChar是光标前面的那个
返回当前光标处char的字体大小
库中未使用的,是为最终用户准备的
- Source:
Returns:
Character font size
- Type
- Number
getDownCursorOffset(e, isRight) → {Number}
获取选定项的开始偏移量
Parameters:
Name | Type | Description |
---|---|---|
e |
Event | 事件对象 |
isRight |
Boolean |
- Source:
Returns:
- Type
- Number
getHeightOfChar(line, _char) → {Number}
计算给定位置字符的高度
Parameters:
Name | Type | Description |
---|---|---|
line |
Number | 行索引号 |
_char |
Number | 字符索引号 |
- Inherited From:
- Source:
Returns:
fontSize of the character
- Type
- Number
getHeightOfLine(lineIndex) → {Number}
计算lineIndex处的行高度
Parameters:
Name | Type | Description |
---|---|---|
lineIndex |
Number | 要计算的线的索引 |
- Inherited From:
- Source:
Returns:
- Type
- Number
getLocalPointer(e, pointeropt) → {Object}
返回指针相对于对象的坐标
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
e |
Event | 要操作的事件 | |
pointer |
Object |
<optional> |
要操作的指针(而不是事件) |
- Inherited From:
- Source:
Returns:
Coordinates of a pointer (x, y)
- Type
- Object
getObjectScaling() → {Object}
返回对象缩放因子计数以及组缩放
- Inherited From:
- Source:
Returns:
object with scaleX and scaleY properties
- Type
- Object
getPointByOrigin(originX, originY) → {fabric.Point}
返回对象的坐标,就好像它有不同的原点一样
Parameters:
Name | Type | Description |
---|---|---|
originX |
String | 水平原点:“左”、“中”或“右” |
originY |
String | 垂直原点:'top', 'center'或'bottom' |
- Inherited From:
- Source:
Returns:
- Type
- fabric.Point
getScaledHeight() → {Number}
返回计算转换的对象边界框的高度
在2.0之前,它被命名为getHeight();
- Inherited From:
- Source:
Returns:
height value
- Type
- Number
getScaledWidth() → {Number}
返回对象的边界框计数转换的宽度
在2.0之前,它被命名为getWidth();
- Inherited From:
- Source:
Returns:
width value
- Type
- Number
getSelectedText() → {String}
返回所选文本
- Source:
Returns:
- Type
- String
getSelectionStartFromPointer(e) → {Number}
返回与单击对象位置相对应的字符索引
Parameters:
Name | Type | Description |
---|---|---|
e |
Event | 事件对象 |
- Source:
Returns:
Index of a character
- Type
- Number
getSelectionStyles(startIndexopt, endIndexopt, completeopt) → {Array}
获取当前选定项/光标(在起始位置)的样式。
如果没有提供startIndex或endIndex,则使用selectionStart或selectionEnd。
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
startIndex |
Number |
<optional> |
启动索引以获取样式 |
endIndex |
Number |
<optional> |
获取样式的结束索引,如果没有指定selectionEnd或startIndex + 1 |
complete |
Boolean |
<optional> |
是否得到完整的风格 |
- Inherited From:
- Source:
Returns:
styles an array with one, zero or more Style objects
- Type
- Array
getSvgSpanStyles(style, useWhiteSpace) → {String}
返回svg-export的样式字符串
Parameters:
Name | Type | Description |
---|---|---|
style |
Object | 要从中检索样式属性的对象 |
useWhiteSpace |
Boolean | 布尔值,用于在样式中包含附加属性。 |
- Inherited From:
- Source:
Returns:
- Type
- String
getSvgStyles(skipShadow) → {String}
返回svg-export的样式字符串
Parameters:
Name | Type | Description |
---|---|---|
skipShadow |
Boolean | 跳过阴影过滤器输出的布尔值 |
- Inherited From:
- Source:
Returns:
- Type
- String
getSvgTextDecoration(style) → {String}
返回svg-export的文本装饰属性
Parameters:
Name | Type | Description |
---|---|---|
style |
Object | 要从中检索样式属性的对象 |
- Inherited From:
- Source:
Returns:
- Type
- String
getSvgTransform(use) → {String}
返回svg导出的转换字符串
Parameters:
Name | Type | Description |
---|---|---|
use |
Boolean | 完整的变换或者单个对象的变换。 |
- Inherited From:
- Source:
Returns:
- Type
- String
getTotalObjectScaling() → {Object}
返回对象缩放因子计数以及组缩放、缩放和视网膜
- Inherited From:
- Source:
Returns:
object with scaleX and scaleY properties
- Type
- Object
getUpCursorOffset(e, isRight) → {Number}
Parameters:
Name | Type | Description |
---|---|---|
e |
Event | 事件对象 |
isRight |
Boolean |
- Source:
Returns:
- Type
- Number
getValueOfPropertyAt(lineIndex, charIndex, property)
检索给定字符位置的属性值
Parameters:
Name | Type | Description |
---|---|---|
lineIndex |
Number | 行号 |
charIndex |
Number | 字符号 |
property |
String | 属性名 |
- Inherited From:
- Source:
Returns:
the value of 'property'
getViewportTransform() → {Array}
如果可能的话,从对象的画布中检索viewportTransform
- Inherited From:
- Source:
Returns:
- Type
- Array
hasFill()
如果对象要绘制填充,则返回true
不考虑文本样式。这只是在渲染时使用的快捷方式
我们希望它是一个近似值,而且要快。
为了避免额外的缓存,它必须在填充发生时返回true,
能以100%的几率猜出什么时候不会发生,错过了也没关系
一些用例中填充是不可见的。
- Since:
-
- 3.0.0
- Inherited From:
- Source:
Returns:
Boolean
hasStateChanged(propertySetopt) → {Boolean}
如果对象状态(它的状态属性之一)被改变,返回true
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
propertySet |
String |
<optional> |
要保存的属性集的可选名称 |
- Inherited From:
- Source:
Returns:
true if instance' state has changed since `fabric.Object#saveState` was called
- Type
- Boolean
hasStroke()
如果对象将绘制笔画,则返回true
不考虑文本样式。这只是在渲染时使用的快捷方式
我们希望它是一个近似值,而且要快。
为了避免额外的缓存,它必须在笔划发生时返回true,
能以100%的几率猜出什么时候不会发生,错过了也没关系
在某些用例中,笔画是不可见的。
- Since:
-
- 3.0.0
- Inherited From:
- Source:
Returns:
Boolean
initAddedHandler()
初始化“添加的”事件处理程序
- Source:
initBehavior()
初始化ittext的所有交互行为
- Source:
initClicks()
初始化双击和三重单击事件处理程序
- Source:
initCursorSelectionHandlers()
初始化与游标或选择相关的事件处理程序
- Source:
initDelayedCursor()
初始化延迟游标
- Source:
initDoubleClickSimulation()
初始化"dbclick"事件处理程序
- Source:
initHiddenTextarea()
初始化隐藏文本区域(需要在iOS中调出键盘)
- Source:
initialize(text, optionsopt) → {fabric.IText}
构造函数
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
text |
String | 文本字符串 | |
options |
Object |
<optional> |
选择对象 |
- Overrides:
- Source:
Returns:
thisArg
- Type
- fabric.IText
initMousedownHandler()
初始化"mousedown"事件处理程序
- Source:
initMouseMoveHandler()
初始化“mousmove”事件处理程序
- Source:
initMouseupHandler()
初始化“mouseup”事件处理程序
- Source:
insertChars(text, style, start, end)
在起始位置插入字符,在起始位置之前。
开始等于1,这意味着文本插入到实际字母0和1之间
如果提供了样式数组,它必须具有相同的字符长度的文本
如果提供了end且大于start,则替换旧文本。
开始/结束在_text数组中的每个字母位置。
Parameters:
Name | Type | Description |
---|---|---|
text |
String | 要插入的文本 |
style |
Array | 样式对象数组 |
start |
Number | |
end |
Number | 默认从+ 1开始 |
- Source:
insertCharStyleObject(lineIndex, charIndex, quantity, copiedStyle)
为给定的行/字符索引插入样式对象
Parameters:
Name | Type | Description |
---|---|---|
lineIndex |
Number | 直线的索引 |
charIndex |
Number | char的索引 |
quantity |
Number | 如果给定,要插入的样式对象 |
copiedStyle |
Array | 样式对象数组 |
- Source:
insertNewlineStyleObject(lineIndex, charIndex, qty, copiedStyle)
处理插入更多连续样式行,当一个或多个
将换行符添加到文本中。因为现在的风格需要改变
首先,我们改变当前所需的数轴样式,然后进行加法
从最后一行到第一行都是新的。
Parameters:
Name | Type | Description |
---|---|---|
lineIndex |
Number | 直线的索引 |
charIndex |
Number | char的索引 |
qty |
Number | 要添加的行数 |
copiedStyle |
Array | 对象样式数组 |
- Source:
insertNewStyleBlock(insertedText, start, copiedStyleopt)
插入样式对象
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
insertedText |
Array | 插入样式位置的字符 | |
start |
Number | 用于插入样式的游标索引 | |
copiedStyle |
Array |
<optional> |
要插入的样式对象的数组。 |
- Source:
intersectsWithObject(other, absoluteopt, calculateopt) → {Boolean}
检查对象是否与另一个对象相交
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
other |
Object | 测试对象 | |
absolute |
Boolean |
<optional> |
使用不带viewportTransform的坐标 |
calculate |
Boolean |
<optional> |
使用当前位置的坐标而不是。ocoordinates |
- Inherited From:
- Source:
Returns:
true if object intersects with another object
- Type
- Boolean
intersectsWithRect(pointTL, pointBR, absoluteopt, calculateopt) → {Boolean}
检查对象是否与由两点组成的区域相交
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
pointTL |
Object | 区域的左上角点 | |
pointBR |
Object | 区域的右下点 | |
absolute |
Boolean |
<optional> |
使用不带viewportTransform的坐标 |
calculate |
Boolean |
<optional> |
使用当前位置的坐标而不是。ocoordinates |
- Inherited From:
- Source:
Returns:
true if object intersects with an area formed by 2 points
- Type
- Boolean
isCacheDirty(skipCanvas)
检查缓存是否脏
Parameters:
Name | Type | Description |
---|---|---|
skipCanvas |
Boolean | 跳过画布检查,因为该对象已被绘制 在父画布上。 |
- Inherited From:
- Source:
isContainedWithinObject(other, absoluteopt, calculateopt) → {Boolean}
检查对象是否完全包含在另一个对象的区域内
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
other |
Object | 测试对象 | |
absolute |
Boolean |
<optional> |
使用不带viewportTransform的坐标 |
calculate |
Boolean |
<optional> |
使用当前位置的坐标而不是。ocoordinates |
- Inherited From:
- Source:
Returns:
true if object is fully contained within area of another object
- Type
- Boolean
isContainedWithinRect(pointTL, pointBR, absoluteopt, calculateopt) → {Boolean}
检查物体是否完全包含在由2个点组成的区域内
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
pointTL |
Object | 区域的左上角点 | |
pointBR |
Object | 区域的右下点 | |
absolute |
Boolean |
<optional> |
使用不带viewportTransform的坐标 |
calculate |
Boolean |
<optional> |
使用当前位置的坐标而不是。ocoordinates |
- Inherited From:
- Source:
Returns:
true if object is fully contained within area formed by 2 points
- Type
- Boolean
isControlVisible(controlKey) → {Boolean}
如果指定的控件可见则返回true,否则返回false。
Parameters:
Name | Type | Description |
---|---|---|
controlKey |
String | 控制键。可能的值是“tl”,“tr”,“品牌”,“提单”、“毫升”、“太”,“先生”,“m”,“地铁”。 |
- Inherited From:
- Source:
Returns:
true if the specified control is visible, false otherwise
- Type
- Boolean
isEmptyStyles(lineIndex) → {Boolean}
如果对象没有样式或一行中没有样式,则返回true
Parameters:
Name | Type | Description |
---|---|---|
lineIndex |
Number | lineIndex在换行行上。 |
- Inherited From:
- Source:
Returns:
- Type
- Boolean
isEndOfWrapping() → {Boolean}
检测文本行是否以硬分隔符结束
Text和ittext没有换行,返回false
- Inherited From:
- Source:
Returns:
- Type
- Boolean
isOnScreen(calculateopt) → {Boolean}
检查对象是否包含在当前viewportTransform的画布中
检查在屏幕上出现的第一个点停止
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
calculate |
Boolean |
<optional> |
使用当前位置的坐标而不是。acoord |
- Inherited From:
- Source:
Returns:
true if object is fully or partially contained within canvas
- Type
- Boolean
isPartiallyOnScreen(calculateopt) → {Boolean}
使用当前viewportTransform检查对象是否部分包含在画布中
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
calculate |
Boolean |
<optional> |
使用当前位置的坐标而不是。ocoordinates |
- Inherited From:
- Source:
Returns:
true if object is partially contained within canvas
- Type
- Boolean
isType(type) → {Boolean}
如果指定的类型与实例的类型相同,则返回true
Parameters:
Name | Type | Description |
---|---|---|
type |
String | 要检查的类型 |
- Inherited From:
- Source:
Returns:
- Type
- Boolean
measureLine(lineIndex) → {Number}
测量文本行,测量所有字符。
Parameters:
Name | Type | Description |
---|---|---|
lineIndex |
Number | 行号 |
- Inherited From:
- Source:
Returns:
Line width
- Type
- Number
missingNewlineOffset()
检测一行是否有换行,因此我们需要在移动时考虑它
还有计数风格。
它总是为text和ittext返回。
- Inherited From:
- Source:
Returns:
Number
moveCursorDown(e)
向下移动光标
Parameters:
Name | Type | Description |
---|---|---|
e |
Event | 事件对象 |
- Source:
moveCursorLeft(e)
向左移动光标
Parameters:
Name | Type | Description |
---|---|---|
e |
Event | 事件对象 |
- Source:
moveCursorLeftWithoutShift(e)
将光标向左移动而不保持选择
Parameters:
Name | Type | Description |
---|---|---|
e |
Event |
- Source:
moveCursorLeftWithShift(e)
在保持选择的同时向左移动光标
Parameters:
Name | Type | Description |
---|---|---|
e |
Event |
- Source:
moveCursorRight(e)
向右移动光标
Parameters:
Name | Type | Description |
---|---|---|
e |
Event | 事件对象 |
- Source:
moveCursorRightWithoutShift(e)
向右移动光标而不保持选择
Parameters:
Name | Type | Description |
---|---|---|
e |
Event | 事件对象 |
- Source:
moveCursorRightWithShift(e)
在保持选择的同时向右移动光标
Parameters:
Name | Type | Description |
---|---|---|
e |
Event |
- Source:
moveCursorUp(e)
向上移动光标
Parameters:
Name | Type | Description |
---|---|---|
e |
Event | 事件对象 |
- Source:
moveCursorWithoutShift(offset)
向上移动光标而不移位
Parameters:
Name | Type | Description |
---|---|---|
offset |
Number |
- Source:
moveCursorWithShift(offset)
用shift键移动光标
Parameters:
Name | Type | Description |
---|---|---|
offset |
Number |
- Source:
moveTo(index) → {fabric.Object}
将对象移动到绘制对象堆栈中的指定位置
Parameters:
Name | Type | Description |
---|---|---|
index |
Number | 物体的新位置 |
- Inherited From:
- Source:
Returns:
thisArg
- Type
- fabric.Object
needsItsOwnCache()
当设置为' true '时,强制对象拥有自己的缓存,即使它在一个组中
当您的对象在缓存上以特定方式运行并且总是需要时,可能需要
它自己独立的画布来正确渲染。
创建用于重写
自从1.7.12
- Inherited From:
- Source:
Returns:
Boolean
onCompositionEnd()
作文结束
- Source:
onCompositionStart()
作文开始
- Source:
onDeselect(optionsopt)
每次_discardActiveObject或_setActiveObject调用这个回调函数
尝试取消选择此对象。如果函数返回true,则进程被取消
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
options |
Object |
<optional> |
如果流程是由事件生成的,则为事件从上层函数发送的选项 属性 名字 类型 属性 描述 e 事件 如果流程是由事件生成的,则为事件 |
- Overrides:
- Source:
onInput(e)
处理onInput事件
Parameters:
Name | Type | Description |
---|---|---|
e |
Event | 事件对象 |
- Source:
onKeyDown(e)
处理按键事件
仅用于箭头和修改键的组合。
Parameters:
Name | Type | Description |
---|---|---|
e |
Event | 事件对象 |
- Source:
onKeyUp(e)
处理按键事件
我们处理KeyUp,因为ie11和edge有复制/粘贴困难
如果触发了复制/剪切事件,keyup将被解除
Parameters:
Name | Type | Description |
---|---|---|
e |
Event | 事件对象 |
- Source:
onSelect(optionsopt)
每次_discardActiveObject或_setActiveObject调用这个回调函数
尝试选择此对象。如果函数返回true,则进程被取消
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
options |
Object |
<optional> |
如果流程是由事件生成的,则为事件从上层函数发送的选项 属性 名字 类型 属性 描述 e 事件 如果流程是由事件生成的,则为事件 |
- Inherited From:
- Source:
paste(e)
粘贴的文本
Parameters:
Name | Type | Description |
---|---|---|
e |
Event | 事件对象 |
- Source:
removeChars(start, end)
从开始/结束处删除字符
开始/结束在_text数组中的每个字母位置。
Parameters:
Name | Type | Description |
---|---|---|
start |
Number | |
end |
Number | 默认从+ 1开始 |
- Source:
removeStyle(props)
从所有单个角色样式中移除一个或多个样式属性
在文本对象中。如果不包含其他样式,则删除角色样式对象
道具。如果不包含其他字符样式,则删除行样式对象。
Parameters:
Name | Type | Description |
---|---|---|
props |
String | 要从字符样式中删除的属性。 |
- Inherited From:
- Source:
removeStyleFromTo(start, end)
从头到尾移除并回流样式块。
Parameters:
Name | Type | Description |
---|---|---|
start |
Number | 用于拆卸的线性起始位置(包含在拆卸中) |
end |
Number | 用于拆卸的线性末端位置(不包括拆卸) |
- Source:
renderCursor(boundaries, ctx)
使光标
Parameters:
Name | Type | Description |
---|---|---|
boundaries |
Object | |
ctx |
CanvasRenderingContext2D | 转换后的上下文 |
- Source:
renderCursorOrSelection()
呈现光标或选择项(取决于存在的内容)
它在contextTop上做。如果contextTop不可用,什么也不做。
- Source:
renderSelection(boundaries, ctx)
呈现文本选择
Parameters:
Name | Type | Description |
---|---|---|
boundaries |
Object | 具有left/top/ leftovers /topOffset的对象 |
ctx |
CanvasRenderingContext2D | 转换后的上下文 |
- Source:
rotate(angle) → {fabric.Object}
以居中旋转方式设置实例的“角度”
Parameters:
Name | Type | Description |
---|---|---|
angle |
Number | 角度值(以度为单位) |
- Inherited From:
- Source:
Returns:
thisArg
- Type
- fabric.Object
saveState(optionsopt) → {fabric.Object}
保存对象的状态
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
options |
Object |
<optional> |
对象,在保存状态时要包含附加的' stateProperties '数组 |
- Inherited From:
- Source:
Returns:
thisArg
- Type
- fabric.Object
scale(value) → {fabric.Object}
缩放对象(等量缩放x和y)
Parameters:
Name | Type | Description |
---|---|---|
value |
Number | 比例因子 |
- Inherited From:
- Source:
Returns:
thisArg
- Type
- fabric.Object
scaleToHeight(value, absolute) → {fabric.Object}
将对象缩放到给定高度,相对于边界框(等量缩放x/y)
Parameters:
Name | Type | Description |
---|---|---|
value |
Number | 新高度值 |
absolute |
Boolean | 忽略视窗 |
- Inherited From:
- Source:
Returns:
thisArg
- Type
- fabric.Object
scaleToWidth(value, absolute) → {fabric.Object}
将一个对象缩放到给定的宽度,相对于边界框(等量缩放x/y)
Parameters:
Name | Type | Description |
---|---|---|
value |
Number | 新的宽度值 |
absolute |
Boolean | 忽略视窗 |
- Inherited From:
- Source:
Returns:
thisArg
- Type
- fabric.Object
searchWordBoundary(selectionStart, direction) → {Number}
查找对应于单词开头或结尾的索引
Parameters:
Name | Type | Description |
---|---|---|
selectionStart |
Number | 字符索引 |
direction |
Number | 1或-1 |
- Source:
Returns:
Index of the beginning or end of a word
- Type
- Number
selectAll() → {fabric.IText}
选择整个文本
- Source:
Returns:
thisArg
- Type
- fabric.IText
selectLine(selectionStart) → {fabric.IText}
根据索引选择一行
Parameters:
Name | Type | Description |
---|---|---|
selectionStart |
Number | 字符索引 |
- Source:
Returns:
thisArg
- Type
- fabric.IText
selectWord(selectionStart)
根据索引选择一个单词
Parameters:
Name | Type | Description |
---|---|---|
selectionStart |
Number | 字符索引 |
- Source:
sendBackwards(intersectingopt) → {fabric.Object}
在绘制的对象堆栈中向下移动一个对象
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
intersecting |
Boolean |
<optional> |
如果为true,则将对象发送到下一个较低相交对象的后面 |
- Inherited From:
- Source:
Returns:
thisArg
- Type
- fabric.Object
sendToBack() → {fabric.Object}
将一个对象移动到绘制对象堆栈的底部
- Inherited From:
- Source:
Returns:
thisArg
- Type
- fabric.Object
set(key, value) → {fabric.Object}
将属性设置为给定值。当更改与位置/尺寸相关的属性(左、顶、比例、角度等)时' set '不更新对象的边界/控件的位置。如果你需要更新那些,调用' setcoord() '。
Parameters:
Name | Type | Description |
---|---|---|
key |
String | Object | 属性名称或对象(如果是对象,则遍历对象属性) |
value |
Object | function | 属性值(if函数,将值传递给它,并将其返回值用作新值) |
- Inherited From:
- Source:
Returns:
thisArg
- Type
- fabric.Object
setControlsVisibility(optionsopt) → {fabric.Object}
设置对象控件的可见性状态。
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
options |
Object |
<optional> |
True为启用左下角控件,false为禁用它True为启用右下角控件,false为禁用它True为启用中底控件,false为禁用它True为启用左中控件,false为禁用它True为启用中右控件,false为禁用它True为启用中顶控件,false为禁用它True为启用左上角控件,false为禁用它True为启用右上方控件,false为禁用它True为启用中顶旋转控件,false为禁用该控件选择对象 属性 名字 类型 属性 描述 提单 布尔 True为启用左下角控件,false为禁用它 br 布尔 True为启用右下角控件,false为禁用它 mb 布尔 True为启用中底控件,false为禁用它 毫升 布尔 True为启用左中控件,false为禁用它 先生 布尔 True为启用中右控件,false为禁用它 太 布尔 True为启用中顶控件,false为禁用它 tl 布尔 True为启用左上角控件,false为禁用它 tr 布尔 True为启用右上方控件,false为禁用它 地铁 布尔 True为启用中顶旋转控件,false为禁用该控件 |
- Inherited From:
- Source:
Returns:
thisArg
- Type
- fabric.Object
setControlVisible(controlKey, visible) → {fabric.Object}
设置指定控件的可见性。
Parameters:
Name | Type | Description |
---|---|---|
controlKey |
String | 控制键。可能的值是“tl”,“tr”,“品牌”,“提单”、“毫升”、“太”,“先生”,“m”,“地铁”。 |
visible |
Boolean | True表示将指定的控件设置为可见,否则为false |
- Inherited From:
- Source:
Returns:
thisArg
- Type
- fabric.Object
setCoords(skipCornersopt) → {fabric.Object}
根据当前角度、宽度和高度、左侧和顶部设置角和控制位置坐标。
弦是用来找角的
绳索用于快速找到画布上的对象
linecoord用于在指针事件期间快速查找对象。
参见https://github.com/fabricjs/fabric.js/wiki/When-to-call-setCoords和http://fabricjs.com/fabric-gotchas
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
skipCorners |
Boolean |
<optional> |
跳过ocord的计算。 |
- Inherited From:
- Source:
Returns:
thisArg
- Type
- fabric.Object
setCursorByClick(e)
根据传递的指针(x/y)对象更改文本中的光标位置
Parameters:
Name | Type | Description |
---|---|---|
e |
Event | 事件对象 |
- Source:
setOnGroup()
这个回调函数每次由对象的父组调用
对组上的非委托属性进行更改的时间。它被传递了密钥
值作为参数。不添加此函数的签名以避免
Travis构建关于未使用变量的错误。
- Inherited From:
- Source:
setOptions(optionsopt)
从选项设置对象的属性
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
options |
Object |
<optional> |
选择对象 |
- Inherited From:
- Source:
setPathInfo() → {fabric.Text}
如果文本有路径,它将添加所需的额外信息
用于路径和文本计算
- Inherited From:
- Source:
Returns:
thisArg
- Type
- fabric.Text
setPositionByOrigin(pos, originX, originY) → {void}
根据对象的原点设置对象的位置
Parameters:
Name | Type | Description |
---|---|---|
pos |
fabric.Point | 对象的新位置 |
originX |
String | 水平原点:“左”、“中”或“右” |
originY |
String | 垂直原点:'top', 'center'或'bottom' |
- Inherited From:
- Source:
Returns:
- Type
- void
setSelectionEnd(index)
设置选择结束(选择的右边界)
Parameters:
Name | Type | Description |
---|---|---|
index |
Number | 设置选择结束位置的索引 |
- Source:
setSelectionStart(index)
设置选择开始(选择的左边界)
Parameters:
Name | Type | Description |
---|---|---|
index |
Number | 设置选择开始的索引 |
- Source:
setSelectionStartEndWithShift()
根据光标的新位置设置selectionStart和selectionEnd
模仿按下shift键时的鼠标导航。
- Source:
setSelectionStyles(stylesopt, startIndexopt, endIndexopt) → {fabric.IText}
设置当前选择项的样式,如果不存在选择项,则不设置任何内容。
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
styles |
Object |
<optional> |
样式对象 |
startIndex |
Number |
<optional> |
启动索引以获取样式 |
endIndex |
Number |
<optional> |
获取样式的结束索引,如果没有指定selectionEnd或startIndex + 1 |
- Inherited From:
- Source:
Returns:
thisArg
- Type
- fabric.IText
setSubscript(start, end) → {fabric.Text}
将角色变成一个“劣等人物”(即:“下标”)
Parameters:
Name | Type | Description |
---|---|---|
start |
Number | 选择开始 |
end |
Number | 选择结束 |
- Inherited From:
- Source:
Returns:
thisArg
- Type
- fabric.Text
setSuperscript(start, end) → {fabric.Text}
将角色变成“高级人物”(即:“上标”)
Parameters:
Name | Type | Description |
---|---|---|
start |
Number | 选择开始 |
end |
Number | 选择结束 |
- Inherited From:
- Source:
Returns:
thisArg
- Type
- fabric.Text
setupState(optionsopt) → {fabric.Object}
设置对象的状态
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
options |
Object |
<optional> |
对象,在保存状态时要包含附加的' stateProperties '数组 |
- Inherited From:
- Source:
Returns:
thisArg
- Type
- fabric.Object
shiftLineStyles(lineIndex, offset)
向上或向下移动线条样式
Parameters:
Name | Type | Description |
---|---|---|
lineIndex |
Number | 直线的索引 |
offset |
Number | 有数字吗? |
- Source:
shouldCache() → {Boolean}
决定对象是否应该缓存。创建自己的缓存级别
objectCaching是一个全局标志,胜过一切
当对象绘制方法需要时,应该使用needsItsOwnCache
缓存步骤。没有一个fabric类需要它。
通常不缓存组中的对象,因为外部的组被缓存。
读取为:缓存,如果需要,或者如果功能已启用,但我们还没有缓存。
- Inherited From:
- Source:
Returns:
- Type
- Boolean
straighten() → {fabric.Object}
将物体拉直(将其从当前角度旋转到0,90,180,270等中的一个,取决于哪个更接近)
- Inherited From:
- Source:
Returns:
thisArg
- Type
- fabric.Object
styleHas(property, lineIndex) → {Boolean}
如果对象具有样式属性或在指定行中,则返回true
此函数用于检测文本是否将使用特定属性。
Parameters:
Name | Type | Description |
---|---|---|
property |
String | 检查 |
lineIndex |
Number | 来检查款式 |
- Inherited From:
- Source:
Returns:
- Type
- Boolean
toCanvasElement(options) → {HTMLCanvasElement}
将一个对象转换为一个HTMLCanvas元素
Parameters:
Name | Type | Description |
---|---|---|
options |
Object | 乘数乘以裁剪左偏移。在v1.2.14中引入裁剪顶部偏移。在v1.2.14中引入裁剪宽度。在v1.2.14中引入种植的高度。在v1.2.14中引入启用视网膜缩放克隆图像。1.6.4引入移除当前对象变换(无缩放、无角度、无翻转、无倾斜)。在2.3.4中引入移除当前对象阴影。2.4.2引入选择对象 属性 名字 类型 属性 默认的 描述 乘数 数量 1 乘数乘以 左 数量 裁剪左偏移。在v1.2.14中引入 前 数量 裁剪顶部偏移。在v1.2.14中引入 宽度 数量 裁剪宽度。在v1.2.14中引入 高度 数量 种植的高度。在v1.2.14中引入 enableRetinaScaling 布尔 启用视网膜缩放克隆图像。1.6.4引入 withoutTransform 布尔 移除当前对象变换(无缩放、无角度、无翻转、无倾斜)。在2.3.4中引入 withoutShadow 布尔 移除当前对象阴影。2.4.2引入 |
- Inherited From:
- Source:
Returns:
Returns DOM element
- Type
- HTMLCanvasElement
toClipPathSVG(reviveropt) → {String}
返回实例的svg clipPath表示
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
reviver |
function |
<optional> |
进一步解析svg表示的方法。 |
- Inherited From:
- Source:
Returns:
svg representation of an instance
- Type
- String
toDatalessObject(propertiesToIncludeopt) → {Object}
返回实例的(无数据)对象表示
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
propertiesToInclude |
Array |
<optional> |
您可能希望在输出中额外包含的任何属性 |
- Inherited From:
- Source:
Returns:
Object representation of an instance
- Type
- Object
toDataURL(options) → {String}
将对象转换为类似data-url的字符串
Parameters:
Name | Type | Description |
---|---|---|
options |
Object | 输出图像的格式。jpeg或png格式质量等级(0..1)。仅用于jpeg。乘数乘以裁剪左偏移。在v1.2.14中引入裁剪顶部偏移。在v1.2.14中引入裁剪宽度。在v1.2.14中引入种植的高度。在v1.2.14中引入启用视网膜缩放克隆图像。1.6.4引入移除当前对象变换(无缩放、无角度、无翻转、无倾斜)。在2.3.4中引入移除当前对象阴影。2.4.2引入 |
- Inherited From:
- Source:
Returns:
Returns a data: URL containing a representation of the object in the format specified by options.format
- Type
- String
toJSON(propertiesToIncludeopt) → {Object}
返回实例的JSON表示形式
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
propertiesToInclude |
Array |
<optional> |
您可能希望在输出中额外包含的任何属性 |
- Inherited From:
- Source:
Returns:
JSON
- Type
- Object
toLocalPoint(point, originX, originY) → {fabric.Point}
以本地坐标返回点
Parameters:
Name | Type | Description |
---|---|---|
point |
fabric.Point | 相对于全球坐标系的点 |
originX |
String | 水平原点:“左”、“中”或“右” |
originY |
String | 垂直原点:'top', 'center'或'bottom' |
- Inherited From:
- Source:
Returns:
- Type
- fabric.Point
toObject(propertiesToIncludeopt) → {Object}
返回实例的对象表示形式
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
propertiesToInclude |
Array |
<optional> |
您可能希望在输出中额外包含的任何属性 |
- Inherited From:
- Source:
Returns:
Object representation of an instance
- Type
- Object
toString() → {String}
返回实例的字符串表示形式
- Inherited From:
- Source:
Returns:
String representation of text object
- Type
- String
toSVG(reviveropt) → {String}
返回实例的svg表示形式
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
reviver |
function |
<optional> |
进一步解析svg表示的方法。 |
- Inherited From:
- Source:
Returns:
svg representation of an instance
- Type
- String
transform(ctx)
在呈现对象时转换上下文
Parameters:
Name | Type | Description |
---|---|---|
ctx |
CanvasRenderingContext2D | 上下文 |
- Inherited From:
- Source:
translateToCenterPoint(point, originX, originY) → {fabric.Point}
将坐标从原点转换为中心坐标(基于对象的尺寸)
Parameters:
Name | Type | Description |
---|---|---|
point |
fabric.Point | 对应于originX和originY参数的点 |
originX |
String | 水平原点:“左”、“中”或“右” |
originY |
String | 垂直原点:'top', 'center'或'bottom' |
- Inherited From:
- Source:
Returns:
- Type
- fabric.Point
translateToGivenOrigin(point, fromOriginX, fromOriginY, toOriginX, toOriginY) → {fabric.Point}
将坐标从一组原点转换为另一组原点(基于对象的尺寸)
Parameters:
Name | Type | Description |
---|---|---|
point |
fabric.Point | 对应于originX和originY参数的点 |
fromOriginX |
String | 水平原点:“左”、“中”或“右” |
fromOriginY |
String | 垂直原点:'top', 'center'或'bottom' |
toOriginX |
String | 水平原点:“左”、“中”或“右” |
toOriginY |
String | 垂直原点:'top', 'center'或'bottom' |
- Inherited From:
- Source:
Returns:
- Type
- fabric.Point
translateToOriginPoint(center, originX, originY) → {fabric.Point}
将坐标从中心坐标转换为原点坐标(基于对象的尺寸)
Parameters:
Name | Type | Description |
---|---|---|
center |
fabric.Point | 与物体中心相对应的点 |
originX |
String | 水平原点:“左”、“中”或“右” |
originY |
String | 垂直原点:'top', 'center'或'bottom' |
- Inherited From:
- Source:
Returns:
- Type
- fabric.Point
tripleClickHandler()
默认处理程序为三重单击,选择一行
- Source:
viewportCenter() → {fabric.Object}
将对象居中于最后添加到的画布的当前视口中。
你可能需要在定心之后在一个对象上调用setcoord来更新控件区域。
- Inherited From:
- Source:
Returns:
thisArg
- Type
- fabric.Object
viewportCenterH() → {fabric.Object}
将对象水平居中于最后添加到的画布的当前视口中。
你可能需要在定心之后在一个对象上调用setcoord来更新控件区域。
- Inherited From:
- Source:
Returns:
thisArg
- Type
- fabric.Object
viewportCenterV() → {fabric.Object}
将对象垂直居中于它最后添加到的画布的当前视口中。
你可能需要在定心之后在一个对象上调用setcoord来更新控件区域。
- Inherited From:
- Source:
Returns:
thisArg
- Type
- fabric.Object
willDrawShadow() → {Boolean}
检查此对象或子对象是否会投射阴影
组使用。shouldCache递归地知道子节点是否有影子
- Inherited From:
- Source:
Returns:
- Type
- Boolean