Html5 canvas does not fill text in coordinates (0,0)

Why doesn't the canvas do anything for fillText(text, 0,0) but works for fillText(text, 10, 10) ?

fillText(text, 0,0): http://jsfiddle.net/kFhQm/4/

fillText(text, 10, 10): http://jsfiddle.net/kFhQm/5/

+6
source share
1 answer

The second argument is the Y coordinate for the text baseline (by default textBaseline is "alphabetic" ), so the text is used over the visible canvas when using 0 .

jsFiddle .

You can use a different number or, alternatively, change the textBaseline property to something suitable, for example, "top" .

 ctx.textBaseline = "top"; 

jsFiddle .

+13
source

All Articles