Skip to content

Instantly share code, notes, and snippets.

@ingeit
Created July 28, 2017 14:51
Show Gist options
  • Save ingeit/3f09514f897f6e9d31daac9c5df9eea6 to your computer and use it in GitHub Desktop.
Save ingeit/3f09514f897f6e9d31daac9c5df9eea6 to your computer and use it in GitHub Desktop.
usar canvas typescript Raw
import { ViewChild } from '@angular/core';
@ViewChild('myCanvas') canvas: any;
canvasElement: any;
ctx:any;
ngAfterViewInit(){
this.canvasElement = this.canvas.nativeElement;
this.ctx = this.canvasElement.getContext('2d');
}
otraFuncion(){
// ejemplo de trabajo con canvas
this.ctx.clearRect(0,0,this.canvasElement.width,this.canvasElement.height);
this.ctx.drawImage(this.imagenHTML, 0, 0);
this.ctx.fillStyle = "blue";
this.ctx.fillText('kevin',200,120);
this.ctx.fillText('34159181',200,220);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment