toCanvasElement function

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

Converts imageSource to CanvasElement.

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

Implementation

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

  context.drawImage(imageSource, 0, 0);

  return canvas;
}