Skip to main content

Context

new Konva.Context(config)

Konva wrapper around native 2d canvas context. It has almost the same API of 2d context with some additional functions. With core Konva shapes you don't need to use this object. But you will use it if you want to create a custom shape or a custom hit regions. For full information about each 2d context API use MDN documentation

Own Methods

fillShape(shape)

fill shape

Parameters:

  • shape (Konva.Shape)

strokeShape(shape)

stroke shape

Parameters:

  • shape (Konva.Shape)

fillStrokeShape(shape)

fill then stroke

Parameters:

  • shape (Konva.Shape)

reset()

reset canvas context transform

getCanvas()

get canvas wrapper

Returns: Konva.Canvas

clear(bounds)

clear canvas

Parameters:

  • bounds (Object) (optional)
  • bounds.x (Number) (optional)
  • bounds.y (Number) (optional)
  • bounds.width (Number) (optional)
  • bounds.height (Number) (optional)

arc()

arc function.

arcTo()

arcTo function.

beginPath()

beginPath function.

bezierCurveTo()

bezierCurveTo function.

clearRect()

clearRect function.

closePath()

closePath function.

createImageData()

createImageData function.

createLinearGradient()

createLinearGradient function.

createPattern()

createPattern function.

createRadialGradient()

createRadialGradient function.

drawImage()

drawImage function.

ellipse()

ellipse function.

isPointInPath()

isPointInPath function.

fillRect()

fillRect function.

strokeRect()

strokeRect function.

fillText()

fillText function.

measureText()

measureText function.

getImageData()

getImageData function.

lineTo()

lineTo function.

moveTo()

moveTo function.

rect()

rect function.

roundRect()

roundRect function.

putImageData()

putImageData function.

quadraticCurveTo()

quadraticCurveTo function.

restore()

restore function.

rotate()

rotate function.

save()

save function.

scale()

scale function.

setLineDash()

setLineDash function.

getLineDash()

getLineDash function.

setTransform()

setTransform function.

stroke()

stroke function.

strokeText()

strokeText function.

transform()

transform function.

translate()

translate function.