Canvas(1)之HelloWorld
来源:互联网 发布:淘宝内部优惠券秒杀 编辑:程序博客网 时间:2024/06/06 14:08
/* 1.要使用canvas必须先设置其width和height属性 2.接着获取绘制上下文,并指定能力,为2D还是3D 3.绘制方式有填充和描边两种方式,即 fillStyle 填充属性 fillRect() strokeStyle 描边属性 strokeRect() */ var drawing = document.getElementById('drawing'); if(drawing.getContext){ //获取绘图的上下文 var context = drawing.getContext('2d'); //绘制红色矩形 context.fillStyle = '#ff0000'; context.fillRect(10,10,50,50); //绘制半透明的矩形 context.fillStyle = 'rgba(0,0,255,0.5)'; context.fillRect(30,30,50,50); //在两个矩形重叠的地方清除一个小矩形, 即使这块矩形变成透明 context.clearRect(40,40,10,10); //获取图像的数据URI,参数为图像的MIME类型,默认为png格式 var imgURI = drawing.toDataURL('imge/png'); //显示对象 var image = document.createElement('img'); image.src = imgURI; document.body.appendChild(image); }
0 0
- Canvas(1)之HelloWorld
- (1)ExtJS之HelloWorld
- 1、Spring之HelloWorld
- (1) 学习SpringBoot 之HelloWorld
- (1) 学习SpringBoot 之HelloWorld
- html5之canvas基础1
- Canvas之 canvas.save()与canvas.restore()
- JAVA3D学习(1) JAVA3D之HelloWorld
- SCA 之Tuscany 1 ——helloworld
- chrom 插件学习之1 HelloWorld
- Dojo+MVC 之旅1 HelloWorld
- window8.1 metro应用开发 之helloworld
- Spring mvc3.1之HelloWorld(新手入门)
- Html5游戏之KiwiJs(1)-Helloworld
- RecyclerView的使用(1)之HelloWorld
- Spring(1)--初识Spring之HelloWorld
- SpringMVC系列(1)之经典helloworld实现
- Tkinter教程之Canvas篇(1)
- shell批量杀进程
- QT经验(一)
- 树
- php操作mysql
- 【WPF】Windows App 比例布局的实现
- Canvas(1)之HelloWorld
- jvm参数说明
- Android 手势(Gesture)——手势检测
- ERROR: In <declare-styleable> MenuView, unable to find attribute android:preserveIconSpacing
- 开发Chrome插件实现在Chrome中截取网页
- 基本代码管理规范
- 或许之前我没有好好的做一些总结。
- 手机拍照与相册获取
- 美团二面被打击,遇到一个最基础的问题:Activity的生命周期,回来一番恶补,总结如下