fabric-api-method

1. Methods

1.1. \color{#2E8B57}{ \_\_onMouseWheel(e)}

鼠标执行滑轮方法

1.2. \color{#2E8B57}{\_chooseObjectsToRender() → {Array}}

将对象分为两组,一组立即呈现,另一组作为activeGroup呈现。

1.3. \color{#2E8B57}{\_setCursorFromEvent(e, target)}

Sets the cursor depending on where the canvas is being hovered. Note: very buggy in Opera
根据画布的悬停位置设置光标。注意:在Opera中有很多bug

1.4. \color{#2E8B57}{absolutePan(point) → {fabric.Canvas}}

绝对定位,左上角

1.5. \color{#2E8B57}{add(…object) → {Self}}

Adds objects to collection, Canvas or Group, then renders canvas (if renderOnAddRemove is not false). in case of Group no changes to bounding box are made. Objects should be instances of (or inherit from) fabric.Object Use of this function is highly discouraged for groups. you can add a bunch of objects with the add method but then you NEED to run a addWithUpdate call for the Group class or position/bbox will be wrong.

将对象添加到集合、画布或组中,然后呈现画布(如果“renderOnAddRemove”不是“false”)。在组的情况下,不改变边界框。对象应该是fabric的实例(或继承自fabric)。不鼓励使用此函数的对象。你可以用add方法添加一堆对象,但是你需要为Group类或者position/bbox运行一个addWithUpdate调用。

1.6. \color{#2E8B57}{bringForward(object, intersectingopt) → {fabric.Canvas}}

Moves an object or a selection up in stack of drawn objects An optional paramter, intersecting allowes to move the object in front of the first intersecting object. Where intersection is calculated with bounding box. If no intersection is found, there will not be change in the stack.

在绘制对象堆栈中向上移动一个对象或一个选择项(可选参数),相贯允许将该对象移动到第一个相贯对象的前面。其中交集用边界框计算。如果没有找到交集,则堆栈中不会有更改。

1.7. \color{#2E8B57}{bringToFront(object) → {fabric.Canvas}}

Moves an object or the objects of a multiple selection to the top of the stack of drawn objects
将一个对象或多个选择项的对象移动到绘制对象堆栈的顶部

1.8. \color{#2E8B57}{calcOffset() → {fabric.Canvas}}

Calculates canvas element offset relative to the document This method is also attached as "resize" event handler of window
计算画布元素相对于文档的偏移量,此方法也附加为窗口的“resize”事件处理程序

1.9. \color{#2E8B57}{calcViewportBoundaries() → {Object}}

Calculate the position of the 4 corner of canvas with current viewportTransform. helps to determinate when an object is in the current rendering viewport using object absolute coordinates ( aCoords )

使用当前viewportTransform计算画布的4个角的位置。使用对象绝对坐标(aCoords)帮助确定对象何时处于当前呈现视图中

1.10. \color{#2E8B57}{centerObject(object) → {fabric.Canvas}}

Centers object vertically and horizontally in the canvas
在画布中垂直和水平居中对象

1.11. \color{#2E8B57}{centerObjectH(object) → {fabric.Canvas}}

Centers object horizontally in the canvas
在画布中水平居中对象

1.12. \color{#2E8B57}{centerObjectV(object) → {fabric.Canvas}}

Centers object vertically in the canvas
在画布中垂直居中对象

1.13. \color{#2E8B57}{clear() → {fabric.Canvas}}

Clears all contexts (background, main, top) of an instance
清除实例的所有上下文(背景、主、顶)

1.14. \color{#2E8B57}{clearContext(ctx) → {fabric.Canvas}}

Clears specified context of canvas element
清除指定的画布元素上下文

1.15. \color{#2E8B57}{complexity() → {Number}}

Returns number representation of a collection complexity
返回集合复杂度的数字表示形式

1.16. \color{#2E8B57}{contains(object) → {Boolean}}

Returns true if collection contains an object
如果集合包含对象,则返回true

1.17. \color{#2E8B57}{containsPoint(e, target, pointopt) → {Boolean}}

Checks if point is contained within an area of given object
检查点是否包含在给定对象的区域内

1.18. \color{#2E8B57}{createSVGFontFacesMarkup(objects) → {String}}

Creates markup containing SVG font faces, font URLs for font faces must be collected by developers and are not extracted from the DOM by fabricjs
创建包含SVG字体外观的标记,字体外观的字体url必须由开发人员收集,而不是由fabricjs从DOM中提取

1.19. \color{#2E8B57}{createSVGRefElementsMarkup() → {String}}

Creates markup containing SVG referenced elements like patterns, gradients etc.
创建包含SVG引用元素(如模式、梯度等)的标记。

1.20. \color{#2E8B57}{discardActiveObject(e) → {fabric.Canvas}}

Discards currently active object and fire events. If the function is called by fabric as a consequence of a mouse event, the event is passed as a parameter and sent to the fire function for the custom events. When used as a method the e param does not have any application.
丢弃当前活动的对象和火灾事件。如果fabric由于鼠标事件而调用该函数,则将该事件作为参数传递,并将其发送给fire函数以处理自定义事件。当作为方法使用时,e参数没有任何应用。

1.21. \color{#2E8B57}{dispose() → {fabric.Canvas}}

Clears a canvas element and removes all event listeners
清除画布元素并删除所有事件监听器

1.22. \color{#2E8B57}{findTarget(e, skipGroup) → {fabric.Object}}

Method that determines what object we are clicking on the skipGroup parameter is for internal use, is needed for shift+click action 11/09/2018 TODO: would be cool if findTarget could discern between being a full target or the outside part of the corner.

1.23. \color{#2E8B57}{forEachObject(callback, context) → {Self}}

Executes given function for each object in this group
循环遍历对象

1.24. \color{#2E8B57}{fxCenterObjectH(object, callbacksopt) → {fabric.Canvas}}

Centers object horizontally with animation.
带动画的水平居中

1.25. \color{#2E8B57}{fxCenterObjectV(object, callbacksopt) → {fabric.Canvas}}

Centers object vertically with animation.
带动画的垂直居中

1.26. \color{#2E8B57}{fxRemove(object, callbacksopt) → {fabric.Canvas}}

Same as fabric.Canvas#remove but animated
带动画的删除

1.27. \color{#2E8B57}{fxStraightenObject(object) → {fabric.Canvas}}

带动画的拉伸对象

1.28. \color{#2E8B57}{getActiveObject() → {fabric.Object}}

获取活动的对象
Returns currently active object

1.29. \color{#2E8B57}{getActiveObjects() → {fabric.Object}}

Returns an array with the current selected objects
获取活动的对象数组

1.30. \color{#2E8B57}{getCenter() → {Object}}

Returns coordinates of a center of canvas. Returned value is an object with top and left properties
中心点

1.31. \color{#2E8B57}{getContext() → {CanvasRenderingContext2D}}

Returns context of canvas where objects are drawn
返回绘制对象的canvas上下文

1.32. \color{#2E8B57}{getElement() → {HTMLCanvasElement}}

Returns <canvas> element corresponding to this instance
返回dom元素

1.33. \color{#2E8B57}{getHeight() → {Number}}

Returns canvas height (in px)
获取高度

1.34. \color{#2E8B57}{getObjects(typeopt) → {Array}}

Returns an array of children objects of this instance Type parameter introduced in 1.3.10 since 2.3.5 this method return always a COPY of the array;
获取对象

1.35. \color{#2E8B57}{getPointer(e, ignoreZoom) → {Object}}

Returns pointer coordinates relative to canvas. Can return coordinates with or without viewportTransform. ignoreZoom false gives back coordinates that represent the point clicked on canvas element. ignoreZoom true gives back coordinates after being processed by the viewportTransform ( sort of coordinates of what is displayed on the canvas where you are clicking. ignoreZoom true = HTMLElement coordinates relative to top,left ignoreZoom false, default = fabric space coordinates, the same used for shape position To interact with your shapes top and left you want to use ignoreZoom true most of the time, while ignoreZoom false will give you coordinates compatible with the object.oCoords system. of the time.
返回点

1.36. \color{#2E8B57}{getSelectionContext() → {CanvasRenderingContext2D}}

Returns context of canvas where object selection is drawn
获取选中的上下文

1.37. \color{#2E8B57}{getSelectionElement() → {HTMLCanvasElement}}

Returns <canvas> element on which object selection is drawn
获取选中的canvas元素

1.38. \color{#2E8B57}{getVpCenter() → {fabric.Point}}

Calculate the point in canvas that correspond to the center of actual viewport.
计算画布中对应于实际视口中心的点。

1.39. \color{#2E8B57}{getWidth() → {Number}}

Returns canvas width (in px)
返回宽度

1.40. \color{#2E8B57}{getZoom() → {Number}}

Returns canvas zoom level
返回鼠标缩放级别

1.41. \color{#2E8B57}{initialize(el, optionsopt) → {Object}}

Constructor
构造函数

1.42. \color{#2E8B57}{insertAt(object, index, nonSplicing) → {Self}}

Inserts an object into collection at specified index, then renders canvas (if renderOnAddRemove is not false) An object should be an instance of (or inherit from) fabric.Object Use of this function is highly discouraged for groups. you can add a bunch of objects with the insertAt method but then you NEED to run a addWithUpdate call for the Group class or position/bbox will be wrong.
在指定索引处将对象插入集合,然后呈现画布(如果“renderOnAddRemove”不是“false”),则对象应是结构的实例(或继承自结构)。对于组,强烈建议不使用此函数的对象。您可以使用insertAt方法添加一组对象,但是您需要为组类运行addWithUpdate调用,否则position/bbox将出错。

1.43. \color{#2E8B57}{isEmpty() → {Boolean}}

Returns true if collection contains no objects
如果集合为空,则返回true

1.44. \color{#2E8B57}{isTargetTransparent(target, x, y) → {Boolean}}

Returns true if object is transparent at a certain location
如果对象在某个位置是透明的,则返回true

1.45. \color{#2E8B57}{item(index) → {Self}}

Returns object at specified index
返回指定索引处的对象

1.46. \color{#2E8B57}{loadFromDatalessJSON(json, callback, reviveropt) → {fabric.Canvas}}

Populates canvas with data from the specified dataless JSON. JSON format must conform to the one of fabric.Canvas#toDatalessJSON
使用指定的无数据JSON中的数据填充画布。JSON格式必须与fabric.Canvas#toDatalessJSON格式一致

1.47. \color{#2E8B57}{loadFromJSON(json, callback, reviveropt) → {fabric.Canvas}}

Populates canvas with data from the specified JSON. JSON format must conform to the one of fabric.Canvas#toJSON
使用指定JSON中的数据填充画布。JSON格式必须与fabric.Canvas#toJSON格式一致

1.48. \color{#2E8B57}{moveTo(object, index) → {fabric.Canvas}}

Moves an object to specified level in stack of drawn objects
将对象移动到绘制对象堆栈中的指定级别

1.49. \color{#2E8B57}{relativePan(point) → {fabric.Canvas}}

Pans viewpoint relatively
相对平移

1.50. \color{#2E8B57}{remove(…object) → {Self}}

Removes objects from a collection, then renders canvas (if renderOnAddRemove is not false)
从集合中移除对象,然后呈现画布

1.51. \color{#2E8B57}{renderAll() → {fabric.Canvas}}

Renders both the top canvas and the secondary container canvas.
渲染顶部画布和辅助容器画布。

1.52. \color{#2E8B57}{renderCanvas(ctx, objects) → {fabric.Canvas}}

Renders background, objects, overlay and controls.
渲染背景,对象,覆盖和控制。

1.53. \color{#2E8B57}{renderTop() → {fabric.Canvas}}

Method to render only the top canvas. Also used to render the group selection box.
方法仅呈现顶层画布。也用于渲染组选择框。

1.54. \color{#2E8B57}{requestRenderAll() → {fabric.Canvas}}

Append a renderAll request to next animation frame. unless one is already in progress, in that case nothing is done a boolean flag will avoid appending more.
向下一个动画帧追加一个renderAll请求。除非一个已经在进行中,否则在这种情况下什么也不做布尔标志将避免附加更多。

1.55. \color{#2E8B57}{restorePointerVpt(pointer) → {Object}}

Returns pointer coordinates without the effect of the viewport
返回不受视口影响的指针坐标

1.56. \color{#2E8B57}{sendBackwards(object, intersectingopt) → {fabric.Canvas}}

Moves an object or a selection down in stack of drawn objects An optional paramter, intersecting allowes to move the object in behind the first intersecting object. Where intersection is calculated with bounding box. If no intersection is found, there will not be change in the stack.
在绘制对象堆栈中向下移动一个对象或一个选择项(可选参数),相贯允许将该对象移动到第一个相贯对象的后面。其中交集用边界框计算。如果没有找到交集,则堆栈中不会有更改。

1.57. \color{#2E8B57}{sendToBack(object) → {fabric.Canvas}}

Moves an object or the objects of a multiple selection to the bottom of the stack of drawn objects
将一个对象或多个选择项的对象移动到绘制对象堆栈的底部

1.58. \color{#2E8B57}{setActiveObject(object, eopt) → {fabric.Canvas}}

Sets given object as the only active object on canvas
将给定对象设置为画布上唯一的活动对象

1.59. \color{#2E8B57}{setBackgroundColor(backgroundColor, callback) → {fabric.Canvas}}

Sets background color for this canvas
设置此画布的背景颜色

1.60. \color{#2E8B57}{setBackgroundImage(image, callback, optionsopt) → {fabric.Canvas}}

Sets background image for this canvas
设置背景色

1.61. \color{#2E8B57}{setDimensions(dimensions, optionsopt) → {fabric.Canvas}}

Sets dimensions (width, height) of this canvas instance. when options.cssOnly flag active you should also supply the unit of measure (px/%/em)
设置画布实例的尺寸(宽度、高度)。

1.62. \color{#2E8B57}{setHeight(value, optionsopt) → {fabric.Canvas}}

Sets height of this canvas instance
设置高度

1.63. \color{#2E8B57}{setOverlayColor(overlayColor, callback) → {fabric.Canvas}}

Sets foreground color for this canvas
设置此画布的前景色

1.64. \color{#2E8B57}{setOverlayImage(image, callback, optionsopt) → {fabric.Canvas}}

Sets overlay image for this canvas
为这个画布设置叠加图像

1.65. \color{#2E8B57}{setViewportTransform(vpt) → {fabric.Canvas}}

Sets viewport transform of this canvas instance
设置此画布实例的viewport转换

1.66. \color{#2E8B57}{setWidth(value, optionsopt) → {fabric.Canvas}}

Sets width of this canvas instance
设置此画布实例的宽度

1.67. \color{#2E8B57}{setZoom(value) → {fabric.Canvas}}

Sets zoom level of this canvas instance
设置此画布实例的缩放级别

1.68. \color{#2E8B57}{size() → {Number}}

Returns a size of a collection (i.e: length of an array containing its objects)
含它的对象的数组的长度

1.69. \color{#2E8B57}{straightenObject(object) → {fabric.Canvas}}

Straightens object, then rerenders canvas
提取对象,然后重新生成画布

1.70. \color{#2E8B57}{toDatalessJSON(propertiesToIncludeopt) → {String}}

Returs dataless JSON representation of canvas
返回画布的无数据JSON表示

1.71. \color{#2E8B57}{toDatalessObject(propertiesToIncludeopt) → {Object}}

Returns dataless object representation of canvas
返回画布的无数据对象表示

1.72. \color{#2E8B57}{toDataURL(optionsopt) → {String}}

导出为 dataURL 图像

1.73. \color{#2E8B57}{toJSON(propertiesToIncludeopt) → {String}}

Returns JSON representation of canvas
转化为json字符串

1.74. \color{#2E8B57}{toObject(propertiesToIncludeopt) → {Object}}

Returns object representation of canvas
转化为对象

1.75. \color{#2E8B57}{toString() → {String}}

Returns a string representation of an instance
转化为string

1.76. \color{#2E8B57}{toSVG(optionsopt, reviveropt) → {String}}

Returns SVG representation of canvas
转化为svg

1.77. \color{#2E8B57}{viewportCenterObject(object) → {fabric.Canvas}}

Centers object vertically and horizontally in the viewport
在视口中垂直和水平居中对象

1.78. \color{#2E8B57}{viewportCenterObjectH(object) → {fabric.Canvas}}

Centers object horizontally in the viewport, object.top is unchanged
在viewport中水平居中对象

1.79. \color{#2E8B57}{viewportCenterObjectV(object) → {fabric.Canvas}}

Centers object Vertically in the viewport, object.top is unchanged
在viewport中垂直居中对象

1.80. \color{#2E8B57}{zoomToPoint(point, value) → {fabric.Canvas}}

Sets zoom level of this canvas instance, zoom centered around point
设置此画布实例的缩放级别,缩放以点为中心

©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 216,324评论 6 498
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 92,356评论 3 392
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 162,328评论 0 353
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 58,147评论 1 292
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 67,160评论 6 388
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 51,115评论 1 296
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 40,025评论 3 417
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 38,867评论 0 274
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 45,307评论 1 310
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 37,528评论 2 332
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 39,688评论 1 348
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 35,409评论 5 343
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 41,001评论 3 325
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 31,657评论 0 22
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,811评论 1 268
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 47,685评论 2 368
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 44,573评论 2 353