标签:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Canvas</title> </head> <style type="text/css"> body{margin:20px auto; padding:0; width:800px; } 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‘); var objImg = new Image(); objImg.src = ‘lin.jpg‘; objImg.onload = function (){ cans.drawImage(objImg,0,0,800,600); } cans.beginPath(); cans.arc(400,300,200,0,Math.PI*2,1); cans.closePath(); cans.clip(); } function img_click(){ var can = $$(‘can‘); var cans = can.getContext(‘2d‘); cans.clearRect(0,0,800,600); } </script> <body onload="pageLoad();"> <canvas id="can" width="800px" height="600px" onclick="img_click(this);"></canvas> </body> </html>
标签:
原文地址:http://www.cnblogs.com/babysay123/p/4654030.html