Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface NodeObject

Hierarchy

  • Group & IObjectOptions & { animating?: boolean; animation?: AnimationProperty; anime?: AnimeInstance; class?: string; clickable?: boolean; cloneable?: boolean; dblclick?: boolean; deletable?: boolean; description?: string; editable?: boolean; id?: string; link?: LinkProperty; locked?: boolean; originAngle?: number; originFill?: string | Pattern | Gradient; originLeft?: number; originOpacity?: number; originRotation?: number; originScaleX?: number; originScaleY?: number; originStroke?: string; originTop?: number; parentId?: string; rotation?: number; superType?: string; tooltip?: TooltipProperty }
    • NodeObject

Indexable

[key: string]: any

Index

Constructors

Properties

Methods

Constructors

constructor

  • new NodeObject(objects?: Object[], options?: IGroupOptions, isAlreadyGrouped?: boolean): NodeObject
  • Constructor

    Parameters

    • Optional objects: Object[]

      Group objects

    • Optional options: IGroupOptions
    • Optional isAlreadyGrouped: boolean

    Returns NodeObject

Properties

_objects

_objects: Object[]

Optional aCoords

aCoords: { bl: Point; br: Point; tl: Point; tr: Point } | undefined

Describe object's corner position in canvas object absolute coordinates properties are tl,tr,bl,br and describe the four main corner. each property is an object with x, y, instance of Fabric.Point. The coordinates depends from this properties: width, height, scaleX, scaleY skewX, skewY, angle, strokeWidth, top, left. Those coordinates are usefull to understand where an object is. They get updated with oCoords but they do not need to be updated when zoom or panning change. The coordinates get updated with @method setCoords. You can calculate them without updating with @method calcCoords(true);

memberof

fabric.Object.prototype

Optional absolutePositioned

absolutePositioned: boolean | undefined

Meaningful ONLY when the object is used as clipPath. if true, the clipPath will have its top and left relative to canvas, and will not be influenced by the object transform. This will make the clipPath relative to the canvas, but clipping just a particular object. WARNING this is beta, this feature may change or be renamed. since 2.4.0

default

false

Optional angle

angle: number | undefined

Angle of rotation of an object (in degrees)

Optional animating

animating: boolean

Is running animation

Optional animation

Animation property

Optional anime

anime: AnimeInstance

Anime instance

Optional backgroundColor

backgroundColor: string | undefined

Background color of an object. Only works with text objects at the moment.

Optional borderColor

borderColor: string | undefined

Color of controlling borders of an object (when it's active)

Optional borderDashArray

borderDashArray: number[] | undefined

Array specifying dash pattern of an object's border (hasBorder must be true)

Optional borderOpacityWhenMoving

borderOpacityWhenMoving: number | undefined

Opacity of object's controlling borders when object is active and moving

Optional borderScaleFactor

borderScaleFactor: number | undefined

Scale factor of object's controlling borders

Optional broadcastPort

broadcastPort: (portOption: Partial<PortObject>) => PortObject[]

Type declaration

Optional cacheProperties

cacheProperties: string[] | undefined

List of properties to consider when checking if cache needs refresh Those properties are checked by statefullCache ON ( or lazy mode if we want ) or from single calls to Object.set(key, value). If the key is in this list, the object is marked as dirty and refreshed at the next render

Optional canvas

canvas: Canvas | undefined

The canvas the object belongs to

Optional centeredRotation

centeredRotation: boolean | undefined

When true, this object will use center point as the origin of transformation when being rotated via the controls. Backwards incompatibility note: This property replaces "centerTransform" (Boolean).

Optional centeredScaling

centeredScaling: boolean | undefined

When true, this object will use center point as the origin of transformation when being scaled via the controls. Backwards incompatibility note: This property replaces "centerTransform" (Boolean).

Optional class

class: string

Object class

Optional clickable

clickable: boolean

Whether it can be clicked

Optional clipPath

clipPath: Object | undefined

A fabricObject that, without stroke define a clipping area with their shape. filled in black the clipPath object gets used when the object has rendered, and the context is placed in the center of the object cacheCanvas. If you want 0,0 of a clipPath to align with an object center, use clipPath.originX/Y to 'center'

Optional cloneable

cloneable: boolean

Is possible clone

Optional configuration

configuration: Record<string, any>

Optional cornerColor

cornerColor: string | undefined

Color of controlling corners of an object (when it's active)

Optional cornerDashArray

cornerDashArray: number[] | undefined

Array specifying dash pattern of an object's control (hasBorder must be true)

Optional cornerSize

cornerSize: number | undefined

Size of object's controlling corners (in pixels)

Optional cornerStrokeColor

cornerStrokeColor: string | undefined

Color of controlling corners of an object (when it's active and transparentCorners false)

Optional cornerStyle

cornerStyle: "rect" | "circle" | undefined

Specify style of control, 'rect' or 'circle'

Optional createFromPort

createFromPort: (left: number, top: number) => PortObject[]

Type declaration

    • Parameters

      • left: number
      • top: number

      Returns PortObject[]

Optional createToPort

createToPort: (left: number, top: number) => PortObject

Type declaration

Optional data

data: any

Not used by fabric, just for convenience

Optional dblclick

dblclick: boolean

Is enable double click

Optional defaultPortOption

defaultPortOption: () => Partial<PortObject>

Type declaration

Optional deletable

deletable: boolean

Is possible delete

Optional description

description: string
description

Optional descriptor

descriptor: Record<string, any>

Optional dirty

dirty: boolean | undefined

When set to true, object's cache will be rerendered next render call.

Optional duplicate

duplicate: () => NodeObject

Type declaration

Optional dynamicPort

dynamicPort: (portOption: Partial<PortObject>) => PortObject[]

Type declaration

Optional editable

editable: boolean

Object editable

Optional errorFlag

errorFlag: IText

Optional errors

errors: any

Optional evented

evented: boolean | undefined

When set to false, an object can not be a target of events. All events propagate through it. Introduced in v1.3.4

Optional excludeFromExport

excludeFromExport: boolean | undefined

When true, object is not exported in OBJECT/JSON since 1.6.3

default

Optional fill

fill: string | Pattern | Gradient | undefined

Color of object's fill

Optional fillRule

fillRule: string | undefined

Fill rule used to fill an object accepted values are nonzero, evenodd Backwards incompatibility note: This property was used for setting globalCompositeOperation until v1.4.12, use globalCompositeOperation instead

Optional flipX

flipX: boolean | undefined

When true, an object is rendered as flipped horizontally

Optional flipY

flipY: boolean | undefined

When true, an object is rendered as flipped vertically

Optional fromPort

fromPort: PortObject[]

Optional fromPortOption

fromPortOption: () => Partial<PortObject>

Type declaration

Optional globalCompositeOperation

globalCompositeOperation: string | undefined

Composite rule used for canvas globalCompositeOperation

Optional group

group: Group | undefined

The group the object is part of

Optional hasBorders

hasBorders: boolean | undefined

When set to false, object's controlling borders are not rendered

Optional hasControls

hasControls: boolean | undefined

When set to false, object's controls are not displayed and can not be used to manipulate object

Optional hasRotatingPoint

hasRotatingPoint: boolean | undefined

When set to false, object's controlling rotating point will not be visible or selectable

Optional height

height: number | undefined

Object height

Optional hoverCursor

hoverCursor: string | undefined

Default cursor value used when hovering over this object on canvas

Optional id

id: string

Object id

Optional includeDefaultValues

includeDefaultValues: boolean | undefined

When false, default object's values are not included in its serialization

Optional inverted

inverted: boolean | undefined

Meaningful ONLY when the object is used as clipPath. if true, the clipPath will make the object clip to the outside of the clipPath since 2.4.0

default

false

Optional label

label: Text

Optional left

left: number | undefined

Left position of an object. Note that by default it's relative to object center. You can change this by setting originX={left/center/right}

Optional link

Link property

Optional lockMovementX

lockMovementX: boolean | undefined

When true, object horizontal movement is locked

Optional lockMovementY

lockMovementY: boolean | undefined

When true, object vertical movement is locked

Optional lockRotation

lockRotation: boolean | undefined

When true, object rotation is locked

Optional lockScalingFlip

lockScalingFlip: boolean | undefined

When true, object cannot be flipped by scaling into negative values

Optional lockScalingX

lockScalingX: boolean | undefined

When true, object horizontal scaling is locked

Optional lockScalingY

lockScalingY: boolean | undefined

When true, object vertical scaling is locked

Optional lockSkewingX

lockSkewingX: boolean | undefined

When true, object horizontal skewing is locked

Optional lockSkewingY

lockSkewingY: boolean | undefined

When true, object vertical skewing is locked

Optional lockUniScaling

lockUniScaling: boolean | undefined

When true, object non-uniform scaling is locked

Optional locked

locked: boolean

Is locked object

Optional matrixCache

matrixCache: any

storage for object full transform matrix

Optional minScaleLimit

minScaleLimit: number | undefined

Minimum allowed scale value of an object

Optional moveCursor

moveCursor: string | undefined

Default cursor value used when moving an object on canvas

Optional name

name: string | undefined

Not used by fabric, just for convenience

Optional noScaleCache

noScaleCache: boolean | undefined

When true, cache does not get updated during scaling. The picture will get blocky if scaled too much and will be redrawn with correct details at the end of scaling. this setting is performance and application dependant. default to true since 1.7.0

Optional nodeClazz

nodeClazz: string

Optional oCoords

oCoords: { bl: Point; br: Point; mb: Point; ml: Point; mr: Point; mt: Point; mtr: Point; tl: Point; tr: Point } | undefined

Describe object's corner position in canvas element coordinates. properties are tl,mt,tr,ml,mr,bl,mb,br,mtr for the main controls. each property is an object with x, y and corner. The corner property contains in a similar manner the 4 points of the interactive area of the corner. The coordinates depends from this properties: width, height, scaleX, scaleY skewX, skewY, angle, strokeWidth, viewportTransform, top, left, padding. The coordinates get updated with @method setCoords. You can calculate them without updating with @method calcCoords;

memberof

fabric.Object.prototype

Optional objectCaching

objectCaching: boolean | undefined

When true, object is cached on an additional canvas.

Optional opacity

opacity: number | undefined

Opacity of an object

Optional originAngle

originAngle: number

Original angle

Optional originFill

originFill: string | Pattern | Gradient

Original fill color

Optional originLeft

originLeft: number

Original left position

Optional originOpacity

originOpacity: number

Original opacity

Optional originRotation

originRotation: number

Original rotation

Optional originScaleX

originScaleX: number

Original scale X

Optional originScaleY

originScaleY: number

Original scale Y

Optional originStroke

originStroke: string

Original stroke color

Optional originTop

originTop: number

Original top position

Optional originX

originX: string | undefined

Horizontal origin of transformation of an object (one of "left", "right", "center")

Optional originY

originY: string | undefined

Vertical origin of transformation of an object (one of "top", "bottom", "center")

Optional ownMatrixCache

ownMatrixCache: any

storage for object transform matrix

Optional padding

padding: number | undefined

Padding between object and its controlling borders (in pixels)

Optional paintFirst

paintFirst: string | undefined

Determines if the fill or the stroke is drawn first (one of "fill" or "stroke")

Optional parentId

parentId: string

Parent object id

Optional perPixelTargetFind

perPixelTargetFind: boolean | undefined

When set to true, objects are "found" on canvas on per-pixel basis rather than according to bounding box

Optional rotatingPointOffset

rotatingPointOffset: number | undefined

Offset for object's controlling rotating point (when enabled via hasRotatingPoint)

Optional rotation

rotation: number

This property replaces "angle"

Optional scaleX

scaleX: number | undefined

Object scale factor (horizontal)

Optional scaleY

scaleY: number | undefined

Object scale factor (vertical)

Optional selectable

selectable: boolean | undefined

When set to false, an object can not be selected for modification (using either point-click-based or group-based selection). But events still fire on it.

Optional selectionBackgroundColor

selectionBackgroundColor: string | undefined

Selection Background color of an object. colored layer behind the object when it is active. does not mix good with globalCompositeOperation methods.

Optional setErrors

setErrors: (errors: any) => void

Type declaration

    • (errors: any): void
    • Parameters

      • errors: any

      Returns void

Optional shadow

shadow: Shadow | string | undefined

Shadow object representing shadow of this shape

Optional singlePort

singlePort: (portOption: Partial<PortObject>) => PortObject[]

Type declaration

Optional skewX

skewX: number | undefined

Object skew factor (horizontal)

Optional skewY

skewY: number | undefined

Object skew factor (vertical)

Optional snapAngle

snapAngle: number | undefined

Indicates the angle that an object will lock to while rotating. Can get from canvas.

Optional snapThreshold

snapThreshold: null | number | undefined

Indicates the distance from the snapAngle the rotation will lock to the snapAngle. Can get from canvas.

Optional stateProperties

stateProperties: string[] | undefined

List of properties to consider when checking if state of an object is changed (fabric.Object#hasStateChanged) as well as for history (undo/redo) purposes

Optional statefullCache

statefullCache: boolean | undefined

When true, object properties are checked for cache invalidation. In some particular situation you may want this to be disabled ( spray brush, very big, groups) or if your application does not allow you to modify properties for groups child you want to disable it for groups. default to false since 1.7.0

default

false

Optional staticPort

staticPort: (portOption: Partial<PortObject>) => PortObject[]

Type declaration

Optional stroke

stroke: string | undefined

When defined, an object is rendered via stroke and this property specifies its color

Optional strokeDashArray

strokeDashArray: number[] | undefined

Array specifying dash pattern of an object's stroke (stroke must be defined)

Optional strokeDashOffset

strokeDashOffset: number | undefined

Line offset of an object's stroke

default

Optional strokeLineCap

strokeLineCap: string | undefined

Line endings style of an object's stroke (one of "butt", "round", "square")

Optional strokeLineJoin

strokeLineJoin: string | undefined

Corner style of an object's stroke (one of "bevil", "round", "miter")

Optional strokeMiterLimit

strokeMiterLimit: number | undefined

Maximum miter length (used for strokeLineJoin = "miter") of an object's stroke

Optional strokeUniform

strokeUniform: boolean | undefined

When false, the stoke width will scale with the object. When true, the stroke will always match the exact pixel size entered for stroke width. default to false

since

2.6.0

default

false

Optional strokeWidth

strokeWidth: number | undefined

Width of a stroke used to render this object

Optional subTargetCheck

subTargetCheck: boolean | undefined

Indicates if click, mouseover, mouseout events & hoverCursor should also check for subtargets

Optional superType

superType: string

Object Super type

Optional toPort

toPort: PortObject

Optional toPortOption

toPortOption: () => Partial<PortObject>

Type declaration

Optional tooltip

Tooltip property

Optional top

top: number | undefined

Top position of an object. Note that by default it's relative to object center. You can change this by setting originY={top/center/bottom}

Optional transparentCorners

transparentCorners: boolean | undefined

When true, object's controlling corners are rendered as transparent inside (i.e. stroke instead of fill)

Optional type

type: string | undefined

Type of an object (rect, circle, path, etc.). Note that this property is meant to be read-only and not meant to be modified. If you modify, certain parts of Fabric (such as JSON loading) won't work correctly.

Optional useSetOnGroup

useSetOnGroup: boolean | undefined

setOnGroup is a method used for TextBox that is no more used since 2.0.0 The behavior is still available setting this boolean to true.

since

2.0.0

default

Optional visible

visible: boolean | undefined

When set to false, an object is not rendered on canvas

Optional width

width: number | undefined

Object width

Methods

Private _calcBounds

  • _calcBounds(onlyWidthHeight?: boolean): void
  • Parameters

    • Optional onlyWidthHeight: boolean

    Returns void

Private _onObjectRemoved

  • _onObjectRemoved(object: Object): void
  • Parameters

    • object: Object

    Returns void

Private _restoreObjectsState

  • _restoreObjectsState(): Group
  • _restoreObjectsState(): Group
  • Retores original state of each of group objects (original state is that which was before group was created).

    chainable

    Returns Group

    thisArg

  • Retores original state of each of group objects (original state is that which was before group was created).

    chainable

    Returns Group

    thisArg

Private _updateObjectsCoords

  • _updateObjectsCoords(center?: Point): void
  • Parameters

    • Optional center: Point

    Returns void

add

  • add(...object: Object[]): Group
  • Adds objects to collection, then renders canvas (if renderOnAddRemove is not false) Objects should be instances of (or inherit from) fabric.Object

    Parameters

    • Rest ...object: Object[]

      Zero or more fabric instances

    Returns Group

addWithUpdate

  • addWithUpdate(object?: Object): Group
  • addWithUpdate(object: Object): Group
  • Adds an object to a group; Then recalculates group's dimension, position.

    chainable

    Parameters

    • Optional object: Object

    Returns Group

    thisArg

  • Adds an object to a group; Then recalculates group's dimension, position.

    chainable

    Parameters

    • object: Object

    Returns Group

    thisArg

animate

  • animate(property: string, value: number | string, options?: IAnimationOptions): Object
  • animate(properties: {}, options?: IAnimationOptions): Object
  • Animates object's properties object.animate('left', ..., {duration: ...});

    Parameters

    • property: string

      Property to animate

    • value: number | string

      Value to animate property

    • Optional options: IAnimationOptions

      The animation options

    Returns Object

  • Animates object's properties object.animate({ left: ..., top: ... }, { duration: ... });

    Parameters

    • properties: {}

      Properties to animate with values to animate to

      • [key: string]: number | string
    • Optional options: IAnimationOptions

      The animation options

    Returns Object

complexity

  • complexity(): number
  • Returns number representation of a collection complexity

    Returns number

    complexity

contains

  • contains(object: Object): boolean
  • Returns true if collection contains an object

    Parameters

    • object: Object

      Object to check against

    Returns boolean

    true if collection contains an object

destroy

  • destroy(): Group
  • Destroys a group (restoring state of its objects)

    chainable

    Returns Group

    thisArg

drawObject

  • drawObject(ctx: CanvasRenderingContext2D): void
  • Execute the drawing operation for an object on a specified context

    Parameters

    • ctx: CanvasRenderingContext2D

      Context to render on

    Returns void

fire

  • fire(eventName: string, options?: any): Object
  • Fires event with an optional options object

    memberof

    fabric.Observable

    chainable

    Parameters

    • eventName: string

      Event name to fire

    • Optional options: any

    Returns Object

    thisArg

forEachObject

  • forEachObject(callback: (element: Object, index: number, array: Object[]) => void, context?: any): Group
  • Executes given function for each object in this group

    Parameters

    • callback: (element: Object, index: number, array: Object[]) => void
        • (element: Object, index: number, array: Object[]): void
        • Parameters

          • element: Object
          • index: number
          • array: Object[]

          Returns void

    • Optional context: any

      Context (aka thisObject)

    Returns Group

    thisArg

getObjects

  • getObjects(type?: string): Object[]
  • Returns an array of children objects of this instance Type parameter introduced in 1.3.10

    Parameters

    • Optional type: string

    Returns Object[]

insertAt

  • insertAt(object: Object, index: number, nonSplicing: boolean): Group
  • 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

    chainable

    Parameters

    • object: Object

      Object to insert

    • index: number

      Index to insert object at

    • nonSplicing: boolean

      When true, no splicing (shifting) of objects occurs

    Returns Group

    thisArg

isCacheDirty

  • isCacheDirty(skipCanvas?: boolean): boolean
  • Check if cache is dirty

    Parameters

    • Optional skipCanvas: boolean

    Returns boolean

isEmpty

  • isEmpty(): boolean
  • Returns true if collection contains no objects

    Returns boolean

    true if collection is empty

isOnACache

  • isOnACache(): boolean
  • Check if this group or its parent group are caching, recursively up

    Returns boolean

item

  • item(index: number): Group
  • Returns object at specified index

    Parameters

    • index: number

    Returns Group

    thisArg

off

  • off(eventName?: string | any, handler?: (e: IEvent) => void): Object
  • Stops event observing for a particular event handler. Calling this method without arguments removes all handlers for all events

    Parameters

    • Optional eventName: string | any

      Event name (eg. 'after:render') or object with key/value pairs (eg. {'after:render': handler, 'selection:cleared': handler})

    • Optional handler: (e: IEvent) => void

      Function to be deleted from EventListeners

        • (e: IEvent): void
        • Parameters

          • e: IEvent

          Returns void

    Returns Object

on

  • on(eventName: "mouse:up" | "mouse:down" | "mouse:move" | "mouse:up:before" | "mouse:down:before" | "mouse:move:before" | "mouse:dblclick" | "mouse:over" | "mouse:out", handler: (e: IEvent<MouseEvent>) => void): Object
  • on(eventName: "mouse:wheel", handler: (e: IEvent<WheelEvent>) => void): Object
  • on(eventName: string, handler: (e: IEvent) => void): Object
  • Observes specified event

    Parameters

    • eventName: "mouse:up" | "mouse:down" | "mouse:move" | "mouse:up:before" | "mouse:down:before" | "mouse:move:before" | "mouse:dblclick" | "mouse:over" | "mouse:out"

      Event name (eg. 'after:render')

    • handler: (e: IEvent<MouseEvent>) => void

      Function that receives a notification when an event of the specified type occurs

        • (e: IEvent<MouseEvent>): void
        • Parameters

          • e: IEvent<MouseEvent>

          Returns void

    Returns Object

  • Parameters

    • eventName: "mouse:wheel"
    • handler: (e: IEvent<WheelEvent>) => void
        • (e: IEvent<WheelEvent>): void
        • Parameters

          • e: IEvent<WheelEvent>

          Returns void

    Returns Object

  • Parameters

    • eventName: string
    • handler: (e: IEvent) => void
        • (e: IEvent): void
        • Parameters

          • e: IEvent

          Returns void

    Returns Object

realizeTransform

  • realizeTransform(object: Object): Object
  • Realises the transform from this group onto the supplied object i.e. it tells you what would happen if the supplied object was in the group, and then the group was destroyed. It mutates the supplied object.

    Parameters

    • object: Object

    Returns Object

    transformedObject

remove

  • remove(...object: Object[]): Group
  • Removes objects from a collection, then renders canvas (if renderOnAddRemove is not false)

    chainable

    Parameters

    • Rest ...object: Object[]

      Zero or more fabric instances

    Returns Group

    thisArg

removeWithUpdate

  • removeWithUpdate(object: Object): Group
  • Removes an object from a group; Then recalculates group's dimension, position.

    chainable

    Parameters

    • object: Object

    Returns Group

    thisArg

render

  • render(ctx: CanvasRenderingContext2D): void
  • Renders instance on a given context

    Parameters

    • ctx: CanvasRenderingContext2D

      context to render instance on

    Returns void

setObjectsCoords

  • setObjectsCoords(): Group
  • Sets coordinates of all group objects

    chainable

    Returns Group

    thisArg

shouldCache

  • shouldCache(): boolean
  • Decide if the object should cache or not. Create its own cache level objectCaching is a global flag, wins over everything needsItsOwnCache should be used when the object drawing method requires a cache step. None of the fabric classes requires it. Generally you do not cache objects in groups because the group outside is cached.

    Returns boolean

size

  • size(): number
  • Returns a size of a collection (i.e: length of an array containing its objects)

    Returns number

    Collection size

toActiveSelection

  • toActiveSelection(): ActiveSelection
  • make a group an active selection, remove the group from canvas the group has to be on canvas for this to work.

    chainable

    Returns ActiveSelection

    thisArg

toClipPathSVG

  • toClipPathSVG(reviver?: Function): string
  • Returns svg clipPath representation of an instance

    Parameters

    • Optional reviver: Function

    Returns string

    svg representation of an instance

toSVG

  • toSVG(reviver?: Function): string
  • Returns svg representation of an instance

    Parameters

    • Optional reviver: Function

    Returns string

    svg representation of an instance

ungroupOnCanvas

  • ungroupOnCanvas(): Group
  • Destroys a group (restoring state of its objects)

    chainable

    Returns Group

    thisArg

willDrawShadow

  • willDrawShadow(): boolean
  • Check if this object or a child object will cast a shadow

    Returns boolean

Static fromObject

  • fromObject(object: any, callback: (group: Group) => any): void
  • Returns {@link fabric.Group} instance from an object representation

    Parameters

    • object: any

      Object to create a group from

    • callback: (group: Group) => any
        • (group: Group): any
        • Parameters

          • group: Group

          Returns any

    Returns void

Generated using TypeDoc