Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Canvas

Canvas class

Contains canvas DOM element and its 2D Context

author

Lucas Fridez lucas.fridez@he-arc.ch

Hierarchy

Index

Constructors

constructor

  • new Canvas(idCanvas: string): Canvas
  • Construct a new Canvas

    author

    Lucas Fridez lucas.fridez@he-arc.ch

    Parameters

    • idCanvas: string

      id of concerned canvas

    Returns Canvas

Properties

Protected canvas

canvas: HTMLCanvasElement

Protected context

context: CanvasRenderingContext2D

Private dataMaxHeight

dataMaxHeight: number

Private dataMaxWidth

dataMaxWidth: number

Methods

adaptAppearance

  • adaptAppearance(image: HTMLImageElement): void
  • Adapt canvas' appearance (width/height) according to image

    author

    Lucas Fridez lucas.fridez@he-arc.ch

    Parameters

    • image: HTMLImageElement

      to keep aspect ratio and dimensions

    Returns void

clear

  • clear(): void
  • Clear context's canvas

    author

    Lucas Fridez lucas.fridez@he-arc.ch

    Returns void

getCanvas

  • getCanvas(): HTMLCanvasElement
  • author

    Lucas Fridez lucas.fridez@he-arc.ch

    Returns HTMLCanvasElement

    HTML Canvas element

getContext

  • getContext(): CanvasRenderingContext2D
  • author

    Lucas Fridez lucas.fridez@he-arc.ch

    Returns CanvasRenderingContext2D

    Context 2d of canvas

getScaledDimensions

  • getScaledDimensions(imgWidth: number, imgHeight: number): { height: number; ratio: number; width: number }
  • Get scaled dimensions of canvas

    author

    Lucas Fridez lucas.fridez@he-arc.ch

    Parameters

    • imgWidth: number

      width of image

    • imgHeight: number

      height of image

    Returns { height: number; ratio: number; width: number }

    aspect ratio object {ratio, width, height}

    • height: number
    • ratio: number
    • width: number

Generated using TypeDoc