canvas学习(一)
2014-02-04 22:13
786 查看
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:性能测试工具。
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:性能测试工具。
相关文章推荐
- !function($){}(window.jQuery)
- 浙江大学ACM俱乐部 1020:电梯升降
- centos安装多个nginx之后出现的问题及解决方案
- 朝鲜推出"红星OS" 疑似全盘抄袭Mac OS
- yum服务器的安装及配置
- 浙江大学ACM俱乐部 1019:石头剪子布
- hdu1114(完全背包+恰好装满)
- ntp服务器安装及配置
- 改变脚本运行的路径
- linux下oracle设置开机自启动实现方法
- Linux下常用命令
- perl hash 按value/按keys 排序(多种方法)
- 浙江大学ACM俱乐部 1018:奇怪的信
- RTMP流媒体播放过程
- Windows从noinstall zip安装MySQL免安装版
- cocos2d-x 2.2 在WINDOWS中如何创建项目
- 浙江大学ACM俱乐部 1017:期末成绩
- Android模拟器DPAD not enabled in avd
- thttpd安装与调试
- Cutting a Rod