Canvas学习之基础一
来源:互联网 发布:linux安装telnet客户端 编辑:程序博客网 时间:2024/05/22 12:11
绘制直线、图形
this.test1 = document.getElementById('test1');this.test1.width = 1024; // 必须如此设置宽高this.test1.height = 900;let ctx1;if (this.test1.getContext('2d')) { ctx1 = this.test1.getContext('2d'); // 获取上下文} else { alert('不支持canvas')}ctx1.beginPath(); // 清除之前的路径ctx1.moveTo(100,200); // 起始点ctx1.lineTo(200,300); // 移动端点ctx1.lineTo(200,200); // 移动端点ctx1.fillStyle='red'; // 填充样式ctx1.fill(); // 执行填充ctx1.pathClose(); // 使路径封闭ctx1.strokeStyle='black' // 线条样式ctx1.strokeWidth=3; // 线条宽度ctx1.stroke(); // 执行画线
圆弧的绘制
this.test2 = document.getElementById('test2');this.test2.width = 1024; // 必须如此设置宽高this.test2.height = 900;let ctx2;if (this.test2.getContext('2d')) { ctx2 = this.test2.getContext('2d'); // 获取上下文} else { alert('不支持canvas')}//ctx2.fillStyle = 'orange';for (let i=1; i<= 10; i++) { ctx2.beginPath(); ctx2.arc(50+100*(i-1), 500, 30, 0, 0.2*i*Math.PI, true); ctx2.closePath(); ctx2.stroke();// ctx2.fill();}ctx2.fillStyle = 'orange';for (let i=1; i<= 10; i++) { ctx2.beginPath(); ctx2.arc(50+100*(i-1), 700, 30, 0, 0.2*i*Math.PI, true);// ctx2.closePath(); ctx2.stroke(); ctx2.fill();// 不管有没有pathClose,执行fill则封闭}
阅读全文
0 0
- Canvas学习之基础一
- canvas 一基础学习
- canvas学习之路(一)基础绘图功能解析
- canvas学习之路(一)基础绘图功能解析
- HTML5基础之canvas绘图(一)
- canvas学习一之canvas的基本使用
- HTML5 Canvas 基础 一
- Canvas基础(一)
- canvas基础知识点(一)
- canvas绘图基础(一)
- HTML5 学习(一 CANVAS 的基础知识点)
- canvas基础学习
- HTML之Canvas基础
- Canvas读书笔记之基础
- HTML5之canvas基础
- css3之canvas 基础
- JavaScript基础之Canvas
- Canvas学习笔记一
- 数据结构-链表的基本操作
- hdu2662
- Mac 怎么更改音频输出设备
- 【JZOJ 5163】PS的烦恼
- 解密回声消除技术之一(理论篇)
- Canvas学习之基础一
- css基础
- BottomBarLayout——方便快捷地实现底部导航栏
- TCP/IP协议
- word图片居中, 实际没效果解决、行间距无效果
- 更新Android SDK tool 到4.4w.2版本时,遇到Failed to rename directory
- Java web入门项目
- Linux中SVN的使用方法
- javascript文本节点操作方法你知道吗?