Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface CanvasRenderingContext2D

The CanvasRenderingContext2D interface, part of the Canvas API, provides the 2D rendering context for the drawing surface of a element. It is used for drawing shapes, text, images, and other objects.

Hierarchy

Index

Properties

direction: CanvasDirection
fillStyle: string | CanvasGradient | CanvasPattern
filter: string
font: string
globalAlpha: number
globalCompositeOperation: string
imageSmoothingEnabled: boolean
imageSmoothingQuality: ImageSmoothingQuality
lineCap: CanvasLineCap
lineDashOffset: number
lineJoin: CanvasLineJoin
lineWidth: number
miterLimit: number
shadowBlur: number
shadowColor: string
shadowOffsetX: number
shadowOffsetY: number
strokeStyle: string | CanvasGradient | CanvasPattern
textAlign: CanvasTextAlign
textBaseline: CanvasTextBaseline

Methods

  • arc(x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise?: boolean): void
  • Parameters

    • x: number
    • y: number
    • radius: number
    • startAngle: number
    • endAngle: number
    • Optional anticlockwise: boolean

    Returns void

  • arcTo(x1: number, y1: number, x2: number, y2: number, radius: number): void
  • Parameters

    • x1: number
    • y1: number
    • x2: number
    • y2: number
    • radius: number

    Returns void

  • beginPath(): void
  • bezierCurveTo(cp1x: number, cp1y: number, cp2x: number, cp2y: number, x: number, y: number): void
  • Parameters

    • cp1x: number
    • cp1y: number
    • cp2x: number
    • cp2y: number
    • x: number
    • y: number

    Returns void

  • clearRect(x: number, y: number, w: number, h: number): void
  • Parameters

    • x: number
    • y: number
    • w: number
    • h: number

    Returns void

  • clip(fillRule?: "evenodd" | "nonzero"): void
  • clip(path: Path2D, fillRule?: "evenodd" | "nonzero"): void
  • Parameters

    • Optional fillRule: "evenodd" | "nonzero"

    Returns void

  • Parameters

    • path: Path2D
    • Optional fillRule: "evenodd" | "nonzero"

    Returns void

  • closePath(): void
  • Returns void

  • createLinearGradient(x0: number, y0: number, x1: number, y1: number): CanvasGradient
  • createRadialGradient(x0: number, y0: number, r0: number, x1: number, y1: number, r1: number): CanvasGradient
  • drawImage(image: CanvasImageSource, dx: number, dy: number): void
  • drawImage(image: CanvasImageSource, dx: number, dy: number, dw: number, dh: number): void
  • drawImage(image: CanvasImageSource, sx: number, sy: number, sw: number, sh: number, dx: number, dy: number, dw: number, dh: number): void
  • ellipse(x: number, y: number, radiusX: number, radiusY: number, rotation: number, startAngle: number, endAngle: number, anticlockwise?: boolean): void
  • Parameters

    • x: number
    • y: number
    • radiusX: number
    • radiusY: number
    • rotation: number
    • startAngle: number
    • endAngle: number
    • Optional anticlockwise: boolean

    Returns void

  • fill(fillRule?: "evenodd" | "nonzero"): void
  • fill(path: Path2D, fillRule?: "evenodd" | "nonzero"): void
  • Parameters

    • Optional fillRule: "evenodd" | "nonzero"

    Returns void

  • Parameters

    • path: Path2D
    • Optional fillRule: "evenodd" | "nonzero"

    Returns void

  • fillRect(x: number, y: number, w: number, h: number): void
  • Parameters

    • x: number
    • y: number
    • w: number
    • h: number

    Returns void

  • fillText(text: string, x: number, y: number, maxWidth?: number): void
  • Parameters

    • text: string
    • x: number
    • y: number
    • Optional maxWidth: number

    Returns void

  • getImageData(sx: number, sy: number, sw: number, sh: number): ImageData
  • getLineDash(): number[]
  • Returns number[]

  • isPointInPath(x: number, y: number, fillRule?: "evenodd" | "nonzero"): boolean
  • isPointInPath(path: Path2D, x: number, y: number, fillRule?: "evenodd" | "nonzero"): boolean
  • Parameters

    • x: number
    • y: number
    • Optional fillRule: "evenodd" | "nonzero"

    Returns boolean

  • Parameters

    • path: Path2D
    • x: number
    • y: number
    • Optional fillRule: "evenodd" | "nonzero"

    Returns boolean

  • isPointInStroke(x: number, y: number): boolean
  • isPointInStroke(path: Path2D, x: number, y: number): boolean
  • lineTo(x: number, y: number): void
  • Parameters

    • x: number
    • y: number

    Returns void

  • moveTo(x: number, y: number): void
  • Parameters

    • x: number
    • y: number

    Returns void

  • putImageData(imagedata: ImageData, dx: number, dy: number): void
  • putImageData(imagedata: ImageData, dx: number, dy: number, dirtyX: number, dirtyY: number, dirtyWidth: number, dirtyHeight: number): void
  • Parameters

    Returns void

  • Parameters

    • imagedata: ImageData
    • dx: number
    • dy: number
    • dirtyX: number
    • dirtyY: number
    • dirtyWidth: number
    • dirtyHeight: number

    Returns void

  • quadraticCurveTo(cpx: number, cpy: number, x: number, y: number): void
  • Parameters

    • cpx: number
    • cpy: number
    • x: number
    • y: number

    Returns void

  • rect(x: number, y: number, w: number, h: number): void
  • Parameters

    • x: number
    • y: number
    • w: number
    • h: number

    Returns void

  • resetTransform(): void
  • restore(): void
  • Returns void

  • rotate(angle: number): void
  • Parameters

    • angle: number

    Returns void

  • save(): void
  • Returns void

  • scale(x: number, y: number): void
  • Parameters

    • x: number
    • y: number

    Returns void

  • scrollPathIntoView(): void
  • scrollPathIntoView(path: Path2D): void
  • setLineDash(segments: number[]): void
  • setLineDash(segments: Iterable<number>): void
  • Parameters

    • segments: number[]

    Returns void

  • Parameters

    Returns void

  • setTransform(a: number, b: number, c: number, d: number, e: number, f: number): void
  • setTransform(transform?: DOMMatrix2DInit): void
  • stroke(): void
  • stroke(path: Path2D): void
  • Returns void

  • Parameters

    Returns void

  • strokeRect(x: number, y: number, w: number, h: number): void
  • Parameters

    • x: number
    • y: number
    • w: number
    • h: number

    Returns void

  • strokeText(text: string, x: number, y: number, maxWidth?: number): void
  • Parameters

    • text: string
    • x: number
    • y: number
    • Optional maxWidth: number

    Returns void

  • transform(a: number, b: number, c: number, d: number, e: number, f: number): void
  • Parameters

    • a: number
    • b: number
    • c: number
    • d: number
    • e: number
    • f: number

    Returns void

  • translate(x: number, y: number): void
  • Parameters

    • x: number
    • y: number

    Returns void

Generated using TypeDoc