+ 3
Is it possible to place text over a rectangle in a canvas?
2 Réponses
+ 6
Yes there is! Assuming that you have a variable called ctx as the context of the canvas and a set fill and stroke, then do:
ctx.fillRect(0, 0, 50, 50);
ctx.fillText(text, 10, 10);
This will place a rectangle at (0, 0) and will end at (50, 50) and the text fill be placed at (10, 10). You can also use the font property to set the font of the text.
Hope that helps!
+ 2
Thank you very much! I'll try that now.