I'm filling canvas with some dynamic texts in ArrayList
. And I set the height as length
of ArrayList
like ArrayList.length * 20
or something like that.
HTML:
<canvas id="myCanvas" width="272px" style="border: 1px solid black"></canvas>
JS :
var canvas = document.getElementById("myCanvas");
var context = canvas.getContext("2d");
var myheight = 10;
for(var i = 0; mylist.length > i; i++){
context.fillText("my text", 10, myheight);
myheight += 10;
}
loop
works fine, texts are filled.. and I'm trying to calculate the canvas.height
after the loop
.
When I set canvas.height = myheight
and all filled texts are gone.. canvas
gone blank.
How can I set height
after canvas
filled by texts dynamically?
Help me.. Thank you.. And sorry for bad English..
Aucun commentaire:
Enregistrer un commentaire