Hiyve Components - v1.0.0
    Preparing search index...

    Interface WhiteboardObject

    Extended Fabric.js object with whiteboard-specific properties

    interface WhiteboardObject {
        __corner?: string;
        _controlsVisibility: Record<string, boolean>;
        _scaling?: boolean;
        absolutePositioned: boolean;
        aCoords: TCornerPoint;
        angle: TDegree;
        backgroundColor: string;
        borderColor: string;
        borderDashArray: number[] | null;
        borderOpacityWhenMoving: number;
        borderScaleFactor: number;
        centeredRotation: boolean;
        centeredScaling: boolean;
        clipPath?: FabricObject<
            Partial<ObjectProps>,
            SerializedObjectProps,
            ObjectEvents,
        >;
        clipPathId?: string;
        controls: TControlSet;
        cornerColor: string;
        cornerDashArray: number[] | null;
        cornerSize: number;
        cornerStrokeColor: string;
        cornerStyle: "circle" | "rect";
        customProps?: WhiteboardObjectCustomProps;
        dirty: boolean;
        evented: boolean;
        excludeFromExport: boolean;
        fill: string | TFiller | null;
        fillRule: CanvasFillRule;
        flipX: boolean;
        flipY: boolean;
        globalCompositeOperation: GlobalCompositeOperation;
        hasBorders: boolean;
        hasControls: boolean;
        height: number;
        hoverCursor: string | null;
        id?: string;
        includeDefaultValues: boolean;
        inverted: boolean;
        isMoving?: boolean;
        left: number;
        lockMovementX: boolean;
        lockMovementY: boolean;
        lockRotation: boolean;
        lockScalingFlip: boolean;
        lockScalingX: boolean;
        lockScalingY: boolean;
        lockSkewingX: boolean;
        lockSkewingY: boolean;
        matrixCache?: TMatrixCache;
        minScaleLimit: number;
        moveCursor: string | null;
        noScaleCache: boolean;
        objectCaching: boolean;
        oCoords: Record<string, TOCoord>;
        opacity: number;
        originX: TOriginX;
        originY: TOriginY;
        ownMatrixCache?: TMatrixCache;
        padding: number;
        paintFirst: "fill" | "stroke";
        parent?: Group;
        perPixelTargetFind: boolean;
        remote?: boolean;
        scaleX: number;
        scaleY: number;
        selectable: boolean;
        selectionBackgroundColor: string;
        shadow: Shadow | null;
        skewX: number;
        skewY: number;
        snapAngle?: TDegree;
        snapThreshold?: TDegree;
        stroke: string | TFiller | null;
        strokeDashArray: number[] | null;
        strokeDashOffset: number;
        strokeLineCap: CanvasLineCap;
        strokeLineJoin: CanvasLineJoin;
        strokeMiterLimit: number;
        strokeUniform: boolean;
        strokeWidth: number;
        top: number;
        touchCornerSize: number;
        transparentCorners: boolean;
        visible: boolean;
        width: number;
        get type(): string;
        set type(value: string): void;
        _drawClipPath(
            ctx: CanvasRenderingContext2D,
            clipPath:
                | FabricObject<
                    Partial<ObjectProps>,
                    SerializedObjectProps,
                    ObjectEvents,
                >
                | undefined,
            context: DrawContext,
        ): void;
        _limitCacheSize(dims: any): any;
        _removeCacheCanvas(): void;
        _renderControls(
            ctx: CanvasRenderingContext2D,
            styleOverride?: TStyleOverride,
        ): void;
        _set(key: string, value: any): this;
        _setClippingProperties(ctx: CanvasRenderingContext2D): void;
        _setFillStyles(
            ctx: CanvasRenderingContext2D,
            __namedParameters: Pick<this, "fill">,
        ): void;
        _setOptions(options?: any): void;
        _setStrokeStyles(
            ctx: CanvasRenderingContext2D,
            decl: Pick<
                this,
                | "stroke"
                | "strokeWidth"
                | "strokeLineCap"
                | "strokeDashOffset"
                | "strokeLineJoin"
                | "strokeMiterLimit",
            >,
        ): void;
        _setupCompositeOperation(ctx: CanvasRenderingContext2D): void;
        _toSVG(_reviver?: TSVGReviver): string[];
        addPaintOrder(
            this: FabricObjectSVGExportMixin & FabricObject<
                Partial<FabricObjectProps>,
                SerializedObjectProps,
                ObjectEvents,
            >,
        ): string;
        animate<T extends number | number[] | TColorArg>(
            animatable: Record<string, T>,
            options?: Partial<AnimationOptions<T>>,
        ): Record<string, TAnimation<T>>;
        calcACoords(): TCornerPoint;
        calcOCoords(): Record<string, TOCoord>;
        calcOwnMatrix(): TMat2D;
        calcTransformMatrix(skipGroup?: boolean): TMat2D;
        canDrop(_e: DragEvent): boolean;
        clearContextTop(
            restoreManually?: boolean,
        ): CanvasRenderingContext2D | undefined;
        clone(propertiesToInclude?: string[]): Promise<WhiteboardObject>;
        cloneAsImage(options?: ObjectToCanvasElementOptions): FabricImage;
        complexity(): number;
        containsPoint(point: Point): boolean;
        dispose(): void;
        drawBorders(
            ctx: CanvasRenderingContext2D,
            options: TQrDecomposeOut,
            styleOverride?: TStyleOverride,
        ): void;
        drawCacheOnCanvas(
            this: TCachedFabricObject,
            ctx: CanvasRenderingContext2D,
        ): void;
        drawClipPathOnCache(
            ctx: CanvasRenderingContext2D,
            clipPath: FabricObject,
            canvasWithClipPath: HTMLCanvasElement,
        ): void;
        drawControls(
            ctx: CanvasRenderingContext2D,
            styleOverride?: Partial<
                Pick<
                    InteractiveFabricObject<
                        Partial<FabricObjectProps>,
                        SerializedObjectProps,
                        ObjectEvents,
                    >,

                        | "cornerStyle"
                        | "cornerSize"
                        | "cornerColor"
                        | "cornerStrokeColor"
                        | "cornerDashArray"
                        | "transparentCorners",
                >,
            >,
        ): void;
        drawControlsConnectingLines(
            ctx: CanvasRenderingContext2D,
            size: Point,
        ): void;
        drawObject(
            ctx: CanvasRenderingContext2D,
            forClipping: boolean | undefined,
            context: DrawContext,
        ): void;
        drawSelectionBackground(ctx: CanvasRenderingContext2D): void;
        findCommonAncestors<T extends WhiteboardObject>(
            other: T,
        ): AncestryComparison;
        fire<K extends keyof ObjectEvents>(
            eventName: K,
            options?: ObjectEvents[K],
        ): void;
        forEachControl(
            fn: (
                control: Control,
                key: string,
                fabricObject: InteractiveFabricObject,
            ) => any,
        ): void;
        get(property: string): any;
        getActiveControl(): | { control: Control; coord: TOCoord; key: string }
        | undefined;
        getAncestors(): Ancestors;
        getBoundingRect(): TBBox;
        getCanvasRetinaScaling(): number;
        getCenterPoint(): Point;
        getCoords(): Point[];
        getObjectOpacity(): number;
        getObjectScaling(): Point;
        getPointByOrigin(originX: TOriginX, originY: TOriginY): Point;
        getRelativeCenterPoint(): Point;
        getRelativeX(): number;
        getRelativeXY(): Point;
        getRelativeY(): number;
        getScaledHeight(): number;
        getScaledWidth(): number;
        getSvgCommons(
            this: FabricObjectSVGExportMixin & FabricObject<
                Partial<FabricObjectProps>,
                SerializedObjectProps,
                ObjectEvents,
            > & { id?: string },
        ): string;
        getSvgFilter(
            this: FabricObjectSVGExportMixin & FabricObject<
                Partial<FabricObjectProps>,
                SerializedObjectProps,
                ObjectEvents,
            >,
        ): string;
        getSvgStyles(
            this: FabricObjectSVGExportMixin & FabricObject<
                Partial<FabricObjectProps>,
                SerializedObjectProps,
                ObjectEvents,
            >,
            skipShadow?: boolean,
        ): string;
        getSvgTransform(
            this: FabricObjectSVGExportMixin & FabricObject<
                Partial<FabricObjectProps>,
                SerializedObjectProps,
                ObjectEvents,
            >,
            full?: boolean,
            additionalTransform?: string,
        ): string;
        getTotalAngle(): TDegree;
        getTotalObjectScaling(): Point;
        getViewportTransform(): TMat2D;
        getX(): number;
        getXY(): Point;
        getY(): number;
        hasCommonAncestors<T extends WhiteboardObject>(other: T): boolean;
        hasFill(): boolean | "" | null;
        hasStroke(): boolean | "" | null;
        intersectsWithObject(other: ObjectGeometry): boolean;
        intersectsWithRect(tl: Point, br: Point): boolean;
        isCacheDirty(skipCanvas?: boolean): boolean;
        isContainedWithinObject(other: ObjectGeometry): boolean;
        isContainedWithinRect(tl: Point, br: Point): boolean;
        isControlVisible(controlKey: string): boolean;
        isDescendantOf(target: TAncestor): boolean;
        isInFrontOf<T extends WhiteboardObject>(other: T): boolean | undefined;
        isNotVisible(): boolean;
        isOnScreen(): boolean;
        isOverlapping<T extends ObjectGeometry<ObjectEvents>>(other: T): boolean;
        isPartiallyOnScreen(): boolean;
        isStrokeAccountedForInDimensions(): boolean;
        isType(...types: string[]): boolean;
        needsItsOwnCache(): boolean;
        off<K extends keyof ObjectEvents>(eventName: K): void;
        off<K extends keyof ObjectEvents>(
            eventName: K,
            handler: TEventCallback,
        ): void;
        off(handlers: EventRegistryObject<EventSpec>): void;
        off(): void;
        on<
            K extends keyof ObjectEvents,
            E extends
            
                    | TPointerEventInfo<TPointerEvent>
                    | TPointerEventInfo<TPointerEvent> & {
                        currentSubTargets: FabricObject<
                            Partial<FabricObjectProps>,
                            SerializedObjectProps,
                            ObjectEvents,
                        >[];
                        currentTarget?: FabricObject<
                            Partial<FabricObjectProps>,
                            SerializedObjectProps,
                            ObjectEvents,
                        >;
                        isClick: boolean;
                    }
                    | TPointerEventInfo<WheelEvent>
                    | TPointerEventInfo<TPointerEvent> & InEvent
                    | TPointerEventInfo<TPointerEvent> & OutEvent
                    | TPointerEventInfo<TPointerEvent> & TPointerEventInfo<TPointerEvent> & {
                        alreadySelected: boolean;
                    }
                    | Partial<TEvent<TPointerEvent>> & { target: FabricObject }
                    | BasicTransformEvent<TPointerEvent>
                    | BasicTransformEvent<TPointerEvent> & ModifyPathEvent
                    | ModifiedEvent<TPointerEvent>
                    | Partial<TEvent<TPointerEvent>> & { target: FabricObject }
                    | { target: Canvas | Group | StaticCanvas<StaticCanvasEvents> }
                    | { target: Canvas | Group | StaticCanvas<StaticCanvasEvents> }
                    | { path: FabricObject }
                    | TEventWithTarget<DragEvent>
                    | DragEventData
                    | DragEventData & InEvent
                    | DragEventData & OutEvent
                    | DropEventData
                    | SimpleEventHandler<Event>,
        >(
            eventName: K,
            handler: TEventCallback<E>,
        ): VoidFunction;
        on(handlers: EventRegistryObject<EventSpec>): VoidFunction;
        once<
            K extends keyof ObjectEvents,
            E extends
            
                    | TPointerEventInfo<TPointerEvent>
                    | TPointerEventInfo<TPointerEvent> & {
                        currentSubTargets: FabricObject<
                            Partial<FabricObjectProps>,
                            SerializedObjectProps,
                            ObjectEvents,
                        >[];
                        currentTarget?: FabricObject<
                            Partial<FabricObjectProps>,
                            SerializedObjectProps,
                            ObjectEvents,
                        >;
                        isClick: boolean;
                    }
                    | TPointerEventInfo<WheelEvent>
                    | TPointerEventInfo<TPointerEvent> & InEvent
                    | TPointerEventInfo<TPointerEvent> & OutEvent
                    | TPointerEventInfo<TPointerEvent> & TPointerEventInfo<TPointerEvent> & {
                        alreadySelected: boolean;
                    }
                    | Partial<TEvent<TPointerEvent>> & { target: FabricObject }
                    | BasicTransformEvent<TPointerEvent>
                    | BasicTransformEvent<TPointerEvent> & ModifyPathEvent
                    | ModifiedEvent<TPointerEvent>
                    | Partial<TEvent<TPointerEvent>> & { target: FabricObject }
                    | { target: Canvas | Group | StaticCanvas<StaticCanvasEvents> }
                    | { target: Canvas | Group | StaticCanvas<StaticCanvasEvents> }
                    | { path: FabricObject }
                    | TEventWithTarget<DragEvent>
                    | DragEventData
                    | DragEventData & InEvent
                    | DragEventData & OutEvent
                    | DropEventData
                    | SimpleEventHandler<Event>,
        >(
            eventName: K,
            handler: TEventCallback<E>,
        ): VoidFunction;
        once(handlers: EventRegistryObject<EventSpec>): VoidFunction;
        onDeselect(
            _options?: {
                e?: TPointerEvent;
                object?: InteractiveFabricObject<
                    Partial<FabricObjectProps>,
                    SerializedObjectProps,
                    ObjectEvents,
                >;
            },
        ): boolean;
        onDragStart(_e: DragEvent): boolean;
        onSelect(_options?: { e?: TPointerEvent }): boolean;
        render(ctx: CanvasRenderingContext2D): void;
        renderCache(this: TCachedFabricObject, options?: any): void;
        renderDragSourceEffect(_e: DragEvent): void;
        renderDropTargetEffect(_e: DragEvent): void;
        rotate(angle: TDegree): void;
        scale(value: number): void;
        scaleToHeight(value: number): void;
        scaleToWidth(value: number): void;
        set(key: string | Record<string, any>, value?: any): this;
        setControlsVisibility(options?: Record<string, boolean>): void;
        setControlVisible(controlKey: string, visible: boolean): void;
        setCoords(): void;
        setOnGroup(): void;
        setOptions(options?: Record<string, any>): void;
        setPositionByOrigin(pos: Point, originX: TOriginX, originY: TOriginY): void;
        setRelativeX(value: number): void;
        setRelativeXY(point: Point, originX?: TOriginX, originY?: TOriginY): void;
        setRelativeY(value: number): void;
        setX(value: number): void;
        setXY(point: Point, originX?: TOriginX, originY?: TOriginY): void;
        setY(value: number): void;
        shouldCache(): boolean;
        shouldStartDragging(_e: TPointerEvent): boolean;
        strokeBorders(ctx: CanvasRenderingContext2D, size: Point): void;
        toBlob(options?: toDataURLOptions): Promise<Blob | null>;
        toCanvasElement(options?: ObjectToCanvasElementOptions): HTMLCanvasElement;
        toClipPathSVG(
            this: FabricObjectSVGExportMixin & FabricObject<
                Partial<FabricObjectProps>,
                SerializedObjectProps,
                ObjectEvents,
            >,
            reviver?: TSVGReviver,
        ): string;
        toDatalessObject(propertiesToInclude?: any[]): any;
        toDataURL(options?: toDataURLOptions): string;
        toggle(property: string): this;
        toJSON(): any;
        toObject(propertiesToInclude?: any[]): any;
        toString(): string;
        toSVG(
            this: FabricObjectSVGExportMixin & FabricObject<
                Partial<FabricObjectProps>,
                SerializedObjectProps,
                ObjectEvents,
            >,
            reviver?: TSVGReviver,
        ): string;
        transform(ctx: CanvasRenderingContext2D): void;
        transformMatrixKey(skipGroup?: boolean): number[];
        translateToCenterPoint(
            point: Point,
            originX: TOriginX,
            originY: TOriginY,
        ): Point;
        translateToGivenOrigin(
            point: Point,
            fromOriginX: TOriginX,
            fromOriginY: TOriginY,
            toOriginX: TOriginX,
            toOriginY: TOriginY,
        ): Point;
        translateToOriginPoint(
            center: Point,
            originX: TOriginX,
            originY: TOriginY,
        ): Point;
        willDrawShadow(): boolean;
    }

    Hierarchy

    • FabricObject
      • WhiteboardObject
    Index

    Properties

    Accessors

    Methods

    _drawClipPath _limitCacheSize _removeCacheCanvas _renderControls _set _setClippingProperties _setFillStyles _setOptions _setStrokeStyles _setupCompositeOperation _toSVG addPaintOrder animate calcACoords 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 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 isStrokeAccountedForInDimensions isType needsItsOwnCache off on once onDeselect onDragStart onSelect render renderCache renderDragSourceEffect renderDropTargetEffect rotate scale scaleToHeight scaleToWidth set setControlsVisibility setControlVisible setCoords setOnGroup setOptions setPositionByOrigin setRelativeX setRelativeXY setRelativeY setX setXY setY shouldCache shouldStartDragging strokeBorders toBlob toCanvasElement toClipPathSVG toDatalessObject toDataURL toggle toJSON toObject toString toSVG transform transformMatrixKey translateToCenterPoint translateToGivenOrigin translateToOriginPoint willDrawShadow

    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

    _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

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

    absolutePositioned: boolean

    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
    
    aCoords: TCornerPoint

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

    angle: TDegree

    Angle of rotation of an object (in degrees)

    0
    
    backgroundColor: string

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

    
    
    borderColor: string

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

    rgb(178,204,255)
    
    borderDashArray: number[] | null

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

    1.6.2

    borderOpacityWhenMoving: number

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

    0.4
    
    borderScaleFactor: number

    Scale factor for the border of the objects ( selection box and controls stroke ). Bigger number will make a thicker border border default value is 1, so this scale value is equal to a border and control strokeWidth. If you need to divide border from control strokeWidth you will need to write your own render function for controls

    1
    
    centeredRotation: boolean

    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

    
    
    centeredScaling: boolean

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

    1.3.4

    
    
    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.

    controls: TControlSet

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

    cornerColor: string

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

    rgb(178,204,255)
    
    cornerDashArray: number[] | null

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

    1.6.2

    null
    
    cornerSize: number

    Size of object's controlling corners (in pixels)

    13
    
    cornerStrokeColor: string

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

    1.6.2

    ''
    
    cornerStyle: "circle" | "rect"

    Specify style of control, 'rect' or 'circle' This is deprecated. In the future there will be a standard control render And you can swap it with one of the alternative proposed with the control api

    1.6.2

    'rect'
    

    Custom properties for serialization

    dirty: boolean

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

    true
    
    evented: boolean

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

    
    
    excludeFromExport: boolean

    When true, object is not exported in OBJECT/JSON

    1.6.3

    
    
    fill: string | TFiller | null
    fillRule: CanvasFillRule

    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
    
    flipX: boolean

    When true, an object is rendered as flipped horizontally

    false
    
    flipY: boolean

    When true, an object is rendered as flipped vertically

    false
    
    globalCompositeOperation: GlobalCompositeOperation

    Composite rule used for canvas globalCompositeOperation

    
    
    hasBorders: boolean

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

    
    
    hasControls: boolean

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

    true
    
    height: number

    Object height

    
    
    hoverCursor: string | null

    Default cursor value used when hovering over this object on canvas

    null
    
    id?: string

    Unique identifier

    includeDefaultValues: boolean

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

    
    
    inverted: boolean

    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
    
    isMoving?: boolean

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

    left: number

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

    0
    
    lockMovementX: boolean

    When true, object horizontal movement is locked

    
    
    lockMovementY: boolean

    When true, object vertical movement is locked

    
    
    lockRotation: boolean

    When true, object rotation is locked

    
    
    lockScalingFlip: boolean

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

    
    
    lockScalingX: boolean

    When true, object horizontal scaling is locked

    
    
    lockScalingY: boolean

    When true, object vertical scaling is locked

    
    
    lockSkewingX: boolean

    When true, object horizontal skewing is locked

    
    
    lockSkewingY: boolean

    When true, object vertical skewing is locked

    
    
    matrixCache?: TMatrixCache

    storage cache for object full transform matrix

    minScaleLimit: number

    Minimum allowed scale value of an object

    0
    
    moveCursor: string | null

    Default cursor value used when moving this object on canvas

    null
    
    noScaleCache: boolean

    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

    true
    
    objectCaching: boolean

    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
    
    oCoords: Record<string, TOCoord>

    The object's controls' position in viewport coordinates Calculated by Control#positionHandler and Control#calcCornerCoords, depending on padding. corner/touchCorner describe the 4 points forming the interactive area of the corner. Used to draw and locate controls.

    opacity: number

    Opacity of an object

    1
    
    originX: TOriginX

    please use 'center' as value in new projects

    originY: TOriginY

    please use 'center' as value in new projects

    ownMatrixCache?: TMatrixCache

    storage cache for object transform matrix

    padding: number

    Padding between object and its controlling borders (in pixels)

    0
    
    paintFirst: "fill" | "stroke"

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

    
    
    parent?: 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

    perPixelTargetFind: boolean

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

    
    
    remote?: boolean

    Whether this object was received from a remote user

    scaleX: number

    Object scale factor (horizontal)

    1
    
    scaleY: number

    Object scale factor (vertical)

    1
    
    selectable: boolean

    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.

    
    
    selectionBackgroundColor: string

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

    
    
    shadow: Shadow | null
    skewX: number

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

    0
    
    skewY: number

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

    0
    
    snapAngle?: TDegree

    The angle that an object will lock to while rotating.

    snapThreshold?: TDegree

    The angle difference from the current snapped angle in which snapping should occur. When undefined, the snapThreshold will default to the snapAngle.

    stroke: string | TFiller | null
    strokeDashArray: number[] | null

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

    null;
    
    strokeDashOffset: number

    Line offset of an object's stroke

    0
    
    strokeLineCap: CanvasLineCap

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

    butt
    
    strokeLineJoin: CanvasLineJoin

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

    
    
    strokeMiterLimit: number

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

    4
    
    strokeUniform: boolean

    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
    
    strokeWidth: number

    Width of a stroke used to render this object

    1
    
    top: number

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

    0
    
    touchCornerSize: number

    Size of object's controlling corners when touch interaction is detected

    24
    
    transparentCorners: boolean

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

    true
    
    visible: boolean

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

    
    
    width: number

    Object width

    
    

    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 to avoid type errors in old code and possibly current deserialization code. DO NOT build new code around this type value

      Returns string

      add sustainable warning message

    • set type(value: string): void

      Parameters

      • value: string

      Returns void

    Methods

    • Prepare clipPath state and cache and draw it on instance's cache

      Parameters

      • ctx: CanvasRenderingContext2D
      • clipPath:
            | FabricObject<
                Partial<ObjectProps>,
                SerializedObjectProps,
                ObjectEvents,
            >
            | undefined
      • context: DrawContext

      Returns void

    • 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

    • Remove cacheCanvas and its dimensions from the objects

      Returns void

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

      Parameters

      • ctx: CanvasRenderingContext2D

        Context to render on

      • OptionalstyleOverride: TStyleOverride

        properties to override the object style

      Returns void

      move to interactivity

    • Protected

      Handles setting values on the instance and handling internal side effects

      Parameters

      • key: string
      • value: any

      Returns this

    • Parameters

      • ctx: CanvasRenderingContext2D

      Returns void

    • Parameters

      • ctx: CanvasRenderingContext2D
      • __namedParameters: Pick<this, "fill">

      Returns void

    • Protected

      Sets object's properties from options, for initialization only

      Parameters

      • Optionaloptions: any

        Options object

      Returns void

    • Parameters

      • ctx: CanvasRenderingContext2D
      • decl: Pick<
            this,
            | "stroke"
            | "strokeWidth"
            | "strokeLineCap"
            | "strokeDashOffset"
            | "strokeLineJoin"
            | "strokeMiterLimit",
        >

      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 This function is implemented in each subclass This is just because typescript otherwise cryies all the time

      Parameters

      • Optional_reviver: TSVGReviver

      Returns string[]

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

    • Parameters

      • this: FabricObjectSVGExportMixin & FabricObject<
            Partial<FabricObjectProps>,
            SerializedObjectProps,
            ObjectEvents,
        >

      Returns string

    • Animates object's properties

      Type Parameters

      • T extends number | number[] | TColorArg

      Parameters

      • animatable: Record<string, T>

        map of keys and end values

      • Optionaloptions: Partial<AnimationOptions<T>>

      Returns Record<string, TAnimation<T>>

      map of animation contexts

      As object — multiple properties

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

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

      Returns TCornerPoint

    • 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, this matrix does not include the group transformation

      Returns TMat2D

      transform matrix for the object

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

      Parameters

      • OptionalskipGroup: boolean

        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

    • Override to customize drag and drop behavior

      Parameters

      • _e: DragEvent

      Returns boolean

      true if the object currently dragged can be dropped on the target

    • 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

      • OptionalrestoreManually: boolean

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

      Returns CanvasRenderingContext2D | undefined

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

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

    • Clones an instance.

      Parameters

      • OptionalpropertiesToInclude: string[]

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

      Returns Promise<WhiteboardObject>

    • 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

      • Optionaloptions: ObjectToCanvasElementOptions

        for clone as image, passed to toDataURL

        • multiplier

          Multiplier to scale by

        • left

          Cropping left offset. Introduced in v1.2.14

        • top

          Cropping top offset. Introduced in v1.2.14

        • width

          Cropping width. Introduced in v1.2.14

        • height

          Cropping height. Introduced in v1.2.14

        • enableRetinaScaling

          Enable retina scaling for clone image. Introduce in 1.6.4

        • withoutTransform

          Remove current object transform ( no scale , no angle, no flip, no skew ). Introduced in 2.3.4

        • withoutShadow

          Remove current object shadow. Introduced in 2.4.2

      Returns FabricImage

      Object cloned as image.

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

    • Returns complexity of an instance

      Returns number

      complexity of this instance (is 1 unless subclassed)

    • Checks if point is inside the object

      Parameters

      • point: Point

        Point to check against

      Returns boolean

      true if point is inside the object

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

      Returns void

    • 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: TQrDecomposeOut

        object representing current object parameters

      • OptionalstyleOverride: TStyleOverride

        object to override the object style

      Returns void

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

      Parameters

      • this: TCachedFabricObject
      • ctx: CanvasRenderingContext2D

        Context to render on

      Returns void

    • Execute the drawing operation for an object clipPath

      Parameters

      • ctx: CanvasRenderingContext2D

        Context to render on

      • clipPath: FabricObject
      • canvasWithClipPath: HTMLCanvasElement

      Returns void

    • Draws corners of an object's bounding box. Requires public properties: width, height Requires public options: cornerSize, padding Be aware that since fabric 6.0 this function does not call setCoords anymore. setCoords needs to be called manually if the object of which we are rendering controls is outside the standard selection and transform process.

      Parameters

      • ctx: CanvasRenderingContext2D

        Context to draw on

      • OptionalstyleOverride: 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

      • forClipping: boolean | undefined

        apply clipping styles

      • context: DrawContext

        additional context for rendering

      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

      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

      Parameters

      • other: T

      Returns AncestryComparison

      an object that represent the ancestry situation.

    • Fires event with an optional options object

      Type Parameters

      • K extends keyof ObjectEvents

      Parameters

      • eventName: K

        Event name to fire

      • Optionaloptions: ObjectEvents[K]

        Options object

      Returns void

    • Calls a function for each control. The function gets called, with the control, the control's key and the object that is calling the iterator

      Parameters

      • fn: (control: Control, key: string, fabricObject: InteractiveFabricObject) => any

        function to iterate over the controls over

      Returns void

    • Basic getter

      Parameters

      • property: string

        Property name

      Returns any

      value of a property

    • Returns { control: Control; coord: TOCoord; key: string } | undefined

    • Returns Ancestors

      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.

      Returns TBBox

      Object with left, top, width, height properties

    • Returns number

    • Returns the center coordinates of the object relative to canvas

      Returns Point

    • Returns Point[]

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

    • Return the object opacity counting also the group property

      Returns number

    • Return the object scale factor counting also the group scaling

      Returns Point

    • 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? )

      Parameters

      • originX: TOriginX

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

      • originY: TOriginY

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

      Returns Point

    • Returns the center coordinates of the object relative to it's parent

      Returns Point

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

    • Returns Point

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

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

    • Returns height of an object bounding box counting transformations

      Returns number

      height value

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

    • Returns width of an object's bounding box counting transformations

      Returns number

      width value

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

    • Returns id attribute for svg output

      Parameters

      • this: FabricObjectSVGExportMixin & FabricObject<
            Partial<FabricObjectProps>,
            SerializedObjectProps,
            ObjectEvents,
        > & { id?: string }

      Returns string

    • Returns filter for svg shadow

      Parameters

      • this: FabricObjectSVGExportMixin & FabricObject<
            Partial<FabricObjectProps>,
            SerializedObjectProps,
            ObjectEvents,
        >

      Returns string

    • Returns styles-string for svg-export

      Parameters

      • this: FabricObjectSVGExportMixin & FabricObject<
            Partial<FabricObjectProps>,
            SerializedObjectProps,
            ObjectEvents,
        >
      • OptionalskipShadow: boolean

        a boolean to skip shadow filter output

      Returns string

    • Returns transform-string for svg-export

      Parameters

      • this: FabricObjectSVGExportMixin & FabricObject<
            Partial<FabricObjectProps>,
            SerializedObjectProps,
            ObjectEvents,
        >
      • Optionalfull: boolean
      • OptionaladditionalTransform: string

      Returns string

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

      Returns TDegree

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

      Returns Point

      object with scaleX and scaleY properties

    • Retrieves viewportTransform from Object's canvas if available

      Returns TMat2D

    • Returns number

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

    • Returns Point

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

    • Returns number

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

    • Type Parameters

      Parameters

      • other: T

      Returns boolean

    • 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 boolean | "" | null

      Boolean

      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 boolean | "" | null

      Boolean

      3.0.0

    • Checks if object intersects with another object

      Parameters

      • other: ObjectGeometry

        Object to test

      Returns boolean

      true if object intersects with another object

    • 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

      Parameters

      • tl: Point
      • br: Point

      Returns boolean

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

      Parameters

      • OptionalskipCanvas: boolean

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

      Returns boolean

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

      Parameters

      • other: ObjectGeometry

        Object to test

      Returns boolean

      true if object is fully contained within area of another object

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

      Parameters

      • tl: Point
      • br: Point

      Returns boolean

    • 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

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

      Parameters

      • target: TAncestor

      Returns boolean

    • Type Parameters

      Parameters

      • other: T

        object to compare against

      Returns boolean | undefined

      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

    • Returns boolean

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

      Returns boolean

      true if object is fully or partially contained within canvas

    • Type Parameters

      • T extends ObjectGeometry<ObjectEvents>

      Parameters

      • other: T

      Returns boolean

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

      Returns boolean

      true if object is partially contained within canvas

    • Returns boolean

      intermidiate method to be removed, do not use

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

      Parameters

      • ...types: string[]

      Returns boolean

    • 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

      Returns boolean

      Boolean

    • 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

      Type Parameters

      • K extends keyof ObjectEvents

      Parameters

      • eventName: K

        event name (eg. 'after:render')

      Returns void

    • unsubscribe an event listener

      Type Parameters

      • K extends keyof ObjectEvents

      Parameters

      • eventName: K

        event name (eg. 'after:render')

      • handler: TEventCallback

        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 keyof ObjectEvents
      • E extends
            | TPointerEventInfo<TPointerEvent>
            | TPointerEventInfo<TPointerEvent> & {
                currentSubTargets: FabricObject<
                    Partial<FabricObjectProps>,
                    SerializedObjectProps,
                    ObjectEvents,
                >[];
                currentTarget?: FabricObject<
                    Partial<FabricObjectProps>,
                    SerializedObjectProps,
                    ObjectEvents,
                >;
                isClick: boolean;
            }
            | TPointerEventInfo<WheelEvent>
            | TPointerEventInfo<TPointerEvent> & InEvent
            | TPointerEventInfo<TPointerEvent> & OutEvent
            | TPointerEventInfo<TPointerEvent> & TPointerEventInfo<TPointerEvent> & {
                alreadySelected: boolean;
            }
            | Partial<TEvent<TPointerEvent>> & { target: FabricObject }
            | BasicTransformEvent<TPointerEvent>
            | BasicTransformEvent<TPointerEvent> & ModifyPathEvent
            | ModifiedEvent<TPointerEvent>
            | Partial<TEvent<TPointerEvent>> & { target: FabricObject }
            | { target: Canvas | Group | StaticCanvas<StaticCanvasEvents> }
            | { target: Canvas | Group | StaticCanvas<StaticCanvasEvents> }
            | { path: FabricObject }
            | TEventWithTarget<DragEvent>
            | DragEventData
            | DragEventData & InEvent
            | DragEventData & OutEvent
            | DropEventData
            | SimpleEventHandler<Event>

      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

      on

    • Observes specified event

      Parameters

      • handlers: EventRegistryObject<EventSpec>

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

      Returns VoidFunction

      disposer

      on

    • Observes specified event once

      Type Parameters

      • K extends keyof ObjectEvents
      • E extends
            | TPointerEventInfo<TPointerEvent>
            | TPointerEventInfo<TPointerEvent> & {
                currentSubTargets: FabricObject<
                    Partial<FabricObjectProps>,
                    SerializedObjectProps,
                    ObjectEvents,
                >[];
                currentTarget?: FabricObject<
                    Partial<FabricObjectProps>,
                    SerializedObjectProps,
                    ObjectEvents,
                >;
                isClick: boolean;
            }
            | TPointerEventInfo<WheelEvent>
            | TPointerEventInfo<TPointerEvent> & InEvent
            | TPointerEventInfo<TPointerEvent> & OutEvent
            | TPointerEventInfo<TPointerEvent> & TPointerEventInfo<TPointerEvent> & {
                alreadySelected: boolean;
            }
            | Partial<TEvent<TPointerEvent>> & { target: FabricObject }
            | BasicTransformEvent<TPointerEvent>
            | BasicTransformEvent<TPointerEvent> & ModifyPathEvent
            | ModifiedEvent<TPointerEvent>
            | Partial<TEvent<TPointerEvent>> & { target: FabricObject }
            | { target: Canvas | Group | StaticCanvas<StaticCanvasEvents> }
            | { target: Canvas | Group | StaticCanvas<StaticCanvasEvents> }
            | { path: FabricObject }
            | TEventWithTarget<DragEvent>
            | DragEventData
            | DragEventData & InEvent
            | DragEventData & OutEvent
            | DropEventData
            | SimpleEventHandler<Event>

      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

      once

    • Observes specified event once

      Parameters

      • handlers: EventRegistryObject<EventSpec>

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

      Returns VoidFunction

      disposer

      once

    • 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

      • Optional_options: {
            e?: TPointerEvent;
            object?: InteractiveFabricObject<
                Partial<FabricObjectProps>,
                SerializedObjectProps,
                ObjectEvents,
            >;
        }

        options sent from the upper functions

      Returns boolean

    • Override to customize Drag behavior
      Fired once a drag session has started

      Parameters

      • _e: DragEvent

      Returns boolean

      true to handle the drag event

    • 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

        • Optionale?: TPointerEvent

          event if the process is generated by an event

      Returns boolean

    • Renders an object on a specified context

      Parameters

      • ctx: CanvasRenderingContext2D

        Context to render on

      Returns void

    • Parameters

      • this: TCachedFabricObject
      • Optionaloptions: any

      Returns void

    • 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

    • Sets "angle" of an instance with centered rotation

      Parameters

      • angle: TDegree

        Angle value (in degrees)

      Returns void

    • Scales an object (equally by x and y)

      Parameters

      • value: number

        Scale factor

      Returns void

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

      Parameters

      • value: number

        New height value

      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

      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)

      • Optionalvalue: any

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

      Returns this

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

      Parameters

      • Optionaloptions: 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

    • 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

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

    • 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

      • Optionaloptions: Record<string, any>

        Options object

      Returns void

    • Sets the position of the object taking into consideration the object's origin

      Parameters

      • pos: Point

        The new position of the object

      • originX: TOriginX

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

      • originY: TOriginY

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

      Returns void

    • Parameters

      • value: 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

      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 FabricObject#originX FabricObject#originY properties in parent's coordinate plane

      • OptionaloriginX: TOriginX

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

      • OptionaloriginY: TOriginY

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

      Returns void

    • Parameters

      • value: 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

      Returns void

    • Parameters

      • value: number

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

      Returns void

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

      Parameters

      • point: Point

        position in scene coordinate plane

      • OptionaloriginX: TOriginX

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

      • OptionaloriginY: TOriginY

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

      Returns void

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

      • value: number

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

      Returns void

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

      Returns boolean

    • Override to customize Drag behavior Fired from Canvas#_onMouseMove

      Parameters

      • _e: TPointerEvent

      Returns boolean

      true in order for the window to start a drag session

    • 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

    • Parameters

      • Optionaloptions: toDataURLOptions

      Returns Promise<Blob | null>

    • Converts an object into a HTMLCanvas element

      Parameters

      • Optionaloptions: ObjectToCanvasElementOptions

        Options object

        • multiplier

          Multiplier to scale by

        • left

          Cropping left offset. Introduced in v1.2.14

        • top

          Cropping top offset. Introduced in v1.2.14

        • width

          Cropping width. Introduced in v1.2.14

        • height

          Cropping height. Introduced in v1.2.14

        • enableRetinaScaling

          Enable retina scaling for clone image. Introduce in 1.6.4

        • withoutTransform

          Remove current object transform ( no scale , no angle, no flip, no skew ). Introduced in 2.3.4

        • withoutShadow

          Remove current object shadow. Introduced in 2.4.2

        • viewportTransform

          Account for canvas viewport transform

        • canvasProvider

          Create the output canvas

      Returns HTMLCanvasElement

      Returns DOM element with the FabricObject

    • Returns svg clipPath representation of an instance

      Parameters

      • this: FabricObjectSVGExportMixin & FabricObject<
            Partial<FabricObjectProps>,
            SerializedObjectProps,
            ObjectEvents,
        >
      • Optionalreviver: TSVGReviver

        Method for further parsing of svg representation.

      Returns string

      svg representation of an instance

    • Returns (dataless) object representation of an instance

      Parameters

      • OptionalpropertiesToInclude: any[]

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

      Returns any

      Object representation of an instance

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

      Parameters

      • Optionaloptions: toDataURLOptions

        Options object

        • format

          The format of the output image. Either "jpeg" or "png"

        • quality

          Quality level (0..1). Only used for jpeg.

        • multiplier

          Multiplier to scale by

        • left

          Cropping left offset. Introduced in v1.2.14

        • top

          Cropping top offset. Introduced in v1.2.14

        • width

          Cropping width. Introduced in v1.2.14

        • height

          Cropping height. Introduced in v1.2.14

        • enableRetinaScaling

          Enable retina scaling for clone image. Introduce in 1.6.4

        • withoutTransform

          Remove current object transform ( no scale , no angle, no flip, no skew ). Introduced in 2.3.4

        • withoutShadow

          Remove current object shadow. Introduced in 2.4.2

      Returns string

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

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

      Parameters

      • property: string

        Property to toggle

      Returns this

    • Returns a JSON representation of an instance

      Returns any

      JSON

    • Returns an object representation of an instance

      Parameters

      • OptionalpropertiesToInclude: any[]

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

      Returns any

      Object representation of an instance

    • Returns a string representation of an instance

      Returns string

    • Returns svg representation of an instance

      Parameters

      • this: FabricObjectSVGExportMixin & FabricObject<
            Partial<FabricObjectProps>,
            SerializedObjectProps,
            ObjectEvents,
        >
      • Optionalreviver: TSVGReviver

        Method for further parsing of svg representation.

      Returns string

      svg representation of an instance

    • Transforms context when rendering an object

      Parameters

      • ctx: CanvasRenderingContext2D

        Context

      Returns void

    • Parameters

      • OptionalskipGroup: boolean

      Returns number[]

    • 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: TOriginX

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

      • originY: TOriginY

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

      Returns Point

    • 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

    • 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: TOriginX

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

      • originY: TOriginY

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

      Returns Point

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

      Returns boolean