最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - html5 canvas doesn't fill text at coordinates (0,0) - Stack Overflow

programmeradmin1浏览0评论

Why does the canvas not do anything for fillText(text, 0,0) but works for fillText(text, 10, 10)?

fillText(text, 0,0): /

fillText(text, 10, 10): /

Why does the canvas not 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/

Share Improve this question asked Jan 12, 2013 at 1:43 TheOneTheOne 11.2k21 gold badges85 silver badges122 bronze badges 1
  • What would you expect it to show? – Dennis Commented Jan 12, 2013 at 1:50
Add a comment  | 

1 Answer 1

Reset to default 33

The second argument is the Y coordinate for the baseline of the text (the default textBaseline is "alphabetic") , so the text is being drawn above the visible canvas element when you use 0.

jsFiddle.

You could use a different number or alternatively, change the textBaseline property to something suitable, such as "top".

ctx.textBaseline = "top";

jsFiddle.

发布评论

评论列表(0)

  1. 暂无评论