W3C HTML 工作组公布了HTML 5工作草案的10项更新,其中
HTML Canvas的2D元素 HTML Canvas 2D Context
草案里新增了绘制文字的接口,这是非常值得期待的功能,canvas可以图文并茂了,在游戏、图表都是常用的情景
10 Drawing text to the canvas
-
context .
-
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 .
-
Returns a
TextMetricsobject with the metrics of the given text in the current font.
metrics .
-
Returns the advance width of the text that was passed to the
measureText()method.
fillText(
text,
x,
y [,
maxWidth ] )
context .
strokeText(
text,
x,
y [,
maxWidth ] )
measureText(
text)
width
HTML5 Canvas绘制文字新特性
HTML5 Canvas新增了绘制文字的功能,通过context.fillText和context.strokeText方法可以在画布上填充或描边文本。measureText方法则可用于获取文本的尺寸信息。
406

被折叠的 条评论
为什么被折叠?



