CanvasOptions
Defined in: src/canvas/CanvasOptions.ts:238
Extends
Section titled “Extends”StaticCanvasOptions
.CanvasTransformOptions
.CanvasSelectionOptions
.CanvasCursorOptions
.TargetFindOptions
.CanvasEventsOptions
Properties
Section titled “Properties”allowTouchScrolling
Section titled “allowTouchScrolling”allowTouchScrolling:
boolean
Defined in: src/canvas/StaticCanvasOptions.ts:163
Indicates whether the browser can be scrolled when using a touchscreen and dragging on the canvas It gives PRIORITY to DOM scrolling, it doesn’t make it always possible. If is true, when using a touch event on the canvas, the canvas will scroll if scroll is possible. If we are in drawing mode or if we are selecting an object the canvas preventDefault and so it won’t scroll
Default
Section titled “Default”
move to Canvas
Inherited from
Section titled “Inherited from”StaticCanvasOptions
.allowTouchScrolling
altActionKey
Section titled “altActionKey”altActionKey:
TOptionalModifierKey
Defined in: src/canvas/CanvasOptions.ts:67
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.
1.6.2
Default
Section titled “Default”
Inherited from
Section titled “Inherited from”CanvasTransformOptions.altActionKey
altSelectionKey
Section titled “altSelectionKey”altSelectionKey:
TOptionalModifierKey
Defined in: src/canvas/CanvasOptions.ts:102
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.
1.6.5
Default
Section titled “Default”
Inherited from
Section titled “Inherited from”CanvasSelectionOptions.altSelectionKey
backgroundColor
Section titled “backgroundColor”backgroundColor:
string
|TFiller
Defined in: src/canvas/StaticCanvasOptions.ts:20
Background color of canvas instance.
Default
Section titled “Default”
Inherited from
Section titled “Inherited from”StaticCanvasOptions
.backgroundColor
backgroundImage?
Section titled “backgroundImage?”
optional
backgroundImage:FabricObject
<Partial
<FabricObjectProps
>,SerializedObjectProps
,ObjectEvents
>
Defined in: src/canvas/StaticCanvasOptions.ts:30
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
Section titled “Default”
Inherited from
Section titled “Inherited from”StaticCanvasOptions
.backgroundImage
backgroundVpt
Section titled “backgroundVpt”backgroundVpt:
boolean
Defined in: src/canvas/StaticCanvasOptions.ts:13
if set to false background image is not affected by viewport transform
1.6.3
we should really find a different way to do this
Default
Section titled “Default”
Inherited from
Section titled “Inherited from”StaticCanvasOptions
.backgroundVpt
centeredKey
Section titled “centeredKey”centeredKey:
TOptionalModifierKey
Defined in: src/canvas/CanvasOptions.ts:56
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.
1.6.2
Default
Section titled “Default”
Inherited from
Section titled “Inherited from”CanvasTransformOptions.centeredKey
centeredRotation
Section titled “centeredRotation”centeredRotation:
boolean
Defined in: src/canvas/CanvasOptions.ts:45
When true, objects use center point as the origin of rotate transformation. Backwards incompatibility note: This property replaces “centerTransform” (Boolean).
1.3.4
Default
Section titled “Default”
Inherited from
Section titled “Inherited from”CanvasTransformOptions.centeredRotation
centeredScaling
Section titled “centeredScaling”centeredScaling:
boolean
Defined in: src/canvas/CanvasOptions.ts:36
When true, objects use center point as the origin of scale transformation. Backwards incompatibility note: This property replaces “centerTransform” (Boolean).
1.3.4
Default
Section titled “Default”
Inherited from
Section titled “Inherited from”CanvasTransformOptions.centeredScaling
clipPath?
Section titled “clipPath?”
optional
clipPath:FabricObject
<Partial
<FabricObjectProps
>,SerializedObjectProps
,ObjectEvents
>
Defined in: src/canvas/StaticCanvasOptions.ts:105
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
Inherited from
Section titled “Inherited from”containerClass
Section titled “containerClass”containerClass:
string
Defined in: src/canvas/CanvasOptions.ts:251
Default element class that’s given to wrapper (div) element of canvas
Default
Section titled “Default”
controlsAboveOverlay
Section titled “controlsAboveOverlay”controlsAboveOverlay:
boolean
Defined in: src/canvas/StaticCanvasOptions.ts:151
Indicates whether object controls (borders/controls) are rendered above overlay image
Default
Section titled “Default”
move to Canvas
Inherited from
Section titled “Inherited from”StaticCanvasOptions
.controlsAboveOverlay
defaultCursor
Section titled “defaultCursor”defaultCursor:
string
Defined in: src/canvas/CanvasOptions.ts:160
Default cursor value used for the entire canvas
Default
Section titled “Default”default
Inherited from
Section titled “Inherited from”CanvasCursorOptions.defaultCursor
enablePointerEvents
Section titled “enablePointerEvents”enablePointerEvents:
boolean
Defined in: src/canvas/CanvasOptions.ts:235
When the option is enabled, PointerEvent is used instead of TPointerEvent.
Default
Section titled “Default”
Inherited from
Section titled “Inherited from”CanvasEventsOptions.enablePointerEvents
enableRetinaScaling
Section titled “enableRetinaScaling”enableRetinaScaling:
boolean
Defined in: src/canvas/StaticCanvasOptions.ts:89
When true, canvas is scaled by devicePixelRatio for better rendering on retina screens
Default
Section titled “Default”
Inherited from
Section titled “Inherited from”StaticCanvasOptions
.enableRetinaScaling
fireMiddleClick
Section titled “fireMiddleClick”fireMiddleClick:
boolean
Defined in: src/canvas/CanvasOptions.ts:228
Indicates if the canvas can fire middle click events
1.7.8
Default
Section titled “Default”
Inherited from
Section titled “Inherited from”CanvasEventsOptions.fireMiddleClick
fireRightClick
Section titled “fireRightClick”fireRightClick:
boolean
Defined in: src/canvas/CanvasOptions.ts:220
Indicates if the canvas can fire right click events
1.6.5
Default
Section titled “Default”
Inherited from
Section titled “Inherited from”CanvasEventsOptions.fireRightClick
freeDrawingCursor
Section titled “freeDrawingCursor”freeDrawingCursor:
string
Defined in: src/canvas/CanvasOptions.ts:167
Cursor value used during free drawing
Default
Section titled “Default”crosshair
Inherited from
Section titled “Inherited from”CanvasCursorOptions.freeDrawingCursor
height
Section titled “height”height:
number
Defined in: src/canvas/StaticCanvasOptions.ts:142
Height in virtual/logical pixels of the canvas. The canvas can be taller than width if retina scaling is active
Inherited from
Section titled “Inherited from”hoverCursor
Section titled “hoverCursor”hoverCursor:
string
Defined in: src/canvas/CanvasOptions.ts:146
Default cursor value used when hovering over an object on canvas
Default
Section titled “Default”move
Inherited from
Section titled “Inherited from”CanvasCursorOptions.hoverCursor
imageSmoothingEnabled
Section titled “imageSmoothingEnabled”imageSmoothingEnabled:
boolean
Defined in: src/canvas/StaticCanvasOptions.ts:96
Indicates whether this canvas will use image smoothing, this is on by default in browsers
Default
Section titled “Default”
Inherited from
Section titled “Inherited from”StaticCanvasOptions
.imageSmoothingEnabled
includeDefaultValues
Section titled “includeDefaultValues”includeDefaultValues:
boolean
Defined in: src/canvas/StaticCanvasOptions.ts:115
Indicates whether toObject/toDatalessObject should include default values if set to false, takes precedence over the object value.
Default
Section titled “Default”
Inherited from
Section titled “Inherited from”StaticCanvasOptions
.includeDefaultValues
moveCursor
Section titled “moveCursor”moveCursor:
string
Defined in: src/canvas/CanvasOptions.ts:153
Default cursor value used when moving an object on canvas
Default
Section titled “Default”move
Inherited from
Section titled “Inherited from”CanvasCursorOptions.moveCursor
notAllowedCursor
Section titled “notAllowedCursor”notAllowedCursor:
string
Defined in: src/canvas/CanvasOptions.ts:175
Cursor value used for disabled elements ( corners with disabled action )
2.0.0
Default
Section titled “Default”not-allowed
Inherited from
Section titled “Inherited from”CanvasCursorOptions.notAllowedCursor
overlayColor
Section titled “overlayColor”overlayColor:
string
|TFiller
Defined in: src/canvas/StaticCanvasOptions.ts:47
Overlay color of canvas instance.
1.3.9
Default
Section titled “Default”
Inherited from
Section titled “Inherited from”StaticCanvasOptions
.overlayColor
overlayImage?
Section titled “overlayImage?”
optional
overlayImage:FabricObject
<Partial
<FabricObjectProps
>,SerializedObjectProps
,ObjectEvents
>
Defined in: src/canvas/StaticCanvasOptions.ts:57
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
Section titled “Default”
Inherited from
Section titled “Inherited from”StaticCanvasOptions
.overlayImage
overlayVpt
Section titled “overlayVpt”overlayVpt:
boolean
Defined in: src/canvas/StaticCanvasOptions.ts:39
if set to false overlay image is not affected by viewport transform
1.6.3
we should really find a different way to do this
Default
Section titled “Default”
Inherited from
Section titled “Inherited from”StaticCanvasOptions
.overlayVpt
perPixelTargetFind
Section titled “perPixelTargetFind”perPixelTargetFind:
boolean
Defined in: src/canvas/CanvasOptions.ts:184
When true, object detection happens on per-pixel basis rather than on per-bounding-box
Default
Section titled “Default”
Inherited from
Section titled “Inherited from”TargetFindOptions.perPixelTargetFind
preserveObjectStacking
Section titled “preserveObjectStacking”preserveObjectStacking:
boolean
Defined in: src/canvas/CanvasOptions.ts:259
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
Section titled “Default”
renderOnAddRemove
Section titled “renderOnAddRemove”renderOnAddRemove:
boolean
Defined in: src/canvas/StaticCanvasOptions.ts:71
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
Section titled “Default”
Inherited from
Section titled “Inherited from”StaticCanvasOptions
.renderOnAddRemove
selection
Section titled “selection”selection:
boolean
Defined in: src/canvas/CanvasOptions.ts:76
Indicates whether group selection should be enabled
Default
Section titled “Default”
Inherited from
Section titled “Inherited from”CanvasSelectionOptions.selection
selectionBorderColor
Section titled “selectionBorderColor”selectionBorderColor:
string
Defined in: src/canvas/CanvasOptions.ts:123
Color of the border of selection (usually slightly darker than color of selection itself)
Default
Section titled “Default”
Inherited from
Section titled “Inherited from”CanvasSelectionOptions.selectionBorderColor
selectionColor
Section titled “selectionColor”selectionColor:
string
Defined in: src/canvas/CanvasOptions.ts:109
Color of selection
Default
Section titled “Default”
Inherited from
Section titled “Inherited from”CanvasSelectionOptions.selectionColor
selectionDashArray
Section titled “selectionDashArray”selectionDashArray:
number
[]
Defined in: src/canvas/CanvasOptions.ts:116
Default dash array pattern If not empty the selection border is dashed
Inherited from
Section titled “Inherited from”CanvasSelectionOptions.selectionDashArray
selectionFullyContained
Section titled “selectionFullyContained”selectionFullyContained:
boolean
Defined in: src/canvas/CanvasOptions.ts:137
Select only shapes that are fully contained in the dragged selection rectangle.
Default
Section titled “Default”
Inherited from
Section titled “Inherited from”CanvasSelectionOptions.selectionFullyContained
selectionKey
Section titled “selectionKey”selectionKey:
TOptionalModifierKey
| ("altKey"
|"ctrlKey"
|"metaKey"
|"shiftKey"
)[]
Defined in: src/canvas/CanvasOptions.ts:88
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.
1.6.2
Default
Section titled “Default”
Inherited from
Section titled “Inherited from”CanvasSelectionOptions.selectionKey
selectionLineWidth
Section titled “selectionLineWidth”selectionLineWidth:
number
Defined in: src/canvas/CanvasOptions.ts:130
Width of a line used in object/group selection
Default
Section titled “Default”
Inherited from
Section titled “Inherited from”CanvasSelectionOptions.selectionLineWidth
skipOffscreen
Section titled “skipOffscreen”skipOffscreen:
boolean
Defined in: src/canvas/StaticCanvasOptions.ts:82
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
Section titled “Default”true
Inherited from
Section titled “Inherited from”StaticCanvasOptions
.skipOffscreen
skipTargetFind
Section titled “skipTargetFind”skipTargetFind:
boolean
Defined in: src/canvas/CanvasOptions.ts:202
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
Section titled “Default”
Inherited from
Section titled “Inherited from”TargetFindOptions.skipTargetFind
stopContextMenu
Section titled “stopContextMenu”stopContextMenu:
boolean
Defined in: src/canvas/CanvasOptions.ts:212
Indicates if the right click on canvas can output the context menu or not
1.6.5
Default
Section titled “Default”
Inherited from
Section titled “Inherited from”CanvasEventsOptions.stopContextMenu
svgViewportTransformation
Section titled “svgViewportTransformation”svgViewportTransformation:
boolean
Defined in: src/canvas/StaticCanvasOptions.ts:123
When true, getSvgTransform() will apply the StaticCanvas.viewportTransform to the SVG transformation. When true, a zoomed canvas will then produce zoomed SVG output.
Default
Section titled “Default”
Inherited from
Section titled “Inherited from”StaticCanvasOptions
.svgViewportTransformation
targetFindTolerance
Section titled “targetFindTolerance”targetFindTolerance:
number
Defined in: src/canvas/CanvasOptions.ts:191
Number of pixels around target pixel to tolerate (consider active) during object detection
Default
Section titled “Default”
Inherited from
Section titled “Inherited from”TargetFindOptions.targetFindTolerance
uniformScaling
Section titled “uniformScaling”uniformScaling:
boolean
Defined in: src/canvas/CanvasOptions.ts:13
When true, objects can be transformed by one side (unproportionately) when dragged on the corners that normally would not do that.
Default
Section titled “Default”
fabric 4.0 // changed name and default value
Inherited from
Section titled “Inherited from”CanvasTransformOptions.uniformScaling
uniScaleKey
Section titled “uniScaleKey”uniScaleKey:
TOptionalModifierKey
Defined in: src/canvas/CanvasOptions.ts:27
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.
1.6.2
Default
Section titled “Default”
Inherited from
Section titled “Inherited from”CanvasTransformOptions.uniScaleKey
viewportTransform
Section titled “viewportTransform”viewportTransform:
TMat2D
Defined in: src/canvas/StaticCanvasOptions.ts:174
The transformation (a Canvas 2D API transform matrix) which focuses the viewport
Examples
Section titled “Examples”canvas.viewportTransform = [1, 0, 0, 1, 0, 0];
canvas.viewportTransform = [0.7, 0, 0, 0.7, 50, 50];
Default
Section titled “Default”
Inherited from
Section titled “Inherited from”StaticCanvasOptions
.viewportTransform
width:
number
Defined in: src/canvas/StaticCanvasOptions.ts:135
Width in virtual/logical pixels of the canvas. The canvas can be larger than width if retina scaling is active