angular - Add text to image using typescript -


hi i'm new typescript want add text image, , image can downloaded text.

i know how javascript

<!doctype html> <html> <head> <meta charset="utf-8"> <title>image text</title> </head>  <body> <canvas id="mycanvas" width="578" height="400"></canvas> <script>   var canvas = document.getelementbyid('mycanvas');   var context = canvas.getcontext('2d');   var imageobj = new image();   imageobj.onload = function() {     context.drawimage(imageobj, 69, 50);     context.font = "20px calibri";  context.filltext("my text!", 100, 200);   };   imageobj.src =   'http://www.html5canvastutorials.com/demos/assets/darth-vader.jpg'; </script> </body>`` </html> 

can me that?

thanks.

your javascript code valid typescript code, need tell compiler canvas of type htmlcanvaselement:

var canvas = document.getelementbyid('mycanvas') htmlcanvaselement; var context = canvas.getcontext('2d'); var imageobj = new image(); imageobj.onload = function () {     context.drawimage(imageobj, 69, 50);     context.font = "20px calibri";     context.filltext("my text!", 100, 200); };  imageobj.src = 'http://www.html5canvastutorials.com/demos/assets/darth-vader.jpg'; 

(code in playground)


Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -