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';
Comments
Post a Comment