toCanvasElement function

HTMLCanvasElement toCanvasElement(
  1. CanvasImageSource imageSource,
  2. int width,
  3. int height
)

Converts imageSource to HTMLCanvasElement.

width Width of the image. height Height of the image.

Implementation

HTMLCanvasElement toCanvasElement(
    CanvasImageSource imageSource, int width, int height) {
  var canvas = HTMLCanvasElement()
    ..width = width
    ..height = height;
  var context = canvas.getContext('2d') as CanvasRenderingContext2D;

  context.drawImage(imageSource, 0, 0);

  return canvas;
}