Class Path<Props, SProps, EventSpec>

Type Parameters

Hierarchy

Constructors

Properties

Accessors

Methods

_animate _applyPatternForTransformedGradient _applyPatternGradientTransform _calcBoundsFromPath _calcDimensions _calculateCurrentDimensions _constrainScale _createBaseClipPathSVGMarkup _createBaseSVGMarkup _createCacheCanvas _drawBorders _drawClipPath _findCenterFromElement _findTargetCorner _getCacheCanvasDimensions _getLeftTopCoords _getNonTransformedDimensions _getOffsetTransform _getTransformedDimensions _limitCacheSize _removeCacheCanvas _removeDefaultValues _removeShadow _render _renderBackground _renderControls _renderFill _renderPaintInOrder _renderPathCommands _renderStroke _set _setClippingProperties _setFillStyles _setLineDash _setObject _setOpacity _setOptions _setPath _setShadow _setStrokeStyles _setupCompositeOperation _toSVG _updateCacheCanvas addPaintOrder animate calcACoords calcLineCoords calcOCoords calcOwnMatrix calcTransformMatrix canDrop clearContextTop clone cloneAsImage complexity containsPoint dispose drawBorders drawCacheOnCanvas drawClipPathOnCache drawControls drawControlsConnectingLines drawObject drawSelectionBackground findCommonAncestors fire forEachControl get getActiveControl getAncestors getBoundingRect getCanvasRetinaScaling getCenterPoint getCoords getObjectOpacity getObjectScaling getParent getPointByOrigin getRelativeCenterPoint getRelativeX getRelativeXY getRelativeY getScaledHeight getScaledWidth getSvgCommons getSvgFilter getSvgStyles getSvgTransform getTotalAngle getTotalObjectScaling getViewportTransform getX getXY getY hasCommonAncestors hasFill hasStroke intersectsWithObject intersectsWithRect isCacheDirty isContainedWithinObject isContainedWithinRect isControlVisible isDescendantOf isInFrontOf isNotVisible isOnScreen isOverlapping isPartiallyOnScreen isType needsItsOwnCache off on onDeselect onSelect once render renderCache renderDragSourceEffect renderDropTargetEffect rotate scale scaleToHeight scaleToWidth set setBoundingBox setControlVisible setControlsVisibility setCoords setDimensions setOnGroup setOptions setPositionByOrigin setRelativeX setRelativeXY setRelativeY setX setXY setY shouldCache strokeBorders toCanvasElement toClipPathSVG toDataURL toDatalessObject toJSON toObject toSVG toString toggle transform transformMatrixKey translateToCenterPoint translateToGivenOrigin translateToOriginPoint willDrawShadow _fromObject fromElement fromObject getDefaults

Constructors

Properties

__corner?: string

keeps the value of the last hovered corner during mouse move. 0 is no corner, or 'mt', 'ml', 'mtr' etc.. It should be private, but there is no harm in using it as a read-only property. this isn't cleaned automatically. Non selected objects may have wrong values

__owningGroup?: Group

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

_cacheCanvas?: HTMLCanvasElement

A reference to the HTMLCanvasElement that is used to contain the cache of the object this canvas element is resized and cleared as needed Is marked private, you can read it, don't use it since it is handled by fabric since 1.7.0

Default

undefined
@private
_cacheContext: null | CanvasRenderingContext2D = null

Quick access for the _cacheCanvas rendering context This is part of the objectCaching feature since 1.7.0

Default

undefined
@private
_controlsVisibility: Record<string, boolean>

a map of control visibility for this object. this was left when controls were introduced to not break the api too much this takes priority over the generic control visibility

_scaling?: boolean

A boolean used from the gesture module to keep tracking of a scaling action when there is no scaling transform in place. This is an edge case and is used twice in all codebase. Probably added to keep track of some performance issues

TODO

use git blame to investigate why it was added DON'T USE IT. WE WILL TRY TO REMOVE IT

_transformDone?: boolean

Private. indicates if the object inside a group is on a transformed context or not or is part of a larger cache for many object ( a group for example)

Default

undefined
@private
aCoords: TCornerPoint

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 useful to understand where an object is. They get updated with lineCoords or oCoords in interactive cases 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

calcACoords();

absolutePositioned: boolean
activeOn: "down" | "up"
angle: TDegree
backgroundColor: string
borderColor: string
borderDashArray: null | number[]
borderOpacityWhenMoving: number
borderScaleFactor: number
cacheHeight?: number

Size of the cache canvas, height since 1.7.0

Default

undefined
@private
cacheTranslationX?: number

zoom level used on the cacheCanvas to draw the cache, Y axe since 1.7.0

Default

undefined
@private
cacheTranslationY?: number

translation of the cacheCanvas away from the center, for subpixel accuracy and crispness since 1.7.0

Default

undefined
@private
cacheWidth?: number

Size of the cache canvas, width since 1.7.0

Default

undefined
@private
canvas?: Canvas
centeredRotation: boolean
centeredScaling: boolean
clipPath?: FabricObject<Partial<ObjectProps>, SerializedObjectProps, ObjectEvents>
clipPathId?: string

When an object is being exported as SVG as a clippath, a reference inside the SVG is needed. This reference is a UID in the fabric namespace and is temporary stored here.

colorProperties: string[]

List of properties to consider for animating colors.

controls: TControlSet

holds the controls for the object. controls are added by default_controls.js

cornerColor: string
cornerDashArray: null | number[]
cornerSize: number
cornerStrokeColor: string
cornerStyle: "circle" | "rect"
dirty: boolean

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

Default

true
evented: boolean
excludeFromExport: boolean
fill: null | string | TFiller
fillRule: CanvasFillRule
flipX: boolean
flipY: boolean
globalCompositeOperation: GlobalCompositeOperation
group?: Group

A reference to the parent of the object, usually a Group

Default

undefined
@private
hasBorders: boolean
hasControls: boolean
height: number
hoverCursor: null | string
includeDefaultValues: boolean
inverted: boolean
isMoving?: boolean

internal boolean to signal the code that the object is part of the move action.

left: number
lineCoords: TCornerPoint

Describe object's corner position in canvas element coordinates. includes padding. Used of object detection. set and refreshed with setCoords. Those could go away

Todo

investigate how to get rid of those

lockMovementX: boolean
lockMovementY: boolean
lockRotation: boolean
lockScalingFlip: boolean
lockScalingX: boolean
lockScalingY: boolean
lockSkewingX: boolean
lockSkewingY: boolean
matrixCache?: TMatrixCache

storage cache for object full transform matrix

minScaleLimit: number
moveCursor: null | string
noScaleCache: boolean
oCoords: Record<string, TOCoord>

Describe object's corner position in canvas element coordinates. properties are depending on control keys and padding 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 the controls positionHandler and are used to draw and locate controls

objectCaching: boolean
opacity: number
originX: TOriginX
originY: TOriginY
ownCaching?: boolean

Indicate if the object is sitting on a cache dedicated to it or is part of a larger cache for many object ( a group for example)

Default

undefined
@private
ownMatrixCache?: TMatrixCache

storage cache for object transform matrix

padding: number
paintFirst: "fill" | "stroke"

Array of path points

Default


pathOffset: Point
perPixelTargetFind: boolean
scaleX: number
scaleY: number
segmentsInfo?: TPathSegmentInfo[]
selectable: boolean
selectionBackgroundColor: string
shadow: null | Shadow
skewX: number
skewY: number
snapAngle?: TDegree
snapThreshold?: TDegree
sourcePath?: string
stroke: null | string | TFiller
strokeDashArray: null | number[]
strokeDashOffset: number
strokeLineCap: CanvasLineCap
strokeLineJoin: CanvasLineJoin
strokeMiterLimit: number
strokeUniform: boolean
strokeWidth: number
top: number
touchCornerSize: number
transparentCorners: boolean
visible: boolean
width: number
zoomX?: number

zoom level used on the cacheCanvas to draw the cache, X axe since 1.7.0

Default

undefined
@private
zoomY?: number

zoom level used on the cacheCanvas to draw the cache, Y axe since 1.7.0

Default

undefined
@private
ATTRIBUTE_NAMES: string[] = ...

List of attribute names to account for when parsing SVG element (used by Path.fromElement)

cacheProperties: string[] = ...

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

ownDefaults: Record<string, any> = interactiveDefaults
stateProperties: string[] = stateProperties

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

type: string = 'Path'

The class type. Used to identify which class this is. This is used for serialization purposes and internally it can be used to identify classes. As a developer you could use instance of Class but to avoid importing all the code and blocking tree shaking we try to avoid doing that.

Accessors

  • get type(): string
  • Legacy identifier of the class. Prefer using utils like isType or instanceOf Will be removed in fabric 7 or 8. The setter exists because is very hard to catch all the ways in which a type value could be set in the instance

    Returns string

    TODO

    add sustainable warning message

    Deprecated

  • set type(value): void
  • Parameters

    • value: string

    Returns void

Methods

  • Private

    This function try to patch the missing gradientTransform on canvas gradients. transforming a context to transform the gradient, is going to transform the stroke too. we want to transform the gradient but not the stroke operation, so we create a transformed gradient on a pattern and then we use the pattern instead of the gradient. this method has drawbacks: is slow, is in low resolution, needs a patch for when the size is limited.

    Parameters

    • ctx: CanvasRenderingContext2D

      Context to render on

    • filler: TFiller

    Returns void

  • Private

    Makes sure the scale is valid and modifies it if necessary @todo: this is a control action issue, not a geometry one

    Parameters

    • value: number

    Returns number

    constrained value;

  • Private

    Determines which corner is under the mouse cursor, represented by pointer. This function is return a corner only if the object is the active one. This is done to avoid selecting corner of non active object and activating transformations rather than drag action. The default behavior of fabricJS is that if you want to transform an object, first you select it to show the control set

    Parameters

    • pointer: Point

      The pointer indicating the mouse position

    • forTouch: boolean = false

      indicates if we are looking for interaction area with a touch action

    Returns string

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

  • Private

    Returns string

    the path command's translate transform attribute

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

    Parameters

    • dims: any

    Returns any

    .width width of canvas

  • Renders controls and borders for the object the context here is not transformed

    Parameters

    • ctx: CanvasRenderingContext2D

      Context to render on

    • Optional styleOverride: TStyleOverride = {}

      properties to override the object style

    Returns void

    Todo

    move to interactivity

  • Private

    Parameters

    • ctx: CanvasRenderingContext2D

      context to render path on

    Returns void

  • Protected

    Handles setting values on the instance and handling internal side effects

    Parameters

    • key: string
    • value: any

    Returns Path<Props, SProps, EventSpec>

  • Private

    Sets line dash

    Parameters

    • ctx: CanvasRenderingContext2D

      Context to set the dash line on

    • Optional dashArray: null | number[]

      array representing dashes

    Returns void

  • Protected

    Sets object's properties from options, for initialization only

    Parameters

    • Optional options: any = {}

      Options object

    Returns void

  • Private

    Parameters

    • path: string | TComplexPathData

      Path data (sequence of coordinates and corresponding "command" tokens)

    • Optional adjustPosition: boolean

      pass true to reposition the object according to the bounding box

    Returns void

    top left position of the bounding box, useful for complementary positioning

  • Parameters

    • ctx: CanvasRenderingContext2D
    • decl: Pick<Path<Props, SProps, EventSpec>, "strokeDashOffset" | "strokeLineCap" | "strokeLineJoin" | "strokeMiterLimit" | "strokeWidth" | "stroke">

    Returns void

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

    Parameters

    • ctx: CanvasRenderingContext2D

      Rendering canvas context

    Returns void

  • Returns svg representation of an instance

    Returns string[]

    an array of strings with the specific svg representation of the instance

  • Calculates the coordinates of the center of each control plus the corners of the control itself This basically just delegates to each control positionHandler WARNING: changing what is passed to positionHandler is a breaking change, since position handler is a public api and should be done just if extremely necessary

    Returns Record<string, TOCoord>

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

    Parameters

    • Optional skipGroup: 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.

    Returns TMat2D

    transform matrix for the object

  • Clears the canvas.contextTop in a specific area that corresponds to the object's bounding box that is in the canvas.contextContainer. This function is used to clear pieces of contextTop where we render ephemeral effects on top of the object. Example: blinking cursor text selection, drag effects.

    Parameters

    • Optional restoreManually: boolean

      When true won't restore the context after clear, in order to draw something else.

    Returns undefined | CanvasRenderingContext2D

    canvas.contextTop that is either still transformed with the object transformMatrix, or restored to neutral transform

    Todo

    discuss swapping restoreManually with a renderCallback, but think of async issues

  • Clones an instance.

    Parameters

    • Optional propertiesToInclude: string[]

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

    Returns Promise<Path<Props, SProps, EventSpec>>

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

    Parameters

    • Optional options: any

      for clone as image, passed to toDataURL

    Returns FabricImage<Partial<ImageProps>, SerializedImageProps, ObjectEvents>

    Object cloned as image.

    Todo

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

  • Checks if point is inside the object

    Parameters

    • point: Point

      Point to check against

    • Optional absolute: boolean = false

      use coordinates without viewportTransform

    • Optional calculate: boolean = false

      use coordinates of current position instead of stored ones

    Returns boolean

    true if point is inside the object

  • Draws borders of an object's bounding box. Requires public properties: width, height Requires public options: padding, borderColor

    Parameters

    • ctx: CanvasRenderingContext2D

      Context to draw on

    • options: Required<Omit<TComposeMatrixArgs, "flipX" | "flipY">>

      object representing current object parameters

    • Optional styleOverride: TStyleOverride

      object to override the object style

    Returns void

  • Draws corners of an object's bounding box. Requires public properties: width, height Requires public options: cornerSize, padding

    Parameters

    • ctx: CanvasRenderingContext2D

      Context to draw on

    • styleOverride: Partial<Pick<InteractiveFabricObject<Partial<FabricObjectProps>, SerializedObjectProps, ObjectEvents>, "cornerStyle" | "cornerSize" | "cornerColor" | "cornerStrokeColor" | "cornerDashArray" | "transparentCorners">> = {}

      object to override the object style

    Returns void

  • Draws lines from a borders of an object's bounding box to controls that have withConnection property set. Requires public properties: width, height Requires public options: padding, borderColor

    Parameters

    • ctx: CanvasRenderingContext2D

      Context to draw on

    • size: Point

      object size x = width, y = height

    Returns void

  • Execute the drawing operation for an object on a specified context

    Parameters

    • ctx: CanvasRenderingContext2D

      Context to render on

    • Optional forClipping: boolean

      apply clipping styles

    Returns void

  • 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

    Parameters

    • ctx: CanvasRenderingContext2D

      Context to draw on

    Returns void

    Todo

    evaluate if make this disappear in favor of a pre-render hook for objects this was added by Andrea Bogazzi to make possible some feature for work reasons it seemed a good option, now is an edge case

  • Compare ancestors

    Type Parameters

    • T extends Path<Props, SProps, EventSpec, T>

    • S extends boolean

    Parameters

    • other: T
    • Optional strict: S

      finds only ancestors that are objects (without canvas)

    Returns AncestryComparison<S>

    an object that represent the ancestry situation.

  • Fires event with an optional options object

    Type Parameters

    • K extends string | number | symbol

    Parameters

    • eventName: K

      Event name to fire

    • Optional options: EventSpec[K]

      Options object

    Returns void

  • Type Parameters

    • T extends boolean

    Parameters

    • Optional strict: T

      returns only ancestors that are objects (without canvas)

    Returns Ancestors<T>

    ancestors (excluding ActiveSelection) from bottom to top

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

    Parameters

    • Optional absolute: boolean

      use coordinates without viewportTransform

    • Optional calculate: boolean

      use coordinates of current position instead of .lineCoords / .aCoords

    Returns TBBox

    Object with left, top, width, height properties

  • return correct set of coordinates for intersection this will return either aCoords or lineCoords. The coords are returned in an array.

    Parameters

    • absolute: boolean = false

      will return aCoords if true or lineCoords

    • calculate: boolean = false

      will return aCoords if true or lineCoords

    Returns Point[]

    [tl, tr, br, bl] of points

  • Returns instance's parent EXCLUDING ActiveSelection

    Type Parameters

    • T extends boolean

    Parameters

    • Optional strict: T

      exclude canvas as well

    Returns undefined | TAncestor

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

    Returns null | boolean | ""

    Boolean

    Since

    3.0.0

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

    Returns null | boolean | ""

    Boolean

    Since

    3.0.0

  • Checks if object intersects with another object

    Parameters

    • other: ObjectGeometry<ObjectEvents>

      Object to test

    • Optional absolute: boolean = false

      use coordinates without viewportTransform

    • Optional calculate: boolean = false

      use coordinates of current position instead of calculating them

    Returns boolean

    true if object intersects with another object

  • Checks if object intersects with an area formed by 2 points

    Parameters

    • pointTL: Point

      top-left point of area

    • pointBR: Point

      bottom-right point of area

    • Optional absolute: boolean

      use coordinates without viewportTransform

    • Optional calculate: boolean

      use coordinates of current position instead of stored one

    Returns boolean

    true if object intersects with an area formed by 2 points

  • Checks if object is fully contained within area of another object

    Parameters

    • other: ObjectGeometry<ObjectEvents>

      Object to test

    • Optional absolute: boolean = false

      use coordinates without viewportTransform

    • Optional calculate: boolean = false

      use coordinates of current position instead of stored ones

    Returns boolean

    true if object is fully contained within area of another object

  • Checks if object is fully contained within area formed by 2 points

    Parameters

    • pointTL: Point

      top-left point of area

    • pointBR: Point

      bottom-right point of area

    • Optional absolute: boolean

      use coordinates without viewportTransform

    • Optional calculate: boolean

      use coordinates of current position instead of stored one

    Returns boolean

    true if object is fully contained within area formed by 2 points

  • Returns true if the specified control is visible, false otherwise.

    Parameters

    • controlKey: string

      The key of the control. Possible values are usually 'tl', 'tr', 'br', 'bl', 'ml', 'mt', 'mr', 'mb', 'mtr', but since the control api allow for any control name, can be any string.

    Returns boolean

    true if the specified control is visible, false otherwise

  • Type Parameters

    • T extends Path<Props, SProps, EventSpec, T>

    Parameters

    • other: T

      object to compare against

    Returns 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

  • 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 = false

      use coordinates of current position instead of .aCoords

    Returns boolean

    true if object is fully or partially contained within canvas

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

    Parameters

    • Optional calculate: boolean

      use coordinates of current position instead of stored ones

    Returns boolean

    true if object is partially contained within canvas

  • 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

    Boolean

  • unsubscribe an event listener

    Type Parameters

    • K extends string | number | symbol

    Parameters

    • eventName: K

      event name (eg. 'after:render')

    • handler: TEventCallback<any>

      event listener to unsubscribe

    Returns void

  • unsubscribe event listeners

    Parameters

    • handlers: EventRegistryObject<EventSpec>

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

    Returns void

  • unsubscribe all event listeners

    Returns void

  • Observes specified event

    Type Parameters

    • K extends string | number | symbol

    • E

    Parameters

    • eventName: K

      Event name (eg. 'after:render')

    • handler: TEventCallback<E>

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

    Returns VoidFunction

    disposer

    Alias

    on

  • Parameters

    • handlers: EventRegistryObject<EventSpec>

    Returns VoidFunction

  • 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

    • Optional options: {
          e?: TPointerEvent;
      }

      options sent from the upper functions

      • Optional e?: TPointerEvent

        event if the process is generated by an event

    Returns boolean

  • Observes specified event once

    Type Parameters

    • K extends string | number | symbol

    • E

    Parameters

    • eventName: K

      Event name (eg. 'after:render')

    • handler: TEventCallback<E>

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

    Returns VoidFunction

    disposer

    Alias

    once

  • Parameters

    • handlers: EventRegistryObject<EventSpec>

    Returns VoidFunction

  • Override to customize drag and drop behavior render a specific effect when an object is the source of a drag event example: render the selection status for the part of text that is being dragged from a text object

    Parameters

    • e: DragEvent

    Returns void

  • Override to customize drag and drop behavior render a specific effect when an object is the target of a drag event used to show that the underly object can receive a drop, or to show how the object will change when dropping. example: show the cursor where the text is about to be dropped

    Parameters

    • e: DragEvent

    Returns void

  • 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

      ignore viewport

    Returns void

  • 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

    • key: string | Record<string, any>

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

    • Optional value: any

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

    Returns Path<Props, SProps, EventSpec>

  • Parameters

    • Optional adjustPosition: boolean

    Returns void

  • Sets the visibility of the specified control. please do not use.

    Parameters

    • controlKey: string

      The key of the control. Possible values are 'tl', 'tr', 'br', 'bl', 'ml', 'mt', 'mr', 'mb', 'mtr'. but since the control api allow for any control name, can be any string.

    • visible: boolean

      true to set the specified control visible, false otherwise

    Returns void

    Todo

    discuss this overlap of priority here with the team. Andrea Bogazzi for details

  • Sets the visibility state of object controls, this is just a bulk option for setControlVisible;

    Parameters

    • Optional options: Record<string, boolean> = {}

      with an optional key per control example: {Boolean} [options.bl] true to enable the bottom-left control, false to disable it

    Returns 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

  • Protected

    Sets object's properties from options, for class constructor only. Needs to be overridden for different defaults.

    Parameters

    • Optional options: Record<string, any> = {}

      Options object

    Returns void

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

    Parameters

    • point: Point

      position according to object's originX originY properties in parent's coordinate plane

    • Optional originX: TOriginX

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

    • Optional originY: TOriginY

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

    Returns void

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

    Parameters

    • point: Point

      position in canvas coordinate plane

    • Optional originX: TOriginX

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

    • Optional originY: TOriginY

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

    Returns void

    Example

    Set object's bottom left corner to point (5,5) on canvas

    object.setXY(new Point(5, 5), 'left', 'bottom').
    
  • 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. Read as: cache if is needed, or if the feature is enabled but we are not already caching.

    Returns boolean

  • override this function in order to customize the drawing of the control box, e.g. rounded corners, different border style.

    Parameters

    • ctx: CanvasRenderingContext2D

      ctx is rotated and translated so that (0,0) is at object's center

    • size: Point

      the control box size used

    Returns void

  • Returns svg clipPath representation of an instance

    Parameters

    • Optional reviver: TSVGReviver

      Method for further parsing of svg representation.

    Returns string

    svg representation of an instance

  • Converts an object into a data-url-like string

    Parameters

    • options: any = {}

      Options object

    Returns string

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

  • Returns dataless object representation of an instance

    Type Parameters

    • T extends Omit<Props & TClassProperties<Path<Props, SProps, EventSpec>>, keyof SProps>

    • K extends string | number | symbol = never

    Parameters

    • Optional propertiesToInclude: K[] = []

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

    Returns Pick<T, K> & SProps

    object representation of an instance

  • Returns object representation of an instance

    Type Parameters

    • T extends Omit<Props & TClassProperties<Path<Props, SProps, EventSpec>>, keyof SProps>

    • K extends string | number | symbol = never

    Parameters

    • Optional propertiesToInclude: K[] = []

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

    Returns Pick<T, K> & SProps

    object representation of an instance

  • Returns svg representation of an instance

    Parameters

    • Optional reviver: TSVGReviver

      Method for further parsing of svg representation.

    Returns string

    svg representation of an instance

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

    Parameters

    • property: string

      Property to toggle

    Returns Path<Props, SProps, EventSpec>

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

    Parameters

    • point: Point

      The point which corresponds to the originX and originY params

    • fromOriginX: TOriginX

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

    • fromOriginY: TOriginY

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

    • toOriginX: TOriginX

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

    • toOriginY: TOriginY

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

    Returns Point

Generated using TypeDoc