so i'm trying make canvas have different types of text on including colours. here have far.
<!doctype html> <html> <body> <canvas id="mycanvas" width="400" height="200" style=" border:1px solid #d3d3d3;"> browser not support html5 canvas tag.</canvas> <script> window.onload = function(){ var canvas = document.getelementbyid("mycanvas"); var context = canvas.getcontext("2d"); var imageobj = new image(); imageobj.onload = function(){ context.drawimage(imageobj, 0, 0); context.font = "40pt calibri"; context.filltext("my text!", 50, 100); }; imageobj.src = "assets/background2.png"; }; </script> </body> </html>
you need use fillstyle method each time want change font color:
context.fillstyle = 'red';
Comments
Post a Comment