Canvas class

canvas = new fabric.Canvas(html.querySelector('#canvas'), { hoverCursor: 'pointer', selection: true, selectionBorderColor: 'blue', isDrawingMode: true });

Available extensions
Annotations
  • @JS('fabric.Canvas')

Constructors

Canvas(Element? element, [dynamic config])

Properties

activeObjectProperty ↔ dynamic

Available on Canvas, provided by the CanvasExtension extension

_activeObject
getter/setter pair
fireMiddleClick ↔ dynamic
Indicates if the canvas can fire middle click events @since 1.7.8 @default
getter/setter pair
fireRightClick ↔ dynamic
Indicates if the canvas can fire right click events @since 1.6.5 @default
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
isDrawingMode ↔ dynamic
When true, mouse events on canvas (mousedown/mousemove/mouseup) result in free drawing. After mousedown, mousemove creates a shape, and then mouseup finalizes it and adds an instance of fabric.Path onto canvas.
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
selection ↔ dynamic
getter/setter pair
stopContextMenu ↔ dynamic
Indicates if the right click on canvas can output the context menu or not @since 1.6.5 @default
getter/setter pair
viewportTransform ↔ dynamic
getter/setter pair

Methods

add(dynamic element) → dynamic
bringForward(dynamic object, [bool intersecting]) Canvas
bringToFront(dynamic object) Canvas
calcOffset() → dynamic
centerObject(dynamic element) → dynamic
clear() Canvas
clearContext(CanvasRenderingContext2D ctx) Canvas
discardActiveObject([Event e]) Canvas
dispose() Canvas
findTarget(Event e, bool skipGroup) → dynamic
Method that determines what object we are clicking on the skipGroup parameter is for internal use, is needed for shift+click action
fire(String eventName, [dynamic options]) → dynamic
Fires event with an optional options object @chainable
getActiveObject() FabricObject?
getActiveObjects() List
getContext() CanvasRenderingContext2D
getHeight() → dynamic
getObjects([String type]) List<FabricObject>
Returns an array of children objects of this instance Type parameter introduced in 1.3.10
getPointer(Event e, [bool ignoreZoom]) Point
getWidth() → dynamic
getZoom() num
loadFromJSON(dynamic json, Function callback, [Function reviveropt]) Canvas
http://fabricjs.com/docs/fabric.Canvas.html#loadFromJSON Populates canvas with data from the specified JSON. JSON format must conform to the one of fabric.Canvas#toJSON json String | Object JSON string or jsObject callback function Callback, invoked when json is parsed and corresponding objects (e.g: fabric.Image) are initialized reviver function
moveTo(dynamic object, num index) Canvas
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
off(dynamic eventName, dynamic func) → dynamic
Stops event observing for a particular event handler. Calling this method without arguments removes all handlers for all events void Function(IEvent e) handler
on(dynamic event, dynamic func) → dynamic
remove(dynamic element) → dynamic
renderAll() Canvas
renderAndReset() Canvas
requestRenderAll() Canvas
sendBackwards(dynamic object, [bool intersecting]) Canvas
sendToBack(dynamic object) Canvas
setActiveObject(dynamic object, [Event e]) Canvas
setHeight(num v) → dynamic
setViewportTransform(dynamic vpt) Canvas
Sets viewport transformation of this canvas instance vpt List
setWidth(num v) → dynamic
setZoom(num value) Canvas
toClipPathSVG([Function reviver]) String
Returns svg clipPath representation of an instance
toDatalessJSON([List<String> propertiesToInclude]) → dynamic
Returns dataless JSON representation of canvas @param {Array} propertiesToInclude Any properties that you might want to additionally include in the output @return {String} json string
toDataURL([IDataURLOptions options]) String
toJSON([List<String> propertiesToInclude]) → dynamic
http://fabricjs.com/docs/fabric.Canvas.html#toJSON Returns Object representation of canvas this alias is provided because if you call JSON.stringify on an instance, the toJSON object will be invoked if it exists. Having a toJSON method means you can do JSON.stringify(myCanvas) propertiesToInclude Array
toString() String
A string representation of this object.
inherited
toSVG([dynamic functionReviver]) String
Returns svg representation of an instance
zoomToPoint(Point point, num value) Canvas

Operators

operator ==(Object other) bool
The equality operator.
inherited