实现canvas绘制圆形框效果不填充内部
分类:实例代码
canvas绘制圆形框效果不填充内部属于前端实例代码,有关更多实例代码大家可以查看。
本章节分享一段代码实例,它实现了绘制圆形框的效果。
代码实例如下:
<!DOCTYPE html> <html> <head> <meta charset=" utf-8"> <meta name="author" content="http://www.pipipi.net/" /> <title>前端教程网</title> </head> <style type="text/css"> canvas{ border:dashed 2px #CCC } </style> <script type="text/javascript"> function $$(id){ return document.getElementById(id); } function pageLoad(){ var can = $$('can'); var cans = can.getContext('2d'); cans.beginPath(); cans.arc(200,150,100,0,Math.PI*2,false); cans.closePath(); cans.lineWidth = 5; cans.strokeStyle = 'red'; cans.stroke(); } window.onload=function(){ pageLoad(); } </script> <body> <canvas id="can" width="400px" height="300px"></canvas> </body> </html>
canvas绘制圆形框效果不填充内部,这样的场景在实际项目中还是用的比较多的,关于canvas绘制圆形框效果不填充内部就介绍到这了。