I'm using the following code
var canvas = document.createElement("canvas");
canvas.width = 55;
canvas.height = 20;
var ctx = canvas.getContext("2d");
ctx.fillStyle = "red";
ctx.fillRect(0, 0, 100, 100);
var img = document.createElement("img");
img.src = canvas.toDataURL("image/png");
document.body.appendChild(img);
It generates a red 55x20 px rectangle. But I would like to put some text inside this one.
I've tried fillText();
but no results.
Any help?