Skip to content

BaseFabricObject

Defined in: src/shapes/Object/Object.ts:178

Root object class from which all 2d shape classes inherit from

http://fabricjs.com/fabric-intro-part-1#objects

added

removed

selected

deselected

rotating

scaling

moving

skewing

modified

mousedown

mouseup

mouseover

mouseout

mousewheel

mousedblclick

dragover

dragenter

dragleave

drop

  • ObjectGeometry<EventSpec>

Props extends TOptions<ObjectProps> = Partial<ObjectProps>

SProps extends SerializedObjectProps = SerializedObjectProps

EventSpec extends ObjectEvents = ObjectEvents

  • ObjectProps

new BaseFabricObject<Props, SProps, EventSpec>(options?): FabricObject<Props, SProps, EventSpec>

Defined in: src/shapes/Object/Object.ts:370

Constructor

Props

Options object

FabricObject<Props, SProps, EventSpec>

ObjectGeometry<EventSpec>.constructor

absolutePositioned: boolean

Defined in: src/shapes/Object/Object.ts:215

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

false

ObjectProps.absolutePositioned


aCoords: TCornerPoint

Defined in: src/shapes/Object/ObjectGeometry.ts:63

Describe object’s corner position in scene coordinates. The coordinates are derived from the following: left, top, width, height, scaleX, scaleY, skewX, skewY, angle, strokeWidth. The coordinates do not depend on viewport changes. The coordinates get updated with setCoords. You can calculate them without updating with ()

ObjectGeometry.aCoords


angle: TDegree

Defined in: src/shapes/Object/ObjectGeometry.ts:583

Angle of rotation of an object (in degrees)

0

ObjectProps.angle

ObjectGeometry.angle


backgroundColor: string

Defined in: src/shapes/Object/Object.ts:202

Background color of an object. takes css colors https://www.w3.org/TR/css-color-3/

ObjectProps.backgroundColor


centeredRotation: boolean

Defined in: src/shapes/Object/Object.ts:216

When true the object will rotate on its center. When false will rotate around the origin point defined by originX and originY. The value of this property is IGNORED during a transform if the canvas has already centeredRotation set to true The object method rotate will always consider this property and never the canvas’s one.

1.3.4

ObjectProps.centeredRotation


centeredScaling: boolean

Defined in: src/shapes/Object/Object.ts:217

When true, this object will use center point as the origin of transformation when being scaled via the controls.

1.3.4

ObjectProps.centeredScaling


optional clipPath: FabricObject<Partial<ObjectProps>, SerializedObjectProps, ObjectEvents>

Defined in: src/shapes/Object/Object.ts:213

ObjectProps.clipPath


dirty: boolean

Defined in: src/shapes/Object/Object.ts:242

When set to true, object’s cache will be rerendered next render call. since 1.7.0

true

excludeFromExport: boolean

Defined in: src/shapes/Object/Object.ts:209

When true, object is not exported in OBJECT/JSON

1.6.3

ObjectProps.excludeFromExport


fill: null | string | TFiller

Defined in: src/shapes/Object/Object.ts:192

ObjectProps.fill


fillRule: CanvasFillRule

Defined in: src/shapes/Object/Object.ts:193

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)

nonzero

ObjectProps.fillRule


flipX: boolean

Defined in: src/shapes/Object/ObjectGeometry.ts:569

When true, an object is rendered as flipped horizontally

false

ObjectProps.flipX

ObjectGeometry.flipX


flipY: boolean

Defined in: src/shapes/Object/ObjectGeometry.ts:570

When true, an object is rendered as flipped vertically

false

ObjectProps.flipY

ObjectGeometry.flipY


globalCompositeOperation: GlobalCompositeOperation

Defined in: src/shapes/Object/Object.ts:201

Composite rule used for canvas globalCompositeOperation

ObjectProps.globalCompositeOperation


height: number

Defined in: src/shapes/Object/ObjectGeometry.ts:568

Object height

ObjectProps.height

ObjectGeometry.height


includeDefaultValues: boolean

Defined in: src/shapes/Object/Object.ts:208

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

ObjectProps.includeDefaultValues


inverted: boolean

Defined in: src/shapes/Object/Object.ts:214

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

false

ObjectProps.inverted


left: number

Defined in: src/shapes/Object/ObjectGeometry.ts:566

Left position of an object. Note that by default it’s relative to object left. You can change this by setting FabricObject#originX

0

ObjectProps.left

ObjectGeometry.left


optional matrixCache: TMatrixCache

Defined in: src/shapes/Object/ObjectGeometry.ts:73

storage cache for object full transform matrix

ObjectGeometry.matrixCache


minScaleLimit: number

Defined in: src/shapes/Object/Object.ts:187

Minimum allowed scale value of an object

0

ObjectProps.minScaleLimit


objectCaching: boolean

Defined in: src/shapes/Object/Object.ts:211

When true, object is cached on an additional canvas. When false, object is not cached unless necessary ( clipPath ) default to true

1.7.0

true

ObjectProps.objectCaching


opacity: number

Defined in: src/shapes/Object/Object.ts:189

Opacity of an object

1

ObjectProps.opacity


originX: TOriginX

Defined in: src/shapes/Object/ObjectGeometry.ts:578

ObjectProps.originX

ObjectGeometry.originX


originY: TOriginY

Defined in: src/shapes/Object/ObjectGeometry.ts:582

ObjectProps.originY

ObjectGeometry.originY


optional ownMatrixCache: TMatrixCache

Defined in: src/shapes/Object/ObjectGeometry.ts:68

storage cache for object transform matrix

ObjectGeometry.ownMatrixCache


padding: number

Defined in: src/shapes/Object/ObjectGeometry.ts:53

Padding between object and its controlling borders (in pixels)

0

ObjectGeometry.padding


paintFirst: "fill" | "stroke"

Defined in: src/shapes/Object/Object.ts:191

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

ObjectProps.paintFirst


optional parent: Group

Defined in: src/shapes/Object/Object.ts:1606

A reference to the parent of the object Used to keep the original parent ref when the object has been added to an ActiveSelection, hence loosing the group ref


scaleX: number

Defined in: src/shapes/Object/ObjectGeometry.ts:571

Object scale factor (horizontal)

1

ObjectProps.scaleX

ObjectGeometry.scaleX


scaleY: number

Defined in: src/shapes/Object/ObjectGeometry.ts:572

Object scale factor (vertical)

1

ObjectProps.scaleY

ObjectGeometry.scaleY


shadow: null | Shadow

Defined in: src/shapes/Object/Object.ts:204

ObjectProps.shadow


skewX: number

Defined in: src/shapes/Object/ObjectGeometry.ts:573

Angle of skew on x axes of an object (in degrees)

0

ObjectProps.skewX

ObjectGeometry.skewX


skewY: number

Defined in: src/shapes/Object/ObjectGeometry.ts:574

Angle of skew on y axes of an object (in degrees)

0

ObjectProps.skewY

ObjectGeometry.skewY


stroke: null | string | TFiller

Defined in: src/shapes/Object/Object.ts:194

ObjectProps.stroke


strokeDashArray: null | number[]

Defined in: src/shapes/Object/Object.ts:195

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

null;

ObjectProps.strokeDashArray


strokeDashOffset: number

Defined in: src/shapes/Object/Object.ts:196

Line offset of an object’s stroke

0

ObjectProps.strokeDashOffset


strokeLineCap: CanvasLineCap

Defined in: src/shapes/Object/Object.ts:197

Line endings style of an object’s stroke (one of “butt”, “round”, “square”)

butt

ObjectProps.strokeLineCap


strokeLineJoin: CanvasLineJoin

Defined in: src/shapes/Object/Object.ts:198

Corner style of an object’s stroke (one of “bevel”, “round”, “miter”)

ObjectProps.strokeLineJoin


strokeMiterLimit: number

Defined in: src/shapes/Object/Object.ts:199

Maximum miter length (used for strokeLineJoin = “miter”) of an object’s stroke

4

ObjectProps.strokeMiterLimit


strokeUniform: boolean

Defined in: src/shapes/Object/ObjectGeometry.ts:585

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. this Property does not work on Text classes or drawing call that uses strokeText,fillText methods default to false

2.6.0

false
false

ObjectProps.strokeUniform

ObjectGeometry.strokeUniform


strokeWidth: number

Defined in: src/shapes/Object/ObjectGeometry.ts:584

Width of a stroke used to render this object

1

ObjectProps.strokeWidth

ObjectGeometry.strokeWidth


top: number

Defined in: src/shapes/Object/ObjectGeometry.ts:565

Top position of an object. Note that by default it’s relative to object top. You can change this by setting FabricObject#originY

0

ObjectProps.top

ObjectGeometry.top


visible: boolean

Defined in: src/shapes/Object/Object.ts:206

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

ObjectProps.visible


width: number

Defined in: src/shapes/Object/ObjectGeometry.ts:567

Object width

ObjectProps.width

ObjectGeometry.width


static cacheProperties: string[]

Defined in: src/shapes/Object/Object.ts:234

List of properties to consider when checking if cache needs refresh Those properties are checked by 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


static colorProperties: string[]

Defined in: src/shapes/Object/Object.ts:1513

List of properties to consider for animating colors.


static customProperties: string[] = []

Defined in: src/shapes/Object/Object.ts:1754

Define a list of custom properties that will be serialized when instance.toObject() gets called


static ownDefaults: Partial<TClassProperties<FabricObject<Partial<ObjectProps>, SerializedObjectProps, ObjectEvents>>> = fabricObjectDefaultValues

Defined in: src/shapes/Object/Object.ts:327


static stateProperties: string[]

Defined in: src/shapes/Object/Object.ts:225

This list of properties is used to check if the state of an object is changed. This state change now is only used for children of groups to understand if a group needs its cache regenerated during a .set call


static type: string = 'FabricObject'

Defined in: src/shapes/Object/Object.ts:343

The class type. This is used for serialization and deserialization purposes and internally it can be used to identify classes. When we transform a class in a plain JS object we need a way to recognize which class it was, and the type is the way we do that. It has no other purposes and you should not give one. Hard to reach on instances and please do not use to drive instance’s logic (this.constructor.type). To idenfity a class use instanceof class ( instanceof Rect ). We do not do that in fabricJS code because we want to try to have code splitting possible.

get type(): string

Defined in: src/shapes/Object/Object.ts:354

Legacy identifier of the class. Prefer using utils like isType or instanceOf Will be removed in fabric 7 or 8. The setter exists to avoid type errors in old code and possibly current deserialization code. DO NOT build new code around this type value

add sustainable warning message

string

set type(value): void

Defined in: src/shapes/Object/Object.ts:362

string

void

_drawClipPath(ctx, clipPath, context): void

Defined in: src/shapes/Object/Object.ts:884

Prepare clipPath state and cache and draw it on instance’s cache

CanvasRenderingContext2D

undefined | FabricObject<Partial<ObjectProps>, SerializedObjectProps, ObjectEvents>

DrawContext

void


_limitCacheSize(dims): any

Defined in: src/shapes/Object/Object.ts:403

Limit the cache dimensions so that X * Y do not cross config.perfLimitSizeTotal and each side do not cross fabric.cacheSideLimit those numbers are configurable so that you can get as much detail as you want making bargain with performances.

any

any

.width width of canvas


_removeCacheCanvas(): void

Defined in: src/shapes/Object/Object.ts:720

Remove cacheCanvas and its dimensions from the objects

void


_setClippingProperties(ctx): void

Defined in: src/shapes/Object/Object.ts:1029

CanvasRenderingContext2D

void


_setFillStyles(ctx, __namedParameters): void

Defined in: src/shapes/Object/Object.ts:1018

CanvasRenderingContext2D

Pick<FabricObject<Props, SProps, EventSpec>, "fill">

void


_setStrokeStyles(ctx, decl): void

Defined in: src/shapes/Object/Object.ts:976

CanvasRenderingContext2D

Pick<FabricObject<Props, SProps, EventSpec>, "stroke" | "strokeWidth" | "strokeDashOffset" | "strokeLineCap" | "strokeLineJoin" | "strokeMiterLimit">

void


_setupCompositeOperation(ctx): void

Defined in: src/shapes/Object/Object.ts:1488

Sets canvas globalCompositeOperation for specific object custom composition operation for the particular object can be specified using globalCompositeOperation property

CanvasRenderingContext2D

Rendering canvas context

void


animate<T>(animatable, options?): Record<string, TAnimation<T>>

Defined in: src/shapes/Object/Object.ts:1527

Animates object’s properties

T extends number | number[] | TColorArg

Record<string, T>

map of keys and end values

Partial<AnimationOptions<T>>

Record<string, TAnimation<T>>

map of animation contexts

As object — multiple properties

object.animate({ left: …, top: … }); object.animate({ left: …, top: … }, { duration: … });

http://fabricjs.com/fabric-intro-part-2#animation


calcACoords(): TCornerPoint

Defined in: src/shapes/Object/ObjectGeometry.ts:429

Calculates the coordinates of the 4 corner of the bbox, in absolute coordinates. those never change with zoom or viewport changes.

TCornerPoint

ObjectGeometry.calcACoords


calcOwnMatrix(): TMat2D

Defined in: src/shapes/Object/ObjectGeometry.ts:515

calculate transform matrix that represents the current transformations from the object’s properties, this matrix does not include the group transformation

TMat2D

transform matrix for the object

ObjectGeometry.calcOwnMatrix


calcTransformMatrix(skipGroup?): TMat2D

Defined in: src/shapes/Object/ObjectGeometry.ts:487

calculate transform matrix that represents the current transformations from the object’s properties.

boolean = false

return transform matrix for object not counting parent transformations There are some situation in which this is useful to avoid the fake rotation.

TMat2D

transform matrix for the object

ObjectGeometry.calcTransformMatrix


clone(propertiesToInclude?): Promise<FabricObject<Props, SProps, EventSpec>>

Defined in: src/shapes/Object/Object.ts:1255

Clones an instance.

string[]

Any properties that you might want to additionally include in the output

Promise<FabricObject<Props, SProps, EventSpec>>


cloneAsImage(options?): FabricImage

Defined in: src/shapes/Object/Object.ts:1281

Creates an instance of Image out of an object makes use of toCanvasElement. Once this method was based on toDataUrl and loadImage, so it also had a quality and format option. toCanvasElement is faster and produce no loss of quality. If you need to get a real Jpeg or Png from an object, using toDataURL is the right way to do it. toCanvasElement and then toBlob from the obtained canvas is also a good option.

ObjectToCanvasElementOptions

for clone as image, passed to toDataURL

FabricImage

Object cloned as image.

fix the export type, it could not be Image but the type that getClass return for ‘image’.


complexity(): number

Defined in: src/shapes/Object/Object.ts:1430

Returns complexity of an instance

number

complexity of this instance (is 1 unless subclassed)


containsPoint(point): boolean

Defined in: src/shapes/Object/ObjectGeometry.ts:284

Checks if point is inside the object

Point

Point to check against

boolean

true if point is inside the object

ObjectGeometry.containsPoint


dispose(): void

Defined in: src/shapes/Object/Object.ts:1498

cancel instance’s running animations override if necessary to dispose artifacts such as clipPath

void


drawCacheOnCanvas(this, ctx): void

Defined in: src/shapes/Object/Object.ts:906

Paint the cached copy of the object on the target context.

TCachedFabricObject

CanvasRenderingContext2D

Context to render on

void


drawClipPathOnCache(ctx, clipPath, canvasWithClipPath): void

Defined in: src/shapes/Object/Object.ts:812

Execute the drawing operation for an object clipPath

CanvasRenderingContext2D

Context to render on

FabricObject

HTMLCanvasElement

void


drawObject(ctx, forClipping, context): void

Defined in: src/shapes/Object/Object.ts:836

Execute the drawing operation for an object on a specified context

CanvasRenderingContext2D

Context to render on

apply clipping styles

undefined | boolean

DrawContext

additional context for rendering

void


drawSelectionBackground(_ctx): void

Defined in: src/shapes/Object/Object.ts:692

CanvasRenderingContext2D

void


findCommonAncestors<T>(other): AncestryComparison

Defined in: src/shapes/Object/Object.ts:1645

Compare ancestors

T extends FabricObject<Props, SProps, EventSpec>

T

AncestryComparison

an object that represent the ancestry situation.


fire<K>(eventName, options?): void

Defined in: src/Observable.ts:167

Fires event with an optional options object

K extends string | number | symbol

K

Event name to fire

EventSpec[K]

Options object

void

ObjectGeometry.fire


get(property): any

Defined in: src/CommonMethods.ts:59

Basic getter

string

Property name

any

value of a property

ObjectGeometry.get


getAncestors(): Ancestors

Defined in: src/shapes/Object/Object.ts:1628

Ancestors

ancestors (excluding ActiveSelection) from bottom to top


getBoundingRect(): TBBox

Defined in: src/shapes/Object/ObjectGeometry.ts:345

Returns coordinates of object’s bounding rectangle (left, top, width, height) the box is intended as aligned to axis of canvas.

TBBox

Object with left, top, width, height properties

ObjectGeometry.getBoundingRect


getCanvasRetinaScaling(): number

Defined in: src/shapes/Object/ObjectGeometry.ts:402

number

ObjectGeometry.getCanvasRetinaScaling


getCenterPoint(): Point

Defined in: src/shapes/Object/ObjectGeometry.ts:735

Returns the center coordinates of the object relative to canvas

Point

ObjectGeometry.getCenterPoint


getCoords(): Point[]

Defined in: src/shapes/Object/ObjectGeometry.ts:204

Point[]

[tl, tr, br, bl] in the scene plane

ObjectGeometry.getCoords


getObjectOpacity(): number

Defined in: src/shapes/Object/Object.ts:571

Return the object opacity counting also the group property

number


getObjectScaling(): Point

Defined in: src/shapes/Object/Object.ts:540

Return the object scale factor counting also the group scaling

Point


getPointByOrigin(originX, originY): Point

Defined in: src/shapes/Object/ObjectGeometry.ts:765

Returns the position of the object as if it has a different origin. Take an object that has left, top set to 100, 100 with origin ‘left’, ‘top’. Return the values of left top ( wrapped in a point ) that you would need to keep the same position if origin where different. Alternatively you can use this to also find which point in the parent plane is a specific origin ( where is the bottom right corner of my object? )

TOriginX

Horizontal origin: ‘left’, ‘center’ or ‘right’

TOriginY

Vertical origin: ‘top’, ‘center’ or ‘bottom’

Point

ObjectGeometry.getPointByOrigin


getRelativeCenterPoint(): Point

Defined in: src/shapes/Object/ObjectGeometry.ts:746

Returns the center coordinates of the object relative to it’s parent

Point

ObjectGeometry.getRelativeCenterPoint


getRelativeX(): number

Defined in: src/shapes/Object/ObjectGeometry.ts:115

number

x position according to object’s FabricObject#originX property in parent’s coordinate plane
if parent is canvas then this property is identical to getX

ObjectGeometry.getRelativeX


getRelativeXY(): Point

Defined in: src/shapes/Object/ObjectGeometry.ts:176

Point

x,y position according to object’s FabricObject#originX FabricObject#originY properties in parent’s coordinate plane

ObjectGeometry.getRelativeXY


getRelativeY(): number

Defined in: src/shapes/Object/ObjectGeometry.ts:131

number

y position according to object’s FabricObject#originY property in parent’s coordinate plane
if parent is canvas then this property is identical to getY

ObjectGeometry.getRelativeY


getScaledHeight(): number

Defined in: src/shapes/Object/ObjectGeometry.ts:363

Returns height of an object bounding box counting transformations

number

height value

shouldn’t this account for group transform and return the actual size in canvas coordinate plane?

ObjectGeometry.getScaledHeight


getScaledWidth(): number

Defined in: src/shapes/Object/ObjectGeometry.ts:354

Returns width of an object’s bounding box counting transformations

number

width value

shouldn’t this account for group transform and return the actual size in canvas coordinate plane?

ObjectGeometry.getScaledWidth


getTotalAngle(): TDegree

Defined in: src/shapes/Object/ObjectGeometry.ts:410

Returns the object angle relative to canvas counting also the group property

TDegree

ObjectGeometry.getTotalAngle


getTotalObjectScaling(): Point

Defined in: src/shapes/Object/Object.ts:557

Return the object scale factor counting also the group scaling, zoom and retina

Point

object with scaleX and scaleY properties


getViewportTransform(): TMat2D

Defined in: src/shapes/Object/ObjectGeometry.ts:420

Retrieves viewportTransform from Object’s canvas if available

TMat2D

ObjectGeometry.getViewportTransform


getX(): number

Defined in: src/shapes/Object/ObjectGeometry.ts:86

number

x position according to object’s FabricObject#originX property in canvas coordinate plane

ObjectGeometry.getX


getXY(): Point

Defined in: src/shapes/Object/ObjectGeometry.ts:146

Point

x position according to object’s FabricObject#originX FabricObject#originY properties in canvas coordinate plane

ObjectGeometry.getXY


getY(): number

Defined in: src/shapes/Object/ObjectGeometry.ts:100

number

y position according to object’s FabricObject#originY property in canvas coordinate plane

ObjectGeometry.getY


hasCommonAncestors<T>(other): boolean

Defined in: src/shapes/Object/Object.ts:1710

T extends FabricObject<Props, SProps, EventSpec>

T

boolean


hasFill(): null | boolean | ""

Defined in: src/shapes/Object/Object.ts:751

return true if the object will draw a fill Does not consider text styles. This is just a shortcut used at rendering time We want it to be an approximation and be fast. wrote to avoid extra caching, it has to return true when fill happens, can guess when it will not happen at 100% chance, does not matter if it misses some use case where the fill is invisible.

null | boolean | ""

Boolean

3.0.0


hasStroke(): null | boolean | ""

Defined in: src/shapes/Object/Object.ts:735

return true if the object will draw a stroke Does not consider text styles. This is just a shortcut used at rendering time We want it to be an approximation and be fast. wrote to avoid extra caching, it has to return true when stroke happens, can guess when it will not happen at 100% chance, does not matter if it misses some use case where the stroke is invisible.

null | boolean | ""

Boolean

3.0.0


intersectsWithObject(other): boolean

Defined in: src/shapes/Object/ObjectGeometry.ts:234

Checks if object intersects with another object

ObjectGeometry

Object to test

boolean

true if object intersects with another object

ObjectGeometry.intersectsWithObject


intersectsWithRect(tl, br): boolean

Defined in: src/shapes/Object/ObjectGeometry.ts:220

Checks if object intersects with the scene rect formed by TL and BR In this case the rect is meant aligned with the axis of the canvas. TL is the TOP LEFT point while br is the BOTTOM RIGHT point

Point

Point

boolean

ObjectGeometry.intersectsWithRect


isCacheDirty(skipCanvas): boolean

Defined in: src/shapes/Object/Object.ts:923

Check if cache is dirty and if is dirty clear the context. This check has a big side effect, it changes the underlying cache canvas if necessary. Do not call this method on your own to check if the cache is dirty, because if it is, it is also going to wipe the cache. This is badly designed and needs to be fixed.

boolean = false

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

boolean


isContainedWithinObject(other): boolean

Defined in: src/shapes/Object/ObjectGeometry.ts:253

Checks if object is fully contained within area of another object

ObjectGeometry

Object to test

boolean

true if object is fully contained within area of another object

ObjectGeometry.isContainedWithinObject


isContainedWithinRect(tl, br): boolean

Defined in: src/shapes/Object/ObjectGeometry.ts:261

Checks if object is fully contained within the scene rect formed by TL and BR

Point

Point

boolean

ObjectGeometry.isContainedWithinRect


isDescendantOf(target): boolean

Defined in: src/shapes/Object/Object.ts:1614

Checks if object is descendant of target Should be used instead of Group.contains or StaticCanvas.contains for performance reasons

TAncestor

boolean


isInFrontOf<T>(other): undefined | boolean

Defined in: src/shapes/Object/Object.ts:1720

T extends FabricObject<Props, SProps, EventSpec>

T

object to compare against

undefined | boolean

if objects do not share a common ancestor or they are strictly equal it is impossible to determine which is in front of the other; in such cases the function returns undefined


isNotVisible(): boolean

Defined in: src/shapes/Object/Object.ts:650

boolean


isOnScreen(): boolean

Defined in: src/shapes/Object/ObjectGeometry.ts:293

Checks if object is contained within the canvas with current viewportTransform the check is done stopping at first point that appears on screen

boolean

true if object is fully or partially contained within canvas

ObjectGeometry.isOnScreen


isOverlapping<T>(other): boolean

Defined in: src/shapes/Object/ObjectGeometry.ts:271

T extends ObjectGeometry<ObjectEvents>

T

boolean

ObjectGeometry.isOverlapping


isPartiallyOnScreen(): boolean

Defined in: src/shapes/Object/ObjectGeometry.ts:323

Checks if object is partially contained within the canvas with current viewportTransform

boolean

true if object is partially contained within canvas

ObjectGeometry.isPartiallyOnScreen


isType(…types): boolean

Defined in: src/shapes/Object/Object.ts:1419

Returns true if any of the specified types is identical to the type of an instance

string[]

boolean


needsItsOwnCache(): boolean

Defined in: src/shapes/Object/Object.ts:763

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

boolean

Boolean


off<K>(eventName): void

Defined in: src/Observable.ts:122

Unsubscribe all event listeners for eventname. Do not use this pattern. You could kill internal fabricJS events. We know we should have protected events for internal flows, but we don’t have yet

K extends string | number | symbol

K

event name (eg. ‘after:render’)

void

ObjectGeometry.off

off<K>(eventName, handler): void

Defined in: src/Observable.ts:128

unsubscribe an event listener

K extends string | number | symbol

K

event name (eg. ‘after:render’)

TEventCallback

event listener to unsubscribe

void

ObjectGeometry.off

off(handlers): void

Defined in: src/Observable.ts:133

unsubscribe event listeners

EventRegistryObject<EventSpec>

handlers key/value pairs (eg. {‘after:render’: handler, ‘selection:cleared’: handler})

void

ObjectGeometry.off

off(): void

Defined in: src/Observable.ts:137

unsubscribe all event listeners

void

ObjectGeometry.off


on<K, E>(eventName, handler): VoidFunction

Defined in: src/Observable.ts:23

Observes specified event

K extends string | number | symbol

E

K

Event name (eg. ‘after:render’)

TEventCallback<E>

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

VoidFunction

disposer

on

ObjectGeometry.on

on(handlers): VoidFunction

Defined in: src/Observable.ts:27

Observes specified event

EventRegistryObject<EventSpec>

key/value pairs (eg. {‘after:render’: handler, ‘selection:cleared’: handler})

VoidFunction

disposer

on

ObjectGeometry.on


once<K, E>(eventName, handler): VoidFunction

Defined in: src/Observable.ts:62

Observes specified event once

K extends string | number | symbol

E

K

Event name (eg. ‘after:render’)

TEventCallback<E>

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

VoidFunction

disposer

once

ObjectGeometry.once

once(handlers): VoidFunction

Defined in: src/Observable.ts:66

Observes specified event once

EventRegistryObject<EventSpec>

key/value pairs (eg. {‘after:render’: handler, ‘selection:cleared’: handler})

VoidFunction

disposer

once

ObjectGeometry.once


render(ctx): void

Defined in: src/shapes/Object/Object.ts:662

Renders an object on a specified context

CanvasRenderingContext2D

Context to render on

void


renderCache(this, options?): void

Defined in: src/shapes/Object/Object.ts:696

TCachedFabricObject

any

void


rotate(angle): void

Defined in: src/shapes/Object/Object.ts:1447

Sets “angle” of an instance with centered rotation

TDegree

Angle value (in degrees)

void


scale(value): void

Defined in: src/shapes/Object/ObjectGeometry.ts:372

Scales an object (equally by x and y)

number

Scale factor

void

ObjectGeometry.scale


scaleToHeight(value): void

Defined in: src/shapes/Object/ObjectGeometry.ts:395

Scales an object to a given height, with respect to bounding box (scaling by x/y equally)

number

New height value

void

ObjectGeometry.scaleToHeight


scaleToWidth(value): void

Defined in: src/shapes/Object/ObjectGeometry.ts:383

Scales an object to a given width, with respect to bounding box (scaling by x/y equally)

number

New width value

void

ObjectGeometry.scaleToWidth


set(key, value?): FabricObject<Props, SProps, EventSpec>

Defined in: src/CommonMethods.ts:29

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().

Property name or object (if object, iterate over the object properties)

string | Record<string, any>

any

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

FabricObject<Props, SProps, EventSpec>

ObjectGeometry.set


setCoords(): void

Defined in: src/shapes/Object/ObjectGeometry.ts:451

Sets corner and controls position coordinates based on current angle, width and height, left and top. aCoords are used to quickly find an object on the canvas. See https://github.com/fabricjs/fabric.js/wiki/When-to-call-setCoords and http://fabricjs.com/fabric-gotchas

void

ObjectGeometry.setCoords


setOnGroup(): void

Defined in: src/shapes/Object/Object.ts:1479

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.

void


setPositionByOrigin(pos, originX, originY): void

Defined in: src/shapes/Object/ObjectGeometry.ts:780

Sets the position of the object taking into consideration the object’s origin

Point

The new position of the object

TOriginX

Horizontal origin: ‘left’, ‘center’ or ‘right’

TOriginY

Vertical origin: ‘top’, ‘center’ or ‘bottom’

void

ObjectGeometry.setPositionByOrigin


setRelativeX(value): void

Defined in: src/shapes/Object/ObjectGeometry.ts:123

number

x position according to object’s FabricObject#originX property in parent’s coordinate plane
if parent is canvas then this method is identical to setX

void

ObjectGeometry.setRelativeX


setRelativeXY(point, originX?, originY?): void

Defined in: src/shapes/Object/ObjectGeometry.ts:186

As setXY, but in current parent’s coordinate plane (the current group if any or the canvas)

Point

position according to object’s FabricObject#originX FabricObject#originY properties in parent’s coordinate plane

TOriginX = ...

Horizontal origin: ‘left’, ‘center’ or ‘right’

TOriginY = ...

Vertical origin: ‘top’, ‘center’ or ‘bottom’

void

ObjectGeometry.setRelativeXY


setRelativeY(value): void

Defined in: src/shapes/Object/ObjectGeometry.ts:139

number

y position according to object’s FabricObject#originY property in parent’s coordinate plane
if parent is canvas then this property is identical to setY

void

ObjectGeometry.setRelativeY


setX(value): void

Defined in: src/shapes/Object/ObjectGeometry.ts:93

number

x position according to object’s FabricObject#originX property in canvas coordinate plane

void

ObjectGeometry.setX


setXY(point, originX?, originY?): void

Defined in: src/shapes/Object/ObjectGeometry.ts:163

Set an object position to a particular point, the point is intended in absolute ( canvas ) coordinate. You can specify FabricObject#originX and FabricObject#originY values, that otherwise are the object’s current values.

Point

position in scene coordinate plane

TOriginX

Horizontal origin: ‘left’, ‘center’ or ‘right’

TOriginY

Vertical origin: ‘top’, ‘center’ or ‘bottom’

void

object.setXY(new Point(5, 5), 'left', 'bottom').

ObjectGeometry.setXY


setY(value): void

Defined in: src/shapes/Object/ObjectGeometry.ts:107

number

y position according to object’s FabricObject#originY property in canvas coordinate plane

void

ObjectGeometry.setY


shouldCache(): boolean

Defined in: src/shapes/Object/Object.ts:788

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. Generally you do not cache objects in groups because the group outside is cached. Read as: cache if is needed, or if the feature is enabled but we are not already caching.

boolean


toBlob(options): Promise<null | Blob>

Defined in: src/shapes/Object/Object.ts:1406

toDataURLOptions = {}

Promise<null | Blob>


toCanvasElement(options): HTMLCanvasElement

Defined in: src/shapes/Object/Object.ts:1303

Converts an object into a HTMLCanvas element

ObjectToCanvasElementOptions = {}

Options object

HTMLCanvasElement

Returns DOM element with the FabricObject


toDatalessObject(propertiesToInclude?): any

Defined in: src/shapes/Object/Object.ts:1854

Returns (dataless) object representation of an instance

any[]

Any properties that you might want to additionally include in the output

any

Object representation of an instance


toDataURL(options): string

Defined in: src/shapes/Object/Object.ts:1399

Converts an object into a data-url-like string

toDataURLOptions = {}

Options object

string

Returns a data: URL containing a representation of the object in the format specified by options.format


toggle(property): FabricObject<Props, SProps, EventSpec>

Defined in: src/CommonMethods.ts:46

Toggles specified property from true to false or from false to true

string

Property to toggle

FabricObject<Props, SProps, EventSpec>

ObjectGeometry.toggle


toJSON(): any

Defined in: src/shapes/Object/Object.ts:1438

Returns a JSON representation of an instance

any

JSON


toObject(propertiesToInclude?): any

Defined in: src/shapes/Object/Object.ts:1761

Returns an object representation of an instance

any[] = []

Any properties that you might want to additionally include in the output

any

Object representation of an instance


toString(): string

Defined in: src/shapes/Object/Object.ts:1894

Returns a string representation of an instance

string


transform(ctx): void

Defined in: src/shapes/Object/Object.ts:528

Transforms context when rendering an object

CanvasRenderingContext2D

Context

void


transformMatrixKey(skipGroup): number[]

Defined in: src/shapes/Object/ObjectGeometry.ts:455

boolean = false

number[]

ObjectGeometry.transformMatrixKey


translateToCenterPoint(point, originX, originY): Point

Defined in: src/shapes/Object/ObjectGeometry.ts:685

Translates the coordinates from origin to center coordinates (based on the object’s dimensions)

Point

The point which corresponds to the originX and originY params

TOriginX

Horizontal origin: ‘left’, ‘center’ or ‘right’

TOriginY

Vertical origin: ‘top’, ‘center’ or ‘bottom’

Point

ObjectGeometry.translateToCenterPoint


translateToGivenOrigin(point, fromOriginX, fromOriginY, toOriginX, toOriginY): Point

Defined in: src/shapes/Object/ObjectGeometry.ts:657

Translates the coordinates from a set of origin to another (based on the object’s dimensions)

Point

The point which corresponds to the originX and originY params

TOriginX

Horizontal origin: ‘left’, ‘center’ or ‘right’

TOriginY

Vertical origin: ‘top’, ‘center’ or ‘bottom’

TOriginX

Horizontal origin: ‘left’, ‘center’ or ‘right’

TOriginY

Vertical origin: ‘top’, ‘center’ or ‘bottom’

Point

ObjectGeometry.translateToGivenOrigin


translateToOriginPoint(center, originX, originY): Point

Defined in: src/shapes/Object/ObjectGeometry.ts:713

Translates the coordinates from center to origin coordinates (based on the object’s dimensions)

Point

The point which corresponds to center of the object

TOriginX

Horizontal origin: ‘left’, ‘center’ or ‘right’

TOriginY

Vertical origin: ‘top’, ‘center’ or ‘bottom’

Point

ObjectGeometry.translateToOriginPoint


willDrawShadow(): boolean

Defined in: src/shapes/Object/Object.ts:801

Check if this object will cast a shadow with an offset. used by Group.shouldCache to know if child has a shadow recursively

boolean


static _fromObject<S>(__namedParameters, __namedParameters): Promise<S>

Defined in: src/shapes/Object/Object.ts:1907

S extends FabricObject<Partial<ObjectProps>, SerializedObjectProps, ObjectEvents>

Record<string, unknown>

Abortable & object = {}

Promise<S>


static fromObject<T>(object, options?): Promise<FabricObject<Partial<ObjectProps>, SerializedObjectProps, ObjectEvents>>

Defined in: src/shapes/Object/Object.ts:1936

T extends TOptions<SerializedObjectProps>

T

Abortable

Promise<FabricObject<Partial<ObjectProps>, SerializedObjectProps, ObjectEvents>>


static getDefaults(): Record<string, any>

Defined in: src/shapes/Object/Object.ts:329

Record<string, any>