canvas学习(一)

1.在页面上任意定义一个元素,然后:
var canvas = document.getElementById('canvas'),
context = canvas.getContext('2d');
就此就可以将此元素定义为画布。
页面上的元素:
<canvas id = 'canvas' width = '600' height = '300'>
Canvas not supported
</canvas>
要这样写。
context.font(字体设置)
context.strokeStyle (颜色)
context.strokeText (空心字体)
2.canvas的元素属性:
a.width及height,后面没有px.将与画布自动变化。
b.getContext():返回与此元素相关的绘图环境对象。
c.toDataURL(type,quality):type,默认为img;第二个数值表示图片显示质量。
d.toBlob(callback,type,args...):创建一个用于表示此canvas元素图像文件的blob.
3.canvasRedneringContext2D对象所包含的属性
canvas,fillstyle,font,globalAlpha,globalCompsiteOperation,lineCap,lineWidth,lineJoin,miterLimit
shadowBlur,shadowColor,shadowOffsetX,shadowOffsetY,strokeStyle,textAlign,textBaseline
4.canvas状态的保存与恢复:
a.save()与restore()
5.小技巧:以编程的方式来控制性能分析器
console.profile()及console.profileEnd()
6.性能分析器与时间轴工具
7.jsPerf:性能测试工具。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值