Skip to main content

Element

Functions

getType([fabricType])String

Gets the type of an element.

isSVG()Boolean

Checks if the element is a SVG.

isColorizable()Boolean

Checks if the element is colorizable.

isBitmap()Boolean

Checks if the element is a bitmap image.

hasColorSelection()Boolean

Checks if the element has a color selection.

checkEditable(checkProps)Boolean

Checks if the element can be edited by the user.

changeColor(colorData, [colorLinking])fabric.Canvas

Changes the color of an element.

setPattern(patternUrl)fabric.Canvas

Sets the pattern for an element.

getZIndex()Number

Gets the z-index of an element.

centerElement([hCenter], [vCenter])fabric.Object

Centers an element horizontal or/and vertical.

getBoundingBoxCoords(element)Object | Boolean

Returns the bounding box of an element.

getClippingObject()Object | fabric.Object

Gets the object for the clipping. Could be an object with coordinates or a fabric.Object.

getElementJSON([addPropertiesToInclude], [propertyKeys])Object

Gets the JSON representation of the element.

alignToPosition([pos])fabric.Canvas

Aligns an element.

toggleUploadZone()fabric.Canvas

Toggles the visibility of an upload zone. The upload zone is visible if it contains an element and hidden when empty.

getType([fabricType]) ⇒ String

Gets the type of an element.

Kind: global function
Extends: fabric.Canvas
Returns: String - The element type - text or image.

ParamTypeDescription
[fabricType]StringChecks this fabrich type instead of this.

isSVG() ⇒ Boolean

Checks if the element is a SVG.

Kind: global function
Extends: fabric.Canvas
Returns: Boolean - State

isColorizable() ⇒ Boolean

Checks if the element is colorizable.

Kind: global function
Extends: fabric.Canvas
Returns: Boolean - State

isBitmap() ⇒ Boolean

Checks if the element is a bitmap image.

Kind: global function
Extends: fabric.Canvas
Returns: Boolean - State

hasColorSelection() ⇒ Boolean

Checks if the element has a color selection.

Kind: global function
Extends: fabric.Canvas
Returns: Boolean - State

checkEditable(checkProps) ⇒ Boolean

Checks if the element can be edited by the user.

Kind: global function
Extends: fabric.Canvas
Returns: Boolean - Editable state

ParamTypeDescription
checkPropsObjectPass an object of properties instead of using this element.

changeColor(colorData, [colorLinking]) ⇐ fabric.Canvas

Changes the color of an element.

Kind: global function
Extends: fabric.Canvas

ParamTypeDefaultDescription
colorDataString | ArrayHex color value or any array of hex color values.
[colorLinking]BooleantrueIf element is color linked, execute it.

setPattern(patternUrl) ⇐ fabric.Canvas

Sets the pattern for an element.

Kind: global function
Extends: fabric.Canvas

ParamTypeDescription
patternUrlStringThe URL of the image used as pattern.

getZIndex() ⇒ Number

Gets the z-index of an element.

Kind: global function
Extends: fabric.Object
Returns: Number - The z-index.

centerElement([hCenter], [vCenter]) ⇐ fabric.Object

Centers an element horizontal or/and vertical.

Kind: global function
Extends: fabric.Object

ParamTypeDefaultDescription
[hCenter]BooleantrueCenter horizontal.
[vCenter]BooleantrueCenter vertical.

getBoundingBoxCoords(element) ⇒ Object | Boolean

Returns the bounding box of an element.

Kind: global function
Returns: Object | Boolean - The bounding box object with x,y,width and height or false.

ParamTypeDescription
elementfabric.ObjectA fabric object

getClippingObject() ⇒ Object | fabric.Object

Gets the object for the clipping. Could be an object with coordinates or a fabric.Object.

Kind: global function
Extends: fabric.Canvas
Returns: Object | fabric.Object - The object used for clipping.

getElementJSON([addPropertiesToInclude], [propertyKeys]) ⇒ Object

Gets the JSON representation of the element.

Kind: global function
Extends: fabric.Canvas
Returns: Object - A JSON representation of the element.

ParamTypeDefaultDescription
[addPropertiesToInclude]BooleanfalseAdd properties from propertiesToInclude property.
[propertyKeys]Array[]Addtional property keys to include.

alignToPosition([pos]) ⇐ fabric.Canvas

Aligns an element.

Kind: global function
Extends: fabric.Canvas

ParamTypeDefaultDescription
[pos]String'left'Allowed values: left, right, top or bottom.

toggleUploadZone() ⇐ fabric.Canvas

Toggles the visibility of an upload zone. The upload zone is visible if it contains an element and hidden when empty.

Kind: global function
Extends: fabric.Canvas