码迷,mamicode.com
首页 > 其他好文 > 详细

canvas学习(三):文字渲染

时间:2017-11-20 19:12:33      阅读:132      评论:0      收藏:0      [点我收藏+]

标签:com   rip   asc   script   getc   绘制   ext   font   red   

一、绘制基本的文字:

var canvas = document.getElementById("myCanvas")
var ctx = canvas.getContext(‘2d‘)
			     
ctx.font = "bold 30px 微软雅黑"

ctx.fillText(‘canvas学习‘, 100 ,100)
ctx.fillStyle = "red"  //填充的文本

ctx.lineWidth = 1  
ctx.strokeStyle="blue"
ctx.strokeText(‘canvas学习‘,100,300)  //边框文本

注意:我们也可以用渐变色和图片填充文字的背景

技术分享图片

 

 

 

二:font属性

 

canvas学习(三):文字渲染

标签:com   rip   asc   script   getc   绘制   ext   font   red   

原文地址:http://www.cnblogs.com/momozjm/p/7867583.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!