Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface CubeObject

Hierarchy

  • Object & 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 }
    • CubeObject

Indexable

[key: string]: any

Index

Constructors

Properties

Methods

Constructors

constructor

  • new CubeObject(options?: IObjectOptions): CubeObject
  • Parameters

    • Optional options: IObjectOptions

    Returns CubeObject

Properties

_controlsVisibility

_controlsVisibility: { bl?: boolean | undefined; br?: boolean | undefined; mb?: boolean | undefined; ml?: boolean | undefined; mr?: boolean | undefined; mt?: boolean | undefined; mtr?: boolean | undefined; tl?: boolean | undefined; tr?: boolean | undefined }

Type declaration

  • Optional bl?: boolean | undefined
  • Optional br?: boolean | undefined
  • Optional mb?: boolean | undefined
  • Optional ml?: boolean | undefined
  • Optional mr?: boolean | undefined
  • Optional mt?: boolean | undefined
  • Optional mtr?: boolean | undefined
  • Optional tl?: boolean | undefined
  • Optional tr?: boolean | undefined

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 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

controls

controls: {}

Type declaration

  • [key: string]: Control

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 data

data: any

Not used by fabric, just for convenience

Optional dblclick

dblclick: boolean

Is enable double click

Optional deletable

deletable: boolean

Is possible delete

Optional description

description: string
description

Optional dirty

dirty: boolean | undefined

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

Optional editable

editable: boolean

Object editable

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 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 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 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 shadow

shadow: Shadow | string | undefined

Shadow object representing shadow of this shape

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 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 superType

superType: string

Object Super type

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 visible

visible: boolean | undefined

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

Optional width

width: number | undefined

Object width

Static Optional NUM_FRACTION_DIGITS

NUM_FRACTION_DIGITS: number | undefined

Defines the number of fraction digits to use when serializing object values.

Methods

Private _applyPatternGradientTransform

  • _applyPatternGradientTransform(ctx: CanvasRenderingContext2D, filler: string | Pattern | Gradient): void
  • Parameters

    • ctx: CanvasRenderingContext2D

      Context to render on

    • filler: string | Pattern | Gradient

      fabric.Pattern or fabric.Gradient

    Returns void

    offset.offsetX offset for text rendering

Private _findTargetCorner

  • _findTargetCorner(pointer: { x: number; y: number }): boolean | "bl" | "br" | "mb" | "ml" | "mr" | "mt" | "tl" | "tr" | "mtr"
  • Determines which corner has been clicked

    Parameters

    • pointer: { x: number; y: number }

      The pointer indicating the mouse position

      • x: number
      • y: number

    Returns boolean | "bl" | "br" | "mb" | "ml" | "mr" | "mt" | "tl" | "tr" | "mtr"

    corner code (tl, tr, bl, br, etc.), or false if nothing is found

Private _getControlsVisibility

  • _getControlsVisibility(): { bl: boolean; br: boolean; mb: boolean; ml: boolean; mr: boolean; mt: boolean; mtr: boolean; tl: boolean; tr: boolean }
  • Returns the instance of the control visibility set for this object.

    Returns { bl: boolean; br: boolean; mb: boolean; ml: boolean; mr: boolean; mt: boolean; mtr: boolean; tl: boolean; tr: boolean }

    • bl: boolean
    • br: boolean
    • mb: boolean
    • ml: boolean
    • mr: boolean
    • mt: boolean
    • mtr: boolean
    • tl: boolean
    • tr: boolean

Private _getLeftTopCoords

  • _getLeftTopCoords(): Point
  • Returns the top, left coordinates

    Returns Point

_getNonTransformedDimensions

  • _getNonTransformedDimensions(): { x: number; y: number }

_getTransformedDimensions

  • _getTransformedDimensions(skewX?: number, skewY?: number): { x: number; y: number }
  • Parameters

    • Optional skewX: number
    • Optional skewY: number

    Returns { x: number; y: number }

    • x: number
    • y: number

Private _removeShadow

  • _removeShadow(ctx: CanvasRenderingContext2D): void
  • Parameters

    • ctx: CanvasRenderingContext2D

      Context to render on

    Returns void

Private _render

  • _render(ctx: CanvasRenderingContext2D): void
  • Parameters

    • ctx: CanvasRenderingContext2D

      Context to render on

    Returns void

Private _renderFill

  • _renderFill(ctx: CanvasRenderingContext2D): void
  • Parameters

    • ctx: CanvasRenderingContext2D

      Context to render on

    Returns void

Private _renderPaintInOrder

  • _renderPaintInOrder(ctx: CanvasRenderingContext2D): void
  • Parameters

    • ctx: CanvasRenderingContext2D

      Context to render on

    Returns void

Private _renderStroke

  • _renderStroke(ctx: CanvasRenderingContext2D): void
  • Parameters

    • ctx: CanvasRenderingContext2D

    Returns void

Private _set

  • _set(key: string, value: any): Object
  • Parameters

    • key: string
    • value: any

    Returns Object

Private _setLineDash

  • _setLineDash(ctx: CanvasRenderingContext2D, dashArray: number[], alternative?: (ctx: CanvasRenderingContext2D) => void): void
  • Parameters

    • ctx: CanvasRenderingContext2D

      Context to set the dash line on

    • dashArray: number[]

      array representing dashes

    • Optional alternative: (ctx: CanvasRenderingContext2D) => void

      function to call if browser does not support lineDash

        • (ctx: CanvasRenderingContext2D): void
        • Parameters

          • ctx: CanvasRenderingContext2D

          Returns void

    Returns void

adjustPosition

  • adjustPosition(to: string): void
  • Parameters

    • to: string

      One of 'left', 'center', 'right'

    Returns void

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

bringForward

  • bringForward(intersecting?: boolean): Object
  • Moves an object up in stack of drawn objects

    Parameters

    • Optional intersecting: boolean

    Returns Object

bringToFront

  • bringToFront(): Object
  • Moves an object to the top of the stack of drawn objects

    Returns Object

calcCoords

  • calcCoords(absolute?: boolean): any
  • Calculate and returns the .coords of an object.

    chainable

    Parameters

    • Optional absolute: boolean

    Returns any

    Object with tl, tr, br, bl ....

calcOwnMatrix

  • calcOwnMatrix(): any[]
  • calculate transform matrix that represents the current transformations from the object's properties, this matrix does not include the group transformation

    Returns any[]

    transform matrix for the object

calcTransformMatrix

  • calcTransformMatrix(skipGroup?: boolean): any[]
  • calculate trasform Matrix that represent current transformation from object properties.

    Parameters

    • Optional skipGroup: boolean

    Returns any[]

    matrix Transform Matrix for the object

center

  • center(): Object
  • Centers object vertically and horizontally on canvas to which is was added last You might need to call setCoords on an object after centering, to update controls area.

    Returns Object

centerH

  • centerH(): Object
  • Centers object horizontally on canvas to which it was added last. You might need to call setCoords on an object after centering, to update controls area.

    Returns Object

centerV

  • centerV(): Object
  • Centers object vertically on canvas to which it was added last. You might need to call setCoords on an object after centering, to update controls area.

    Returns Object

clone

  • clone(callback: Function, propertiesToInclude?: string[]): void
  • Clones an instance, using a callback method will work for every object.

    Parameters

    • callback: Function

      Callback is invoked with a clone as a first argument

    • Optional propertiesToInclude: string[]

    Returns void

cloneAsImage

  • cloneAsImage(callback: Function, options?: IDataURLOptions): Object
  • Creates an instance of fabric.Image out of an object

    Parameters

    • callback: Function

      callback, invoked with an instance as a first argument

    • Optional options: IDataURLOptions

    Returns Object

complexity

  • complexity(): number
  • Returns complexity of an instance

    Returns number

containsPoint

  • containsPoint(point: Point, lines?: any, absolute?: boolean, calculate?: boolean): boolean
  • Checks if point is inside the object

    Parameters

    • point: Point

      Point to check against

    • Optional lines: any
    • Optional absolute: boolean
    • Optional calculate: boolean

    Returns boolean

    true if point is inside the object

drawBorders

  • drawBorders(ctx: CanvasRenderingContext2D, styleOverride?: any): Object
  • Draws borders of an object's bounding box. Requires public properties: width, height Requires public options: padding, borderColor

    chainable

    Parameters

    • ctx: CanvasRenderingContext2D

      Context to draw on

    • Optional styleOverride: any

      object to override the object style

    Returns Object

    thisArg

drawBordersInGroup

  • drawBordersInGroup(ctx: CanvasRenderingContext2D, options?: any, styleOverride?: any): Object
  • Draws borders of an object's bounding box when it is inside a group. Requires public properties: width, height Requires public options: padding, borderColor

    chainable

    Parameters

    • ctx: CanvasRenderingContext2D

      Context to draw on

    • Optional options: any

      object representing current object parameters

    • Optional styleOverride: any

      object to override the object style

    Returns Object

    thisArg

drawCacheOnCanvas

  • drawCacheOnCanvas(ctx: CanvasRenderingContext2D): void
  • Paint the cached copy of the object on the target context.

    Parameters

    • ctx: CanvasRenderingContext2D

      Context to render on

    Returns void

drawClipPathOnCache

  • drawClipPathOnCache(ctx: CanvasRenderingContext2D): void
  • Execute the drawing operation for an object clipPath

    Parameters

    • ctx: CanvasRenderingContext2D

      Context to render on

    Returns void

drawControls

  • drawControls(ctx: CanvasRenderingContext2D, styleOverride?: any): Object
  • Draws corners of an object's bounding box. Requires public properties: width, height Requires public options: cornerSize, padding

    chainable

    Parameters

    • ctx: CanvasRenderingContext2D

      Context to draw on

    • Optional styleOverride: any

      object to override the object style

    Returns Object

    thisArg

drawCorners

  • drawCorners(context: CanvasRenderingContext2D): Object
  • Draws corners of an object's bounding box. Requires public properties: width, height Requires public options: cornerSize, padding

    Parameters

    • context: CanvasRenderingContext2D

    Returns Object

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

drawSelectionBackground

  • drawSelectionBackground(ctx: CanvasRenderingContext2D): Object
  • Draws a colored layer behind the object, inside its selection borders. Requires public options: padding, selectionBackgroundColor this function is called when the context is transformed has checks to be skipped when the object is on a staticCanvas

    chainable

    Parameters

    • ctx: CanvasRenderingContext2D

      Context to draw on

    Returns Object

    thisArg

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

fxStraighten

  • fxStraighten(callbacks: Callbacks): Object
  • Same as straighten but with animation

    Parameters

    • callbacks: Callbacks

    Returns Object

get

  • get<K>(property: K): this[K]
  • Basic getter

    Type parameters

    • K: keyof this

    Parameters

    • property: K

      Property name

    Returns this[K]

getBoundingRect

  • getBoundingRect(absolute?: boolean, calculate?: boolean): { height: number; left: number; top: number; width: number }
  • Returns coordinates of object's bounding rectangle (left, top, width, height) the box is intented as aligned to axis of canvas.

    Parameters

    • Optional absolute: boolean
    • Optional calculate: boolean

    Returns { height: number; left: number; top: number; width: number }

    Object with left, top, width, height properties

    • height: number
    • left: number
    • top: number
    • width: number

getCenterPoint

  • getCenterPoint(): Point
  • Returns the real center coordinates of the object

    Returns Point

getCoords

  • getCoords(absolute?: boolean, calculate?: boolean): []
  • return correct set of coordinates for intersection

    Parameters

    • Optional absolute: boolean
    • Optional calculate: boolean

    Returns []

getLocalPointer

  • getLocalPointer(e: Event | undefined, pointer?: { x: number; y: number }): { x: number; y: number }
  • Returns coordinates of a pointer relative to an object

    Parameters

    • e: Event | undefined

      Event to operate upon

    • Optional pointer: { x: number; y: number }
      • x: number
      • y: number

    Returns { x: number; y: number }

    • x: number
    • y: number

getObjectOpacity

  • getObjectOpacity(): number
  • Return the object opacity counting also the group property

    Returns number

getObjectScaling

  • getObjectScaling(): { scaleX: number; scaleY: number }
  • Return the object scale factor counting also the group scaling

    Returns { scaleX: number; scaleY: number }

    object with scaleX and scaleY properties

    • scaleX: number
    • scaleY: number

getPointByOrigin

  • getPointByOrigin(originX: string, originY: string): Point
  • Returns the coordinates of the object as if it has a different origin

    Parameters

    • originX: string

      Horizontal origin: 'left', 'center' or 'right'

    • originY: string

      Vertical origin: 'top', 'center' or 'bottom'

    Returns Point

getScaledHeight

  • getScaledHeight(): number
  • Returns height of an object bounding box counting transformations before 2.0 it was named getHeight();

    Returns number

    height value

getScaledWidth

  • getScaledWidth(): number
  • Returns width of an object bounding box counting transformations before 2.0 it was named getWidth();

    Returns number

    width value

getSvgCommons

  • getSvgCommons(): string
  • Returns id attribute for svg output

    Returns string

getSvgFilter

  • getSvgFilter(): string
  • Returns filter for svg shadow

    Returns string

getSvgSpanStyles

  • getSvgSpanStyles(style: any, useWhiteSpace?: boolean): string
  • Returns styles-string for svg-export

    Parameters

    • style: any

      the object from which to retrieve style properties

    • Optional useWhiteSpace: boolean

      a boolean to include an additional attribute in the style.

    Returns string

getSvgStyles

  • getSvgStyles(skipShadow?: boolean): string
  • Returns styles-string for svg-export

    Parameters

    • Optional skipShadow: boolean

      a boolean to skip shadow filter output

    Returns string

getSvgTextDecoration

  • getSvgTextDecoration(style: any): string
  • Returns text-decoration property for svg-export

    Parameters

    • style: any

      the object from which to retrieve style properties

    Returns string

getSvgTransform

  • getSvgTransform(full?: boolean, additionalTransform?: string): string
  • Returns transform-string for svg-export

    Parameters

    • Optional full: boolean
    • Optional additionalTransform: string

    Returns string

getSvgTransformMatrix

  • getSvgTransformMatrix(): string
  • Returns transform-string for svg-export from the transform matrix of single elements

    Returns string

getTotalObjectScaling

  • getTotalObjectScaling(): { scaleX: number; scaleY: number }
  • Return the object scale factor counting also the group scaling, zoom and retina

    Returns { scaleX: number; scaleY: number }

    object with scaleX and scaleY properties

    • scaleX: number
    • scaleY: number

getViewportTransform

  • getViewportTransform(): any[]
  • Retrieves viewportTransform from Object's canvas if possible

    Returns any[]

hasStateChanged

  • hasStateChanged(propertySet: string): boolean
  • Returns true if object state (one of its state properties) was changed

    Parameters

    • propertySet: string

    Returns boolean

    true if instance' state has changed since {@link fabric.Object#saveState} was called

initialize

  • initialize(options?: IObjectOptions): Object
  • Parameters

    • Optional options: IObjectOptions

    Returns Object

intersectsWithObject

  • intersectsWithObject(other: Object, absolute?: boolean, calculate?: boolean): boolean
  • Checks if object intersects with another object

    Parameters

    • other: Object

      Object to test

    • Optional absolute: boolean
    • Optional calculate: boolean

    Returns boolean

    true if object intersects with another object

intersectsWithRect

  • intersectsWithRect(pointTL: any, pointBR: any, absolute?: boolean, calculate?: boolean): boolean
  • Checks if object intersects with an area formed by 2 points

    Parameters

    • pointTL: any

      top-left point of area

    • pointBR: any

      bottom-right point of area

    • Optional absolute: boolean
    • Optional calculate: boolean

    Returns boolean

    true if object intersects with an area formed by 2 points

isCacheDirty

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

    Parameters

    • Optional skipCanvas: boolean

      skip canvas checks because this object is painted on parent canvas.

    Returns boolean

isContainedWithinObject

  • isContainedWithinObject(other: Object, absolute?: boolean, calculate?: boolean): boolean
  • Checks if object is fully contained within area of another object

    Parameters

    • other: Object

      Object to test

    • Optional absolute: boolean
    • Optional calculate: boolean

    Returns boolean

    true if object is fully contained within area of another object

isContainedWithinRect

  • isContainedWithinRect(pointTL: any, pointBR: any, absolute?: boolean, calculate?: boolean): boolean
  • Checks if object is fully contained within area formed by 2 points

    Parameters

    • pointTL: any

      top-left point of area

    • pointBR: any

      bottom-right point of area

    • Optional absolute: boolean
    • Optional calculate: boolean

    Returns boolean

isControlVisible

  • isControlVisible(controlName: string): boolean
  • Returns true if the specified control is visible, false otherwise.

    Parameters

    • controlName: string

      The name of the control. Possible values are 'tl', 'tr', 'br', 'bl', 'ml', 'mt', 'mr', 'mb', 'mtr'.

    Returns boolean

isOnScreen

  • isOnScreen(calculate?: boolean): boolean
  • Checks if object is contained within the canvas with current viewportTransform the check is done stopping at first point that appears on screen

    Parameters

    • Optional calculate: boolean

    Returns boolean

    true if object is fully or partially contained within canvas

isPartiallyOnScreen

  • isPartiallyOnScreen(calculate?: boolean): boolean
  • Checks if object is partially contained within the canvas with current viewportTransform

    Parameters

    • Optional calculate: boolean

    Returns boolean

    true if object is partially contained within canvas

isType

  • isType(type: string): boolean
  • Returns true if specified type is identical to the type of an instance

    Parameters

    • type: string

      Type to check against

    Returns boolean

moveTo

  • moveTo(index: number): Object
  • Moves an object to specified level in stack of drawn objects

    Parameters

    • index: number

      New position of object

    Returns Object

needsItsOwnCache

  • needsItsOwnCache(): boolean
  • When set to true, force the object to have its own cache, even if it is inside a group it may be needed when your object behave in a particular way on the cache and always needs its own isolated canvas to render correctly. Created to be overridden since 1.7.12

    Returns boolean

    false

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

onDeselect

  • onDeselect(options: { e?: Event | undefined; object?: Object | undefined }): boolean
  • onDeselect(options: { e?: Event | undefined; object?: Object | undefined }): boolean
  • This callback function is called every time _discardActiveObject or _setActiveObject try to to deselect this object. If the function returns true, the process is cancelled

    Parameters

    • options: { e?: Event | undefined; object?: Object | undefined }
      • Optional e?: Event | undefined
      • Optional object?: Object | undefined

    Returns boolean

    true to cancel selection

  • This callback function is called every time _discardActiveObject or _setActiveObject try to to deselect this object. If the function returns true, the process is cancelled

    Parameters

    • options: { e?: Event | undefined; object?: Object | undefined }
      • Optional e?: Event | undefined
      • Optional object?: Object | undefined

    Returns boolean

onSelect

  • onSelect(options: { e?: Event | undefined }): boolean
  • This callback function is called every time _discardActiveObject or _setActiveObject try to to select this object. If the function returns true, the process is cancelled

    Parameters

    • options: { e?: Event | undefined }
      • Optional e?: Event | undefined

    Returns boolean

render

  • render(ctx: CanvasRenderingContext2D): void
  • Renders an object on a specified context

    Parameters

    • ctx: CanvasRenderingContext2D

      Context to render on

    Returns void

rotate

  • rotate(angle: number): Object
  • Sets "angle" of an instance

    Parameters

    • angle: number

      Angle value

    Returns Object

saveState

  • saveState(options?: { propertySet?: string | undefined; stateProperties?: any[] | undefined }): Object
  • Saves state of an object

    Parameters

    • Optional options: { propertySet?: string | undefined; stateProperties?: any[] | undefined }
      • Optional propertySet?: string | undefined
      • Optional stateProperties?: any[] | undefined

    Returns Object

    thisArg

scale

  • scale(value: number): Object
  • Scales an object (equally by x and y)

    Parameters

    • value: number

      Scale factor

    Returns Object

    thisArg

scaleToHeight

  • scaleToHeight(value: number, absolute?: boolean): this
  • Scales an object to a given height, with respect to bounding box (scaling by x/y equally)

    Parameters

    • value: number

      New height value

    • Optional absolute: boolean

    Returns this

scaleToWidth

  • scaleToWidth(value: number, absolute?: boolean): this
  • Scales an object to a given width, with respect to bounding box (scaling by x/y equally)

    Parameters

    • value: number

      New width value

    • Optional absolute: boolean

    Returns this

sendBackwards

  • sendBackwards(intersecting?: boolean): Object
  • Moves an object down in stack of drawn objects

    Parameters

    • Optional intersecting: boolean

    Returns Object

sendToBack

  • sendToBack(): Object
  • Moves an object to the bottom of the stack of drawn objects

    Returns Object

set

  • set<K>(key: K, value: this[K] | ((value: this[K]) => this[K])): Object
  • set(options: Partial<this>): Object
  • Sets property to a given value. When changing position/dimension -related properties (left, top, scale, angle, etc.) set does not update position of object's borders/controls. If you need to update those, call setCoords().

    Type parameters

    • K: keyof this

    Parameters

    • key: K

      Property name

    • value: this[K] | ((value: this[K]) => this[K])

      Property value (if function, the value is passed into it and its return value is used as a new one)

    Returns Object

  • Sets property to a given value. When changing position/dimension -related properties (left, top, scale, angle, etc.) set does not update position of object's borders/controls. If you need to update those, call setCoords().

    Parameters

    • options: Partial<this>

      Property object, iterate over the object properties

    Returns Object

setAngle

  • setAngle(angle: number): Object
  • Sets "angle" of an instance

    Parameters

    • angle: number

      Angle value

    Returns Object

setControlVisible

  • setControlVisible(controlName: string, visible: boolean): Object
  • Sets the visibility of the specified control.

    Parameters

    • controlName: string

      The name of the control. Possible values are 'tl', 'tr', 'br', 'bl', 'ml', 'mt', 'mr', 'mb', 'mtr'.

    • visible: boolean

      true to set the specified control visible, false otherwise

    Returns Object

setControlsVisibility

  • setControlsVisibility(options?: { bl?: boolean | undefined; br?: boolean | undefined; mb?: boolean | undefined; ml?: boolean | undefined; mr?: boolean | undefined; mt?: boolean | undefined; mtr?: boolean | undefined; tl?: boolean | undefined; tr?: boolean | undefined }): this
  • Sets the visibility state of object controls.

    Parameters

    • Optional options: { bl?: boolean | undefined; br?: boolean | undefined; mb?: boolean | undefined; ml?: boolean | undefined; mr?: boolean | undefined; mt?: boolean | undefined; mtr?: boolean | undefined; tl?: boolean | undefined; tr?: boolean | undefined }
      • Optional bl?: boolean | undefined
      • Optional br?: boolean | undefined
      • Optional mb?: boolean | undefined
      • Optional ml?: boolean | undefined
      • Optional mr?: boolean | undefined
      • Optional mt?: boolean | undefined
      • Optional mtr?: boolean | undefined
      • Optional tl?: boolean | undefined
      • Optional tr?: boolean | undefined

    Returns this

setCoords

  • setCoords(skipCorners?: boolean): this
  • Sets corner position coordinates based on current angle, width and height. oCoords are used to find the corners aCoords are used to quickly find an object on the canvas lineCoords are used to quickly find object during pointer events. See When-to-call-setCoords

    chainable

    Parameters

    • Optional skipCorners: boolean

    Returns this

    thisArg

setOnGroup

  • setOnGroup(): void
  • This callback function is called by the parent group of an object every time a non-delegated property changes on the group. It is passed the key and value as parameters. Not adding in this function's signature to avoid Travis build error about unused variables.

    Returns void

setOptions

  • setOptions(options: IObjectOptions): void
  • setOptions(options?: any): void
  • Parameters

    • options: IObjectOptions

    Returns void

  • Sets object's properties from options

    Parameters

    • Optional options: any

    Returns void

setPositionByOrigin

  • setPositionByOrigin(pos: Point, originX: string, originY: string): void
  • Sets the position of the object taking into consideration the object's origin

    Parameters

    • pos: Point

      The new position of the object

    • originX: string

      Horizontal origin: 'left', 'center' or 'right'

    • originY: string

      Vertical origin: 'top', 'center' or 'bottom'

    Returns void

setSourcePath

  • setSourcePath(value: string): Object
  • setSourcePath(value: string): Object
  • Sets sourcePath of an object

    Parameters

    • value: string

      Value to set sourcePath to

    Returns Object

  • Sets sourcePath of an object

    Parameters

    • value: string

      Value to set sourcePath to

    Returns Object

setupState

  • setupState(options?: any): Object
  • Setups state of an object

    Parameters

    • Optional options: any

    Returns Object

    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

straighten

  • straighten(): Object
  • Straightens an object (rotating it from current angle to one of 0, 90, 180, 270, etc. depending on which is closer)

    Returns Object

toCanvasElement

  • toCanvasElement(options?: IDataURLOptions): HTMLCanvasElement
  • Converts an object into a HTMLCanvas element

    Parameters

    • Optional options: IDataURLOptions

      Options object

    Returns HTMLCanvasElement

    Returns a new HTMLCanvasElement painted with the current canvas object

toClipPathSVG

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

    Parameters

    • Optional reviver: Function

    Returns string

    svg representation of an instance

toDataURL

  • toDataURL(options: IDataURLOptions): string
  • Converts an object into a data-url-like string

    Parameters

    • options: IDataURLOptions

      Options object

    Returns string

toDatalessObject

  • toDatalessObject(propertiesToInclude?: string[]): any
  • Returns (dataless) object representation of an instance

    Parameters

    • Optional propertiesToInclude: string[]

    Returns any

toJSON

  • toJSON(propertiesToInclude?: string[]): any
  • Returns a JSON representation of an instance

    Parameters

    • Optional propertiesToInclude: string[]

    Returns any

toLocalPoint

  • toLocalPoint(point: Point, originX: string, originY: string): Point
  • Returns the point in local coordinates

    Parameters

    • point: Point

      The point relative to the global coordinate system

    • originX: string

      Horizontal origin: 'left', 'center' or 'right'

    • originY: string

      Vertical origin: 'top', 'center' or 'bottom'

    Returns Point

toObject

  • toObject(propertiesToInclude?: string[]): any
  • Returns an object representation of an instance

    Parameters

    • Optional propertiesToInclude: string[]

    Returns any

toSVG

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

    Parameters

    • Optional reviver: Function

    Returns string

    svg representation of an instance

toString

  • toString(): string
  • Returns a string representation of an instance

    Returns string

toggle

  • toggle(property: keyof this): Object
  • Toggles specified property from true to false or from false to true

    Parameters

    • property: keyof this

      Property to toggle

    Returns Object

transform

  • transform(ctx: CanvasRenderingContext2D): void
  • Transforms context when rendering an object

    Parameters

    • ctx: CanvasRenderingContext2D

      Context

    Returns void

translateToCenterPoint

  • translateToCenterPoint(point: Point, originX: string, originY: string): Point
  • Translates the coordinates from origin to center coordinates (based on the object's dimensions)

    Parameters

    • point: Point

      The point which corresponds to the originX and originY params

    • originX: string

      Horizontal origin: 'left', 'center' or 'right'

    • originY: string

      Vertical origin: 'top', 'center' or 'bottom'

    Returns Point

translateToGivenOrigin

  • translateToGivenOrigin(pointL: Point, fromOriginX: string, fromOriginY: string, toOriginX: string, toOriginY: string): Point
  • Translates the coordinates from a set of origin to another (based on the object's dimensions)

    Parameters

    • pointL: Point
    • fromOriginX: string

      Horizontal origin: 'left', 'center' or 'right'

    • fromOriginY: string

      Vertical origin: 'top', 'center' or 'bottom'

    • toOriginX: string

      Horizontal origin: 'left', 'center' or 'right'

    • toOriginY: string

      Vertical origin: 'top', 'center' or 'bottom'

    Returns Point

translateToOriginPoint

  • translateToOriginPoint(center: Point, originX: string, originY: string): Point
  • Translates the coordinates from center to origin coordinates (based on the object's dimensions)

    Parameters

    • center: Point

      The point which corresponds to center of the object

    • originX: string

      Horizontal origin: 'left', 'center' or 'right'

    • originY: string

      Vertical origin: 'top', 'center' or 'bottom'

    Returns Point

viewportCenter

  • viewportCenter(): Object
  • Centers object on current viewport of canvas to which it was added last. You might need to call setCoords on an object after centering, to update controls area.

    chainable

    Returns Object

    thisArg

viewportCenterH

  • viewportCenterH(): Object
  • Centers object horizontally on current viewport of canvas to which it was added last. You might need to call setCoords on an object after centering, to update controls area.

    chainable

    Returns Object

    thisArg

viewportCenterV

  • viewportCenterV(): Object
  • Centers object vertically on current viewport of canvas to which it was added last. You might need to call setCoords on an object after centering, to update controls area.

    chainable

    Returns Object

    thisArg

willDrawShadow

  • willDrawShadow(): boolean
  • Check if this object or a child object will cast a shadow used by Group.shouldCache to know if child has a shadow recursively

    Returns boolean

Static Private _fromObject

  • _fromObject(className: string, object: Object, callback?: Function, extraParam?: any): Object
  • Creates fabric Object instance

    Parameters

    • className: string
    • object: Object
    • Optional callback: Function
    • Optional extraParam: any

    Returns Object

Generated using TypeDoc