html 5 画布的自学
2015-09-16 22:08
686 查看
<!DOCTYPE HTML> <html> <head> <title>my canvas learning</title> </head> <body> <canvas id="myCanvas"> Your browser does not support the canvas tag. </canvas> <script type="text/javascript"> //通过 id 获取文档对象 var canvas = document.getElementById('myCanvas'); //获取 上下文环境,用来操作 var ctx = canvas.getContext('2d'); //指定填充颜色 ctx.fillStyle = '#0065BD'; //填充矩形:(0,0)开始,宽度125像素,高度75像素 ctx.fillRect(0,0,125,75);//Method //开启画路径的过程 ctx.beginPath(); //设置线的宽度 ctx.lineWidth = "15"; //设置线的颜色 ctx.strokeStyle="white"; //用moveTo和lineTo描绘1 ctx.moveTo(0,0); ctx.lineTo(125,75); //用moveTo和lineTo描绘2 ctx.moveTo(125,0); ctx.lineTo(0,75); //开始渲染画笔 ctx.stroke(); </script> </body> </html>
相关文章推荐
- HTML5中在客户端验证文件上传的大小
- Canvas 在高清屏下绘制图片变模糊的解决方法
- 原生js结合html5制作小飞龙的简易跳球
- 三个不常见的 HTML5 实用新特性简介
- 低版本IE正常运行HTML5+CSS3网站的3种解决方案
- js+HTML5实现canvas多种颜色渐变效果的方法
- javascript+HTML5的Canvas实现Lab单车动画效果
- javascript+html5实现绘制圆环的方法
- HTML5实现微信拍摄上传照片功能
- jQuery+HTML5加入购物车代码分享
- 实现音乐播放器的代码(html5+css3+jquery)
- 2014 HTML5/CSS3热门动画特效TOP10
- jQuery+html5+css3实现圆角无刷新表单带输入验证功能代码
- HTML5使用DeviceOrientation实现摇一摇功能
- jquery+html5烂漫爱心表白动画代码分享
- spring+html5实现安全传输随机数字密码键盘
- html5在android中的使用问题及技巧解读
- 非html5实现js版弹球游戏示例代码
- html5 canvas js(数字时钟)实例代码