Interface CanvasOptions

Hierarchy

  • StaticCanvasOptions
  • CanvasTransformOptions
  • CanvasSelectionOptions
  • CanvasCursorOptions
  • TargetFindOptions
  • CanvasEventsOptions
    • CanvasOptions

Implemented by

Properties

allowTouchScrolling: boolean

Indicates whether the browser can be scrolled when using a touchscreen and dragging on the canvas

Default


Todo

move to Canvas

altActionKey: TOptionalModifierKey

Indicates which key enable alternate action on corner values: 'altKey', 'shiftKey', 'ctrlKey'. If null or 'none' or any other string that is not a modifier key feature is disabled feature disabled.

Since

1.6.2

Default


altSelectionKey: TOptionalModifierKey

Indicates which key enable alternative selection in case of target overlapping with active object values: 'altKey', 'shiftKey', 'ctrlKey'. For a series of reason that come from the general expectations on how things should work, this feature works only for preserveObjectStacking true. If null or 'none' or any other string that is not a modifier key feature is disabled.

Since

1.6.5

Default


backgroundColor: string | TFiller

Background color of canvas instance.

Default


Background image of canvas instance. since 2.4.0 image caching is active, please when putting an image as background, add to the canvas property a reference to the canvas it is on. Otherwise the image cannot detect the zoom vale. As an alternative you can disable image objectCaching

Default


backgroundVpt: boolean

if set to false background image is not affected by viewport transform

Since

1.6.3

Todo

we should really find a different way to do this

Default


Indicates which key enable centered Transform values: 'altKey', 'shiftKey', 'ctrlKey'. If null or 'none' or any other string that is not a modifier key feature is disabled feature disabled.

Since

1.6.2

Default


centeredRotation: boolean

When true, objects use center point as the origin of rotate transformation. Backwards incompatibility note: This property replaces "centerTransform" (Boolean).

Since

1.3.4

Default


centeredScaling: boolean

When true, objects use center point as the origin of scale transformation. Backwards incompatibility note: This property replaces "centerTransform" (Boolean).

Since

1.3.4

Default


a fabricObject that, without stroke define a clipping area with their shape. filled in black the clipPath object gets used when the canvas has rendered, and the context is placed in the top left corner of the canvas. clipPath will clip away controls, if you do not want this to happen use controlsAboveOverlay = true

containerClass: string

Default element class that's given to wrapper (div) element of canvas

Default


Deprecated

customize CanvasDOMManager instead or access elements directly

controlsAboveOverlay: boolean

Indicates whether object controls (borders/controls) are rendered above overlay image

Default


Todo

move to Canvas

defaultCursor: string

Default cursor value used for the entire canvas

Default

default
enablePointerEvents: boolean

When the option is enabled, PointerEvent is used instead of TPointerEvent.

Default


enableRetinaScaling: boolean

When true, canvas is scaled by devicePixelRatio for better rendering on retina screens

Default


fireMiddleClick: boolean

Indicates if the canvas can fire middle click events

Since

1.7.8

Default


fireRightClick: boolean

Indicates if the canvas can fire right click events

Since

1.6.5

Default


freeDrawingCursor: string

Cursor value used during free drawing

Default

crosshair
height: number

Height in virtual/logical pixels of the canvas. The canvas can be taller than width if retina scaling is active

hoverCursor: string

Default cursor value used when hovering over an object on canvas

Default

move
imageSmoothingEnabled: boolean

Indicates whether this canvas will use image smoothing, this is on by default in browsers

Default


includeDefaultValues: boolean

Indicates whether toObject/toDatalessObject should include default values if set to false, takes precedence over the object value.

Default


moveCursor: string

Default cursor value used when moving an object on canvas

Default

move
notAllowedCursor: string

Cursor value used for disabled elements ( corners with disabled action )

Since

2.0.0

Default

not-allowed
overlayColor: string | TFiller

Overlay color of canvas instance.

Since

1.3.9

Default


Overlay image of canvas instance. since 2.4.0 image caching is active, please when putting an image as overlay, add to the canvas property a reference to the canvas it is on. Otherwise the image cannot detect the zoom vale. As an alternative you can disable image objectCaching

Default


overlayVpt: boolean

if set to false overlay image is not affected by viewport transform

Since

1.6.3

Todo

we should really find a different way to do this

Default


perPixelTargetFind: boolean

When true, object detection happens on per-pixel basis rather than on per-bounding-box

Default


preserveObjectStacking: boolean

Indicates whether objects should remain in current stack position when selected. When false objects are brought to top and rendered as part of the selection group

Default


renderOnAddRemove: boolean

Indicates whether StaticCanvas#add, StaticCanvas#insertAt and StaticCanvas#remove, StaticCanvas#moveTo, StaticCanvas#clear and many more, should also re-render canvas. Disabling this option will not give a performance boost when adding/removing a lot of objects to/from canvas at once since the renders are queued and executed one per frame. Disabling is suggested anyway and managing the renders of the app manually is not a big effort ( canvas.requestRenderAll() ) Left default to true to do not break documentation and old app, fiddles.

Default


selection: boolean

Indicates whether group selection should be enabled

Default


selectionBorderColor: string

Color of the border of selection (usually slightly darker than color of selection itself)

Default


selectionColor: string

Color of selection

Default


selectionDashArray: number[]

Default dash array pattern If not empty the selection border is dashed

selectionFullyContained: boolean

Select only shapes that are fully contained in the dragged selection rectangle.

Default


selectionKey: TOptionalModifierKey | ("altKey" | "shiftKey" | "ctrlKey" | "metaKey")[]

Indicates which key or keys enable multiple click selection Pass value as a string or array of strings values: 'altKey', 'shiftKey', 'ctrlKey'. If null or empty or containing any other string that is not a modifier key feature is disabled.

Since

1.6.2

Default


selectionLineWidth: number

Width of a line used in object/group selection

Default


skipOffscreen: boolean

Based on vptCoords and object.aCoords, skip rendering of objects that are not included in current viewport. May greatly help in applications with crowded canvas and use of zoom/pan If One of the corner of the bounding box of the object is on the canvas the objects get rendered.

Default

true
skipTargetFind: boolean

When true, target detection is skipped. Target detection will return always undefined. click selection won't work anymore, events will fire with no targets. if something is selected before setting it to true, it will be deselected at the first click. area selection will still work. check the selection property too. if you deactivate both, you should look into staticCanvas.

Default


stopContextMenu: boolean

Indicates if the right click on canvas can output the context menu or not

Since

1.6.5

Default


svgViewportTransformation: boolean

When true, getSvgTransform() will apply the StaticCanvas.viewportTransform to the SVG transformation. When true, a zoomed canvas will then produce zoomed SVG output.

Default


targetFindTolerance: number

Number of pixels around target pixel to tolerate (consider active) during object detection

Default


Indicates which key switches uniform scaling. values: 'altKey', 'shiftKey', 'ctrlKey'. If null or 'none' or any other string that is not a modifier key feature is disabled. totally wrong named. this sounds like uniform scaling if Canvas.uniformScaling is true, pressing this will set it to false and viceversa.

Since

1.6.2

Default


uniformScaling: boolean

When true, objects can be transformed by one side (unproportionately) when dragged on the corners that normally would not do that.

Default


Since

fabric 4.0 // changed name and default value

viewportTransform: TMat2D

The transformation (a Canvas 2D API transform matrix) which focuses the viewport

Example

Default transform

canvas.viewportTransform = [1, 0, 0, 1, 0, 0];

Example

Scale by 70% and translate toward bottom-right by 50, without skewing

canvas.viewportTransform = [0.7, 0, 0, 0.7, 50, 50];

Default


width: number

Width in virtual/logical pixels of the canvas. The canvas can be larger than width if retina scaling is active

Generated using TypeDoc