Namespace: fabric

fabric

Source:

Classes

BaseBrush
Canvas
Circle
CircleBrush
Color
Ellipse
Gradient
Group
Image
Intersection
IText
Line
Object
Path
PathGroup
Pattern
PatternBrush
PencilBrush
Point
Polygon
Polyline
Rect
Shadow
SprayBrush
StaticCanvas
Text
Textbox
Triangle

Namespaces

Collection
CommonMethods
Observable
util

Members

(static) charWidthsCache

Cache Object for widths of chars in text rendering.
Source:

(static) devicePixelRatio

Device Pixel Ratio
Source:
See:

(static) DPI

Pixel per Inch as a default value set to 96. Can be changed for more realistic conversion.
Source:

(static) isLikelyNode :boolean

True when in environment that's probably Node.js
Type:
  • boolean
Source:

(static) isTouchSupported :boolean

True when in environment that supports touch events
Type:
  • boolean
Source:

(static) SHARED_ATTRIBUTES :array

Attributes parsed from all SVG elements
Type:
  • array
Source:

Methods

(static) createCanvasForNode(width, height, optionsopt, nodeCanvasOptionsopt) → {Object}

Only available when running fabric on node.js
Parameters:
Name Type Attributes Description
width Number Canvas width
height Number Canvas height
options Object <optional>
Options to pass to FabricCanvas.
nodeCanvasOptions Object <optional>
Options to pass to NodeCanvas.
Source:
Returns:
wrapped canvas instance
Type
Object

(static) getCSSRules(doc) → {Object}

Returns CSS rules for a given SVG document
Parameters:
Name Type Description
doc SVGDocument SVG document to parse
Source:
Returns:
CSS rules of this document
Type
Object

(static) getGradientDefs(doc) → {Object}

Parses an SVG document, returning all of the gradient declarations found in it
Parameters:
Name Type Description
doc SVGDocument SVG document to parse
Source:
Returns:
Gradient definitions; key corresponds to element id, value -- to gradient definition element
Type
Object

(static) loadSVGFromString(string, callback, reviveropt, optionsopt)

Takes string corresponding to an SVG document, and parses it into a set of fabric objects
Parameters:
Name Type Attributes Description
string String
callback function
reviver function <optional>
Method for further parsing of SVG elements, called after each fabric object created.
options Object <optional>
Object containing options for parsing
Properties
Name Type Attributes Description
crossOrigin String <optional>
crossOrigin crossOrigin setting to use for external resources
Source:

(static) loadSVGFromURL(url, callback, reviveropt, optionsopt)

Takes url corresponding to an SVG document, and parses it into a set of fabric objects. Note that SVG is fetched via XMLHttpRequest, so it needs to conform to SOP (Same Origin Policy)
Parameters:
Name Type Attributes Description
url String
callback function
reviver function <optional>
Method for further parsing of SVG elements, called after each fabric object created.
options Object <optional>
Object containing options for parsing
Properties
Name Type Attributes Description
crossOrigin String <optional>
crossOrigin crossOrigin setting to use for external resources
Source:

(static) log(valuesopt)

Wrapper around `console.log` (when available)
Parameters:
Name Type Attributes Description
values * <optional>
Values to log
Source:

(static) parseAttributes(element, attributes) → {Object}

Returns an object of attributes' name/value, given element and an array of attribute names; Parses parent "g" nodes recursively upwards.
Parameters:
Name Type Description
element DOMElement Element to parse
attributes Array Array of attributes to parse
Source:
Returns:
object containing parsed attributes' names/values
Type
Object

(static) parseElements(elements, callback, optionsopt, reviveropt)

Transforms an array of svg elements to corresponding fabric.* instances
Parameters:
Name Type Attributes Description
elements Array Array of elements to parse
callback function Being passed an array of fabric instances (transformed from SVG elements)
options Object <optional>
Options object
reviver function <optional>
Method for further parsing of SVG elements, called after each fabric object created.
Source:

(static) parseFontDeclaration(value, oStyle)

Parses a short font declaration, building adding its properties to a style object
Parameters:
Name Type Description
value String font declaration
oStyle Object definition
Source:

(static) parsePointsAttribute(points) → {Array}

Parses "points" attribute, returning an array of values
Parameters:
Name Type Description
points String points attribute string
Source:
Returns:
array of points
Type
Array

(static) parseStyleAttribute(element) → {Object}

Parses "style" attribute, retuning an object with values
Parameters:
Name Type Description
element SVGElement Element to parse
Source:
Returns:
Objects with values parsed from style attribute of an element
Type
Object

(static) parseSVGDocument(doc, callback, reviveropt, parsingOptionsopt)

Parses an SVG document, converts it to an array of corresponding fabric.* instances and passes them to a callback
Parameters:
Name Type Attributes Description
doc SVGDocument SVG document to parse
callback function Callback to call when parsing is finished; It's being passed an array of elements (parsed from a document).
reviver function <optional>
Method for further parsing of SVG elements, called after each fabric object created.
parsingOptions Object <optional>
options for parsing document
Properties
Name Type Attributes Description
crossOrigin String <optional>
crossOrigin settings
Source:

(static) parseTransformAttribute(attributeValue) → {Array}

Parses "transform" attribute, returning an array of values
Parameters:
Name Type Description
attributeValue String String containing attribute value
Source:
Returns:
Array of 6 elements representing transformation matrix
Type
Array

(static) warn(valuesopt)

Wrapper around `console.warn` (when available)
Parameters:
Name Type Attributes Description
values * <optional>
Values to log as a warning
Source: