`
txf2004
  • 浏览: 6873053 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

让人喜悦的HTML Canvas 2D Context

 
阅读更多

W3C HTML 工作组公布了HTML 5工作草案的10项更新,其中

HTML Canvas的2D元素 HTML Canvas 2D Context

草案里新增了绘制文字的接口,这是非常值得期待的功能,canvas可以图文并茂了,在游戏、图表都是常用的情景

10 Drawing text to the canvas

context . fillText(text, x, y [, maxWidth ] )
context . strokeText(text, x, y [, maxWidth ] )

Fills or strokes (respectively) the given text at the given position. If a maximum width is provided, the text will be scaled to fit that width if necessary.

metrics = context . measureText(text)

Returns a TextMetrics object with the metrics of the given text in the current font.

metrics . width

Returns the advance width of the text that was passed to the measureText() method.

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics