javascript - How to Change text on Canvas prediodically -


how can draw canvas image , text text updated new values periodically. problem face new text writing on old text without clearing it.

<canvas id="product1" width="184" height="239"/> var img = new image(); img.onload = function () { context.drawimage(img, 0, 0, img.width,img.height,0, 0, 184, 239); context.font = "20pt calibri"; context.textalign="center";  context.filltext("product 1",150,120);   }; img.src = "https://image.ibb.co/gwnaoa/keg.jpg";   setinterval(function() {             var context = document.getelementbyid('product1').getcontext("2d").filltext(math.random(),150,120);           }, 2000); 

you have clear canvas, redraw image , draw new text.

or if know place of text, clear rect text , draw new text.

use clearrect(x,y,width,height)

canvas paper have magic pencil can write upon have drawn. can't select particular object line, text, rect, image or whatever have drawn. can clear , write.


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -