### Complete Hello World Example Source: https://fabricjs.com/docs/getting-started/helloworld A full implementation of the Hello World example using the global fabric object. ```javascript const { StaticCanvas, FabricText } = fabric; const canvas = new StaticCanvas(); const helloWorld = new FabricText('Hello world!'); canvas.add(helloWorld); canvas.centerObject(helloWorld); const imageSrc = canvas.toDataURL(); // some download code down here const a = document.createElement('a'); a.href = imageSrc; a.download = 'image.png'; document.body.appendChild(a); a.click(); document.body.removeChild(a); ``` -------------------------------- ### IText Path Example Source: https://fabricjs.com/api/classes/itext Example demonstrating how to create an IText object that follows a path. The path itself can be styled or hidden. ```javascript const textPath = new Text('Text on a path', { top: 150, left: 150, textAlign: 'center', charSpacing: -50, path: new Path('M 0 0 C 50 -100 150 -100 200 0', { strokeWidth: 1, visible: false }), pathSide: 'left', pathStartOffset: 0 }); ``` -------------------------------- ### Install Fabric.js via npm Source: https://fabricjs.com/docs/getting-started/installing Use this command to install the Fabric.js package and save it as a dependency in your project. ```bash npm i --save fabric ``` -------------------------------- ### compositionStart Source: https://fabricjs.com/api/classes/textbox The starting index for text composition. This property is inherited from IText. ```APIDOC ## compositionStart ### Description The starting index for text composition. This property is inherited from `IText`. ### Type `number` ``` -------------------------------- ### onCompositionStart() Source: https://fabricjs.com/api/classes/itext Handles the start of a text composition event. This method is inherited from ITextClickBehavior. ```APIDOC ## onCompositionStart() ### Description Handles the start of a text composition event. ### Signature `onCompositionStart(): void` ### Returns `void` ### Inherited from `ITextClickBehavior.onCompositionStart` ``` -------------------------------- ### onDragStart() Source: https://fabricjs.com/api/classes/polyline Override to customize Drag behavior. Fired once a drag session has started. ```APIDOC ## onDragStart(_e) ### Description Override to customize Drag behavior. Fired once a drag session has started. ### Method ``` boolean ``` ### Parameters #### _e - **_e** (`DragEvent`) - Description: ### Returns - **boolean** true to handle the drag event ``` -------------------------------- ### onDragStart() Source: https://fabricjs.com/api/classes/fabricimage Override to customize Drag behavior. Fired once a drag session has started. ```APIDOC ## onDragStart() ### Description Override to customize Drag behavior. Fired once a drag session has started. ### Method (Implicitly called) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters #### _e `DragEvent` - Description not provided. ### Returns `boolean` - true to handle the drag event. ### Inherited from `FabricObject`.`onDragStart` ``` -------------------------------- ### onDragStart() Source: https://fabricjs.com/api/classes/rect Callback function executed when a drag session starts. Override to customize drag behavior. ```APIDOC ## onDragStart(_e) ### Description Override to customize Drag behavior Fired once a drag session has started ### Method onDragStart ### Parameters #### Path Parameters - **_e** (DragEvent) - Required ### Returns `boolean` - true to handle the drag event ### Inherited from `FabricObject`.`onDragStart` ``` -------------------------------- ### Install Gradient Updater Source: https://fabricjs.com/docs/upgrading/upgrading-to-fabric-70 Utility to maintain compatibility with legacy data containing opacity values in Gradient ColorStops. ```javascript import { installGradientUpdater } from 'fabric/extensions'; installGradientUpdater(); ``` -------------------------------- ### compositionStart Source: https://fabricjs.com/api/classes/itext A numerical value related to the start of text composition. ```APIDOC ## compositionStart ### Description A numerical value related to the start of text composition. ### Type `number` ### Overrides `ITextClickBehavior.compositionStart` ``` -------------------------------- ### onDragStart Source: https://fabricjs.com/api/classes/interactivefabricobject Callback function executed once a drag session has started. Override to customize drag behavior. ```APIDOC ## onDragStart(_e) ### Description Override to customize Drag behavior. Fired once a drag session has started. ### Method `onDragStart` ### Parameters #### _e - **_e** (`DragEvent`) ### Returns - **boolean** true to handle the drag event ``` -------------------------------- ### onDragStart(_e) Source: https://fabricjs.com/api/classes/line Callback function executed when a drag session starts. Override to customize drag behavior. ```APIDOC ## onDragStart(_e) ### Description Override to customize Drag behavior. Fired once a drag session has started. ### Method `boolean` ### Endpoint N/A (Method within a class) ### Parameters #### Path Parameters * **_e** (`DragEvent`) ### Returns `boolean` - true to handle the drag event ### Inherited from `FabricObject`.`onDragStart` ``` -------------------------------- ### Resize Filter Example Usage Source: https://fabricjs.com/api/fabric/namespaces/filters/classes/resize Example of how to apply the Resize filter to an object in Fabric.js. ```APIDOC ## Example Usage ### Description This example demonstrates how to instantiate and apply the Resize filter to an object. ### Code ```javascript const filter = new Resize(); object.filters.push(filter); object.applyFilters(canvas.renderAll.bind(canvas)); ``` ``` -------------------------------- ### setupGLContext() Source: https://fabricjs.com/api/classes/webglfilterbackend Sets up the WebGL context and binds necessary event handlers. ```APIDOC ## setupGLContext() ### Description Setup a WebGL context suitable for filtering, and bind any needed event handlers. ### Parameters #### Path Parameters - **width** (number) - Required - **height** (number) - Required ### Returns - **void** ``` -------------------------------- ### SprayBrush Constructor Source: https://fabricjs.com/api/classes/spraybrush Initializes a new instance of the SprayBrush. ```APIDOC ## new SprayBrush(canvas) ### Description Initializes a new instance of the SprayBrush. ### Method Constructor ### Parameters #### canvas - **canvas** (Canvas) - Required - The canvas object to associate with the brush. ### Returns - **SprayBrush** - An instance of a spray brush. ### Overrides `BaseBrush`.`constructor` ``` -------------------------------- ### Setting up Video Elements for Fabric.js Source: https://fabricjs.com/demos/video-element This snippet initializes multiple video elements, sets their sources, dimensions, and playback behavior. It prepares them for use with Fabric.js. ```javascript const canvas = new fabric.Canvas(canvasEl); const video1El = document.createElement('video'); const video2El = document.createElement('video'); const video1source = document.createElement('source'); const video2source = document.createElement('source'); const webcamEl = document.createElement('video'); // FabricImage requires the width and height attributes to be set video1El.width = 480; video1El.height = 360; video1El.id = 'video1' video1El.muted = true; video1El.appendChild(video1source); video1source.src = '/site_assets/dizzy.mp4'; video1El.onended = () => video1El.play(); video2El.width = 1280; video2El.height = 720; video2El.id = 'video2' video2El.muted = true; video2El.appendChild(video2source); video2source.src = '/site_assets/big-buck-bunny.mp4'; video2El.onended = () => video2El.play(); webcamEl.width = 500; webcamEl.height = 360; webcamEl.id = 'webcam' webcamEl.muted = true; ``` -------------------------------- ### SVG Radial Gradient Examples Source: https://fabricjs.com/api/classes/gradient Examples of SVG radial gradient definitions. These can be used with Fabric.js to create gradient fills for objects. ```html ``` ```html ``` -------------------------------- ### SVG Linear Gradient Examples Source: https://fabricjs.com/api/classes/gradient Examples of SVG linear gradient definitions. These can be used with Fabric.js to create gradient fills for objects. ```html ``` ```html ``` -------------------------------- ### Basic Animation Setup with Easing Source: https://fabricjs.com/demos/animation-easing Sets up a rectangle on the canvas and an animation button. When the button is clicked, the rectangle animates between two positions using a selected easing function. The canvas is re-rendered on each animation frame. ```javascript const canvas = new fabric.Canvas(canvasEl); const rect = new fabric.Rect({ width: 50, height: 50, left: 100, top: 100, stroke: '#aaf', strokeWidth: 5, fill: '#faa', selectable: false, }); canvas.add(rect); const animateBtn = document.getElementById('animate'); animateBtn.onclick = function () { animateBtn.disabled = true; rect.animate( { left: rect.left === 100 ? 400 : 100 }, { duration: 1000, onChange: () => canvas.requestRenderAll(), onComplete: function () { animateBtn.disabled = false; }, easings: fabric.util.ease[document.getElementById('easing').value], } ); }; Run me ``` -------------------------------- ### Constructor Source: https://fabricjs.com/api/classes/color Initializes a new Color object. Accepts a color argument in hex, rgb(a), or hsl format, or from a known color list. ```APIDOC ## new Color(color?) ### Description Initializes a new Color object. Accepts a color argument in hex, rgb(a), or hsl format, or from a known color list. ### Parameters #### color? (TColorArg) - Optional - Color value in hex, rgb(a), hsl format, or from known color list. ### Returns `Color` ``` -------------------------------- ### removeChars() Source: https://fabricjs.com/api/classes/itext Removes characters from a specified start and end position. The start and end positions are based on grapheme positions within the internal text array. ```APIDOC ## removeChars() ### Description Removes characters from start/end. Start and end are per grapheme position in the _text array. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters #### start - **start** (number) - Required - The starting grapheme position for character removal. #### end - **end** (number) - Optional - The ending grapheme position for character removal. Defaults to start + 1. ### Returns `void` ### Request Example ```json { "example": "No request body" } ``` ### Response #### Success Response (200) `void` #### Response Example ```json { "example": "No response body" } ``` ``` -------------------------------- ### Constructor: new StaticCanvasDOMManager Source: https://fabricjs.com/api/classes/staticcanvasdommanager Initializes a new instance of the StaticCanvasDOMManager. ```APIDOC ## Constructor ### Description Creates a new instance of StaticCanvasDOMManager. ### Parameters - **arg0** (string | HTMLCanvasElement) - Optional - The canvas element or selector. ### Returns - **StaticCanvasDOMManager** - The initialized manager instance. ``` -------------------------------- ### get type Source: https://fabricjs.com/api/classes/group Accessor to get the legacy identifier of the class. Prefer using utils like isType or instanceOf. This method will be removed in fabric 7 or 8. ```APIDOC ## get type ### Description Accessor to get the 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. ### Signature `get type(): string` ### Defined in `src/shapes/Object/Object.ts:354` ### Returns `string` ### Inherited from `createCollectionMixin( FabricObject, ).type` ``` -------------------------------- ### onDragStart Source: https://fabricjs.com/api/classes/fabrictext Callback function invoked when a drag session starts. Can be overridden to customize drag behavior. ```APIDOC ## onDragStart ### Description Callback function invoked when a drag session starts. Can be overridden to customize drag behavior. ### Method `onDragStart(_e: DragEvent): boolean` ### Parameters #### _e - **_e** (DragEvent) - Required ### Returns - **boolean** - true to handle the drag event ``` -------------------------------- ### Set Selection Start and End with Shift Source: https://fabricjs.com/api/classes/textbox Adjusts the selection start and end indices to mimic keyboard/mouse navigation when the shift key is pressed. This method is inherited from the IText class. ```typescript setSelectionStartEndWithShift(start: number, end: number, newSelection: number): void ``` -------------------------------- ### _chooseObjectsToRender Source: https://fabricjs.com/api/classes/canvas Divides objects into two groups: those to render immediately and those to render as part of an active group. ```APIDOC ## _chooseObjectsToRender() ### Description Divides objects in two groups, one to render immediately and one to render as activeGroup. ### Method (Not explicitly defined, likely internal) ### Endpoint (Not applicable) ### Parameters None ### Returns `FabricObject, SerializedObjectProps, ObjectEvents>[]` - Objects to render immediately and pushes the other in the activeGroup. ``` -------------------------------- ### noScaleCache Source: https://fabricjs.com/api/classes/circle 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 dependent. ```APIDOC ## noScaleCache ### Description 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 dependent. ### Type `boolean` ### Default `true` ### Inherited from `FabricObject` ``` -------------------------------- ### noScaleCache Source: https://fabricjs.com/api/classes/triangle 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 dependent. Defaults to true since 1.7.0. ```APIDOC ## noScaleCache ### Description 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 ### Type `boolean` ### Default ``` true ``` ### Defined in src/shapes/Object/InteractiveObject.ts:51 ``` -------------------------------- ### createProgram() Source: https://fabricjs.com/api/fabric/namespaces/filters/classes/resize Compiles a shader program for WebGL filters. ```APIDOC ## createProgram() ### Description Compile this filter’s shader program. ### Parameters #### gl - **gl** (WebGLRenderingContext) - Required - The GL canvas context to use for shader compilation. #### fragmentSource - **fragmentSource** (string) - Required - fragmentShader source for compilation #### vertexSource - **vertexSource** (string) - Required - vertexShader source for compilation ### Returns - **object** - **attributeLocations** (TWebGLAttributeLocationMap) - **program** (WebGLProgram) - **uniformLocations** (TWebGLUniformLocationMap) ``` -------------------------------- ### createProgram() Source: https://fabricjs.com/api/fabric/namespaces/filters/classes/vibrance Compiles a WebGL shader program for a filter. ```APIDOC ## createProgram() ### Description Compile this filter’s shader program. ### Parameters - **gl** (WebGLRenderingContext) - Required - The GL canvas context to use for shader compilation. - **fragmentSource** (string) - Required - fragmentShader source for compilation. - **vertexSource** (string) - Required - vertexShader source for compilation. ### Returns - **attributeLocations** (TWebGLAttributeLocationMap) - Map of attribute locations. - **program** (WebGLProgram) - The compiled shader program. - **uniformLocations** (TWebGLUniformLocationMap) - Map of uniform locations. ``` -------------------------------- ### noScaleCache Source: https://fabricjs.com/api/classes/group 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 property has a default value of true, is inherited from the createCollectionMixin, and implemented by GroupProps. ```APIDOC ## noScaleCache ### Description 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 ### Type `boolean` ### Default ``` true ``` ### Defined in src/shapes/Object/InteractiveObject.ts:51 ### Implementation of `GroupProps`.`noScaleCache` ### Inherited from `createCollectionMixin( FabricObject, ).noScaleCache` ``` -------------------------------- ### noScaleCache Source: https://fabricjs.com/api/classes/ellipse 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 property has a default value of true, is inherited from FabricObject, and implements EllipseProps. ```APIDOC ## noScaleCache ### Description 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 ### Type `boolean` ### Default ``` true ``` ### Defined in src/shapes/Object/InteractiveObject.ts:51 ### Implementation of `EllipseProps`.`noScaleCache` ### Inherited from `FabricObject`.`noScaleCache` ``` -------------------------------- ### startAngle Source: https://fabricjs.com/api/classes/circle Angle for the start of the circle, in degrees. ```APIDOC ## startAngle ### Description Angle for the start of the circle, in degrees. ### Type `number` ### Default ``` 0 ``` ### Implementation of `UniqueCircleProps.startAngle` ``` -------------------------------- ### get(property) Source: https://fabricjs.com/api/classes/staticcanvas Basic getter for a property. ```APIDOC ## get(property) ### Description Basic getter. ### Method `get` ### Parameters #### property - **property** (`string`) - Property name ### Returns `any` - Value of a property ### Inherited from `createCollectionMixin(CommonMethods).get` ``` -------------------------------- ### Control Constructor Source: https://fabricjs.com/api/classes/control Initializes a new instance of the Control class. It accepts an optional `options` object to configure the control's properties. ```APIDOC ## new Control(options?) ### Description Initializes a new instance of the Control class. ### Parameters #### options? (Partial) An optional object containing properties to configure the control. ### Returns `Control` - The newly created Control instance. ``` -------------------------------- ### get() Source: https://fabricjs.com/api/classes/polygon Basic getter for object properties. ```APIDOC ## get() ### Description Basic getter for object properties. ### Method `get` ### Parameters #### property - **property** (`string`) - Property name ### Returns `any` - value of a property ### Inherited from `Polyline`.`get` ``` -------------------------------- ### FitContentLayout Constructor Source: https://fabricjs.com/api/classes/fitcontentlayout Initializes a new instance of the FitContentLayout class. This constructor is inherited from the LayoutStrategy class. ```APIDOC ## Constructor ### Description Initializes a new instance of the `FitContentLayout` class. ### Returns `FitContentLayout` - A new instance of `FitContentLayout`. ### Inherited from `LayoutStrategy` ``` -------------------------------- ### width Source: https://fabricjs.com/api/classes/fabricimage Gets or sets the width of the object. ```APIDOC ## width ### Description Object width ### Property `width` : `number` ### Implementation of `ImageProps.width` ### Inherited from `FabricObject.width` ``` -------------------------------- ### noScaleCache Source: https://fabricjs.com/api/interfaces/groupprops 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 dependent. Defaults to true since 1.7.0. Inherited from FabricObjectProps. ```APIDOC ## noScaleCache ### Description 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 dependent. Defaults to `true` since 1.7.0. ### Type `optional boolean` ### Default ``` true ``` ### Defined in src/shapes/Object/types/FabricObjectProps.ts:17 ### Inherited from `FabricObjectProps`.`noScaleCache` ``` -------------------------------- ### Create a Polygon Instance Source: https://fabricjs.com/api/classes/polygon Instantiate a new Polygon object by providing an array of points and an optional options object for styling and positioning. This example demonstrates creating a polygon with specific points and stroke properties. ```javascript var poly = new Polyline([ { x: 10, y: 10 }, { x: 50, y: 30 }, { x: 40, y: 70 }, { x: 60, y: 50 }, { x: 100, y: 150 }, { x: 40, y: 100 } ], { stroke: 'red', left: 100, top: 100 }); ``` -------------------------------- ### getCanvasRetinaScaling() Source: https://fabricjs.com/api/classes/polygon Gets the retina scaling factor of the canvas. ```APIDOC ## getCanvasRetinaScaling() ### Description Gets the retina scaling factor of the canvas. ### Method `getCanvasRetinaScaling` ### Returns `number` ### Inherited from `Polyline`.`getCanvasRetinaScaling` ``` -------------------------------- ### get() Source: https://fabricjs.com/api/classes/circle Retrieves the value of a specified property from the object. ```APIDOC ## get() ### Description Basic getter for object properties. ### Method (Implicitly a method of the Circle object) ### Parameters #### Path Parameters - **property** (string) - Required - Property name ### Returns `any` - value of a property ### Inherited from `FabricObject` ``` -------------------------------- ### Constructor: new PencilBrush Source: https://fabricjs.com/api/classes/pencilbrush Initializes a new instance of the PencilBrush class. ```APIDOC ## new PencilBrush(canvas) ### Description Creates a new PencilBrush instance associated with a specific canvas. ### Parameters #### Path Parameters - **canvas** (Canvas) - Required - The canvas instance to associate with the brush. ### Response - **Returns** (PencilBrush) - The initialized PencilBrush instance. ``` -------------------------------- ### getTransformAnchorPoint() Source: https://fabricjs.com/api/classes/control Gets the anchor point used for transformations. ```APIDOC ## getTransformAnchorPoint() ### Description Gets the anchor point used for transformations. ### Method (Implicitly called by the system) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Returns #### Success Response `object` - An object containing the x and y coordinates of the anchor point. ### Anchor Point Details #### x `TOriginX` - The x-coordinate of the anchor point. #### y `TOriginY` - The y-coordinate of the anchor point. ``` -------------------------------- ### initFilterBackend Source: https://fabricjs.com/api/functions/initfilterbackend Verifies if it is possible to initialize webgl or fallback on a canvas2d filtering backend. ```APIDOC ## initFilterBackend ### Description Verifies if it is possible to initialize webgl or fallback on a canvas2d filtering backend. ### Returns - **FilterBackend** - The initialized filtering backend instance. ``` -------------------------------- ### Constructor new Grayscale() Source: https://fabricjs.com/api/fabric/namespaces/filters/classes/grayscale Initializes a new instance of the Grayscale filter. ```APIDOC ## Constructor new Grayscale() ### Description Creates a new Grayscale filter instance. ### Parameters #### Path Parameters - **options** (object) - Optional - Partial GrayscaleOwnProps and Record configuration object. ### Request Example ```javascript const filter = new Grayscale({ mode: 'average' }); ``` ``` -------------------------------- ### getAlpha() Source: https://fabricjs.com/api/classes/color Gets the alpha channel value of the color. ```APIDIDOC ## getAlpha() ### Description Gets the alpha channel value of the color. ### Returns `number` - Alpha value between 0 and 1. ``` -------------------------------- ### Triangle Constructor Source: https://fabricjs.com/api/classes/triangle Initializes a new Triangle instance. It accepts an optional options object to configure the triangle's properties. ```APIDOC ## new Triangle(options?) ### Description Initializes a new Triangle instance. It accepts an optional options object to configure the triangle's properties. ### Parameters #### options? (Props) Optional. Options object to configure the triangle. ### Returns `Triangle` - A new Triangle instance. ### Overrides `FabricObject.constructor` ``` -------------------------------- ### backgroundColor Property Source: https://fabricjs.com/api/classes/basefabricobject Sets or gets the background color of an object. ```APIDOC ## backgroundColor ### Description Background color of an object. takes css colors https://www.w3.org/TR/css-color-3/ ### Type `string` ### Implementation of `ObjectProps.backgroundColor` ``` -------------------------------- ### get() Source: https://fabricjs.com/api/classes/triangle Retrieves the value of a specified property from the Triangle object. ```APIDOC ## get() ### Description Basic getter for object properties. ### Method `get(property: string): any` ### Parameters #### Path Parameters * **property** (string) - Required - Property name to retrieve. ### Returns #### Success Response (200) * **any** - The value of the requested property. ``` -------------------------------- ### createProgram() Source: https://fabricjs.com/api/fabric/namespaces/filters/classes/invert Compiles a shader program for a filter using the provided WebGL context and source strings. ```APIDOC ## createProgram() ### Description Compile this filter’s shader program. ### Parameters #### gl - **gl** (WebGLRenderingContext) - Required - The GL canvas context to use for shader compilation. #### fragmentSource - **fragmentSource** (string) - Required - fragmentShader source for compilation. #### vertexSource - **vertexSource** (string) - Required - vertexShader source for compilation. ### Response #### Success Response - **attributeLocations** (TWebGLAttributeLocationMap) - Map of attribute locations. - **program** (WebGLProgram) - The compiled shader program. - **uniformLocations** (TWebGLUniformLocationMap) - Map of uniform locations. ``` -------------------------------- ### getY() Source: https://fabricjs.com/api/classes/polygon Gets the y-coordinate of the object in the canvas coordinate plane. ```APIDOC ## getY() ### Description Gets the y-coordinate of the object in the canvas coordinate plane, relative to its originY property. ### Method GET ### Endpoint `/polygon/getY` ### Returns #### Success Response (200) - **y** (number) - The y-coordinate. ``` -------------------------------- ### getX() Source: https://fabricjs.com/api/classes/polygon Gets the x-coordinate of the object in the canvas coordinate plane. ```APIDOC ## getX() ### Description Gets the x-coordinate of the object in the canvas coordinate plane, relative to its originX property. ### Method GET ### Endpoint `/polygon/getX` ### Returns #### Success Response (200) - **x** (number) - The x-coordinate. ``` -------------------------------- ### get() Source: https://fabricjs.com/api/classes/fabrictext Basic getter for object properties. Inherited from StyledText. ```APIDOC ## get(property) ### Description Basic getter. ### Method `get`(`property`: `string`): `any` ### Parameters #### Property Parameter * **property** (`string`) - Required - Property name ### Returns `any` - value of a property ### Inherited from `StyledText.get` ``` -------------------------------- ### onDragStart() Source: https://fabricjs.com/api/classes/fabricobject Callback function executed when a drag session starts. Override to customize drag behavior. Inherited from InteractiveFabricObject. ```APIDOC ## onDragStart() ### Description Callback function executed when a drag session starts. Override to customize drag behavior. ### Method `onDragStart`(`_e`: `DragEvent`): `boolean` ### Parameters #### _e - **_e** (`DragEvent`) ### Returns `boolean` - Description: true to handle the drag event ### Inherited from `InteractiveFabricObject` ``` -------------------------------- ### get() Source: https://fabricjs.com/api/classes/group Retrieves the value of a specified property from the group object. ```APIDOC ## get(property) ### Description Basic getter. ### Method get ### Parameters #### Path Parameters - **property** (string) - Required - Property name ### Returns #### Success Response (any) - any - value of a property ``` -------------------------------- ### get Source: https://fabricjs.com/api/classes/canvas Basic getter for retrieving a property's value. ```APIDOC ## get(property) ### Description Basic getter for retrieving a property's value. ### Method (Inherited from SelectableCanvas.get) ### Parameters #### Path Parameters * **property** (string) - Required - Property name ### Returns #### Success Response (200) * **any** - value of a property ``` -------------------------------- ### createProgram() Source: https://fabricjs.com/api/fabric/namespaces/filters/classes/huerotation Compiles the filter's shader program using provided fragment and vertex sources. Returns an object containing program, attribute locations, and uniform locations. ```APIDOC ## createProgram() ### Description Compile this filter’s shader program. ### Method `object` ### Endpoint N/A (Method within a class) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) - **attributeLocations** (TWebGLAttributeLocationMap) - - **program** (WebGLProgram) - - **uniformLocations** (TWebGLUniformLocationMap) - #### Response Example ```json { "program": "WebGLProgram", "attributeLocations": "TWebGLAttributeLocationMap", "uniformLocations": "TWebGLUniformLocationMap" } ``` ``` -------------------------------- ### createProgram() Source: https://fabricjs.com/api/fabric/namespaces/filters/classes/brightness Compiles a filter's shader program. ```APIDOC ## createProgram() ### Description Compile this filter’s shader program. ### Parameters #### Parameters - **gl** (WebGLRenderingContext) - Required - The GL canvas context to use for shader compilation. - **fragmentSource** (string) - Required - fragmentShader source for compilation. - **vertexSource** (string) - Required - vertexShader source for compilation. ### Returns - **object** - Returns an object containing attributeLocations, program, and uniformLocations. ``` -------------------------------- ### get() Source: https://fabricjs.com/api/classes/ellipse Retrieves the value of a specified property from the ellipse object. ```APIDOC ## get() ### Description Basic getter for ellipse properties. ### Method N/A (Method Signature) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Parameters #### property `string` - Property name ### Request Example N/A ### Response #### Success Response (200) - **value** (any) - value of a property #### Response Example N/A ``` -------------------------------- ### erasing:start Event Source: https://fabricjs.com/api/interfaces/canvasevents Triggered when an erasing operation on the canvas begins. ```APIDOC ## erasing:start ### Description This event is triggered at the beginning of an erasing operation on the canvas. It does not carry any specific event data beyond the initiation of the action. ``` -------------------------------- ### IText Constructor Source: https://fabricjs.com/api/classes/itext Initializes a new IText instance. It takes the initial text string and an optional options object for configuration. ```APIDOC ## new IText(text, options?) ### Description Initializes a new IText instance with the provided text and configuration options. ### Parameters #### text - **text** (string) - The initial text content for the IText object. #### options? - **options** (Props) - An optional object to configure the IText instance. Props extends TOptions. ### Returns - `IText` - A new instance of the IText class. ``` -------------------------------- ### fromObject(options) Source: https://fabricjs.com/api/classes/shadow Creates a Shadow instance from a given object of options. This is a static method. ```APIDOC ## fromObject(options) ### Description Creates a Shadow instance from a given object of options. This is a static method. ### Method > `static` **fromObject**(`options`): `Promise` ### Parameters #### options (`Partial>`) ### Returns `Promise` ### Defined in src/Shadow.ts:232 ``` -------------------------------- ### _setupCompositeOperation() Source: https://fabricjs.com/api/classes/interactivefabricobject Sets the canvas globalCompositeOperation for the object. Allows for custom composition operations specified by the globalCompositeOperation property. ```APIDOC ## _setupCompositeOperation() ### Description Sets canvas globalCompositeOperation for specific object custom composition operation for the particular object can be specified using globalCompositeOperation property. ### Method (Implicitly called) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) None #### Response Example None ### Inherited from `BaseFabricObject` ``` -------------------------------- ### angle Property Source: https://fabricjs.com/api/classes/basefabricobject Sets or gets the rotation angle of the object in degrees. ```APIDOC ## angle ### Description Angle of rotation of an object (in degrees) ### Type `TDegree` ### Default `0` ### Implementation of `ObjectProps.angle` ### Inherited from `FabricObject.angle` ``` -------------------------------- ### BaseFabricObject Constructor Source: https://fabricjs.com/api/classes/basefabricobject Initializes a new BaseFabricObject instance. It accepts an optional options object to configure the object's properties. ```APIDOC ## Constructor ### Description Initializes a new BaseFabricObject instance. ### Signature `new BaseFabricObject(options?: Props): FabricObject` ### Parameters #### options? (`Props`) - Description: Options object to configure the new object. ``` -------------------------------- ### GET /version Source: https://fabricjs.com/api/variables/version Retrieves the current version string of the Fabric.js library. ```APIDOC ## GET /version ### Description Returns the current version of the Fabric.js library as a string. ### Method GET ### Endpoint /version ### Response #### Success Response (200) - **version** (string) - The current version identifier of the library. ``` -------------------------------- ### FitContentLayout Methods Source: https://fabricjs.com/api/classes/fitcontentlayout Documentation for the methods available in the FitContentLayout class, including overridden and inherited methods. ```APIDOC ## Methods ### calcBoundingBox() > **calcBoundingBox**(`objects`, `context`): `undefined` | `LayoutStrategyResult` #### Description Override this method to customize layout. This method is inherited from `LayoutStrategy`. #### Parameters ##### objects - `FabricObject, SerializedObjectProps, ObjectEvents>[]` - The objects to calculate the bounding box for. ##### context - `StrictLayoutContext` - The layout context. #### Returns - `undefined` | `LayoutStrategyResult` - The calculated bounding box or undefined. #### Inherited from `LayoutStrategy.calcBoundingBox` ``` ```APIDOC ### calcLayoutResult() > **calcLayoutResult**(`context`, `objects`): `undefined` | `LayoutStrategyResult` #### Description Used by the `LayoutManager` to perform layout. If this method returns `undefined`, layout is skipped. This method is inherited from `LayoutStrategy`. #### Parameters ##### context - `StrictLayoutContext` - The layout context. ##### objects - `FabricObject, SerializedObjectProps, ObjectEvents>[]` - The objects to perform layout on. #### Returns - `undefined` | `LayoutStrategyResult` - The layout result or undefined to skip layout. #### Inherited from `LayoutStrategy.calcLayoutResult` ``` ```APIDOC ### getInitialSize() > **getInitialSize**(`context`, `result`): `Point` #### Description Calculates the initial size for the layout. This method is inherited from `LayoutStrategy`. #### Parameters ##### context - `StrictLayoutContext & CommonLayoutContext & object` - The layout context. ##### result - `Pick` - The current layout result. #### Returns - `Point` - The calculated initial size. #### Inherited from `LayoutStrategy.getInitialSize` ``` ```APIDOC ### shouldLayoutClipPath() > **shouldLayoutClipPath**(`__namedParameters`): `undefined` | `boolean` #### Description Determines if the layout should clip the path. This method is inherited from `LayoutStrategy`. #### Parameters ##### __namedParameters - `StrictLayoutContext` - The layout context. #### Returns - `undefined` | `boolean` - Whether to clip the path. #### Inherited from `LayoutStrategy.shouldLayoutClipPath` ``` ```APIDOC ### shouldPerformLayout() > **shouldPerformLayout**(`context`): `boolean` #### Description Determines if the layout should be performed. This method is overridden to always perform layout. #### Parameters ##### context - `StrictLayoutContext` - The layout context. #### Returns - `boolean` - Whether to perform layout. #### Overrides `LayoutStrategy.shouldPerformLayout` ``` -------------------------------- ### getXY() Source: https://fabricjs.com/api/classes/polygon Gets the x and y coordinates of the object in the canvas coordinate plane. ```APIDOC ## getXY() ### Description Gets the x and y coordinates of the object in the canvas coordinate plane, relative to its originX and originY properties. ### Method GET ### Endpoint `/polygon/getXY` ### Returns #### Success Response (200) - **point** (Point) - An object with `x` and `y` properties representing the coordinates. ``` -------------------------------- ### Line Constructor Source: https://fabricjs.com/api/classes/line Initializes a new instance of the Line class. It accepts an optional array of points and an options object for configuration. ```APIDOC ## new Line(points?, options?) ### Description Constructor for the Line class. ### Parameters #### points? (`Array<[number, number, number, number]>`) Optional. An array of four numbers representing the start and end points of the line [x1, y1, x2, y2]. #### options? (`Partial`) Optional. An object containing options to configure the line, extending `FabricObjectProps`. ### Returns `Line` - The newly created Line instance. ### Overrides `FabricObject.constructor` ``` -------------------------------- ### get() Source: https://fabricjs.com/api/classes/interactivefabricobject Basic getter for object properties. This method is inherited from BaseFabricObject. ```APIDOC ## get(property) ### Description Basic getter for object properties. This method is inherited from BaseFabricObject. ### Method (Inherited from BaseFabricObject) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters * **property** (string) - Required - Property name ### Returns `any` - value of a property ``` -------------------------------- ### Pattern Constructor Source: https://fabricjs.com/api/classes/pattern Initializes a new Pattern instance. Options can be provided to configure the pattern's appearance and behavior. ```APIDOC ## new Pattern(options?) ### Description Constructor for the Pattern class. ### Parameters #### options? (`PatternOptions`) - Optional: Yes - Description: Options object to configure the pattern. ``` -------------------------------- ### getCanvasRetinaScaling() Source: https://fabricjs.com/api/classes/circle Gets the retina scaling factor of the canvas associated with the object. ```APIDOC ## getCanvasRetinaScaling() ### Description Gets the canvas retina scaling factor. ### Method (Implicitly a method of the Circle object) ### Returns `number` ### Inherited from `FabricObject` ``` -------------------------------- ### contextContainer Source: https://fabricjs.com/api/classes/canvas Gets the 2D rendering context for the main canvas element. ```APIDOC ## contextContainer ### Description Gets the 2D rendering context for the main canvas element. ### Get Signature `get contextContainer(): CanvasRenderingContext2D` ### Returns `CanvasRenderingContext2D` ### Defined in src/canvas/StaticCanvas.ts:144 ``` -------------------------------- ### createProgram() Source: https://fabricjs.com/api/fabric/namespaces/filters/classes/colormatrix Compiles the filter's shader program using the provided WebGL context. ```APIDOC ## createProgram() ### Description Compile this filter’s shader program. ### Parameters #### Path Parameters - **gl** (WebGLRenderingContext) - Required - The GL canvas context to use for shader compilation. - **fragmentSource** (string) - Required - fragmentShader source for compilation. - **vertexSource** (string) - Required - vertexShader source for compilation. ### Returns - **object** - Returns an object containing attributeLocations, program, and uniformLocations. ``` -------------------------------- ### onDragStart() Source: https://fabricjs.com/api/classes/ellipse Override to customize Drag behavior. Fired once a drag session has started. Returns true to handle the drag event. ```APIDOC ## onDragStart(_e) ### Description Callback function fired once a drag session has started. Override to customize drag behavior. ### Method `onDragStart` ### Parameters #### _e - **_e** (DragEvent) - Required ### Returns `boolean` - true to handle the drag event ``` -------------------------------- ### createProgram() Source: https://fabricjs.com/api/fabric/namespaces/filters/classes/pixelate Compiles a shader program for a filter using the provided WebGL context and source code. ```APIDOC ## createProgram() ### Description Compile this filter’s shader program. ### Parameters #### gl (WebGLRenderingContext) - The GL canvas context to use for shader compilation. #### fragmentSource (string) - fragmentShader source for compilation #### vertexSource (string) - vertexShader source for compilation ### Response #### Success Response (200) - **attributeLocations** (TWebGLAttributeLocationMap) - **program** (WebGLProgram) - **uniformLocations** (TWebGLUniformLocationMap) ``` -------------------------------- ### _setFillStyles(ctx, style) Source: https://fabricjs.com/api/classes/itext Prepares the canvas for a fill style. The fill style needs to be provided as defined. ```APIDOC ## _setFillStyles(ctx, style) ### Description Prepares the canvas for a fill style. The fill style needs to be provided as defined. ### Method (Implicitly a method of the IText class) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters #### ctx `CanvasRenderingContext2D` - The canvas rendering context. #### style `Pick` - The fill style properties. ### Returns #### Success Response - **offsetX** (number) - The X offset for the fill. - **offsetY** (number) - The Y offset for the fill. ### Response Example ```json { "offsetX": 10, "offsetY": 5 } ``` ### Inherited from `ITextClickBehavior._setFillStyles` ``` -------------------------------- ### getElement() Source: https://fabricjs.com/api/classes/staticcanvas Gets the underlying HTML canvas element associated with this StaticCanvas instance. ```APIDOC ## getElement() ### Description Returns the element corresponding to this instance. ### Method `getElement()` ### Returns `HTMLCanvasElement` - The HTML canvas element. ``` -------------------------------- ### createProgram() Source: https://fabricjs.com/api/fabric/namespaces/filters/classes/blendimage Compiles a shader program for a filter. ```APIDOC ## createProgram() ### Description Compile this filter’s shader program. ### Parameters #### Path Parameters - **gl** (WebGLRenderingContext) - Required - The GL canvas context to use for shader compilation. - **fragmentSource** (string) - Required - fragmentShader source for compilation. - **vertexSource** (string) - Required - vertexShader source for compilation. ### Returns - **attributeLocations** (TWebGLAttributeLocationMap) - **program** (WebGLProgram) - **uniformLocations** (TWebGLUniformLocationMap) ``` -------------------------------- ### selectionStart Source: https://fabricjs.com/api/classes/itext Indicates the index where the text selection begins. If no text is selected, it represents the cursor's position. ```APIDOC ## selectionStart ### Description Index where text selection starts (or where cursor is when there is no selection). ### Type number ### Defined in src/shapes/IText/IText.ts:134 ``` -------------------------------- ### get() Source: https://fabricjs.com/api/classes/rect Retrieves the value of a specified property from the object. This is a basic getter method. ```APIDOC ## get() ### Description Basic getter to retrieve the value of a property. ### Method GET ### Endpoint `/rect/{property}` ### Parameters #### Path Parameters - **property** (string) - Required - Property name to retrieve. ### Returns #### Success Response (200) - **value** (any) - The value of the requested property. ### Response Example ```json { "value": "somePropertyValue" } ``` ``` -------------------------------- ### WebGLFilterBackend Constructor Source: https://fabricjs.com/api/classes/webglfilterbackend Initializes a new instance of the WebGLFilterBackend class. It can optionally accept named parameters, including tileSize. ```APIDOC ## Constructor WebGLFilterBackend ### Description Initializes a new instance of the WebGLFilterBackend class. ### Method `new WebGLFilterBackend( __namedParameters )` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters #### `__namedParameters` (object) - Optional - **tileSize** (number) - Optional - The size of the texture tiles to use. Defaults to `config.textureSize`. ### Request Example ```json { "tileSize": 512 } ``` ### Response #### Success Response (200) `WebGLFilterBackend` - An instance of the WebGLFilterBackend class. ### Response Example ```json { "instance": "WebGLFilterBackend" } ``` ``` -------------------------------- ### get() Source: https://fabricjs.com/api/classes/itext Retrieves the value of a specified property from the object. This is a basic getter method. ```APIDOC ## get() [get] ### Description Basic getter. ### Method N/A (Method Signature) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Parameters #### property `string` - Property name to retrieve. ### Request Example N/A ### Response #### Success Response (200) Returns the value of the specified property. #### Response Example `any` ``` -------------------------------- ### get() Source: https://fabricjs.com/api/classes/path Retrieves the value of a specified property from the object. This is a basic getter method. ```APIDOC ## get() ### Description Retrieves the value of a specified property from the object. ### Method get ### Parameters #### Path Parameters - **property** (string) - Required - Property name ### Returns #### Success Response - **value** (any) - value of a property ```