<!doctype html><html><head> <title>變幻線-by-@謝帥shawn</title> <meta charset='utf-8' /></head><body> <canvas height='560' width='1000' id='canvas'>您的瀏覽器不支持canvas!</canvas> <script> //全局變量 starx=Math.random()*canvas.width; stary=Math.random()*canvas.height; canvas=document.getElementById('canvas'); ctx=canvas.getContext('2d'); ctx.fillStyle='rgba(0,0,0,.08)'; ctx.lineWidth=5; ctx.lineJoin='round'; //int function int() { setInterval(render,30); } //render function render() { ctx.beginPath(); ctx.fillRect(0,0,canvas.width,canvas.height); ctx.moveTo(starx,stary); starx=Math.random()*canvas.width; stary=Math.random()*canvas.height; ctx.bezierCurveTo(Math.random()*canvas.width,Math.random()*canvas.height,Math.random()*canvas.width,Math.random()*canvas.height,starx,stary); var r=Math.round(Math.random()*255); var g=Math.round(Math.random()*255); var b=Math.round(Math.random()*255); ctx.strokeStyle='rgba('+r+','+g+','+b+',1)'; ctx.stroke(); } //onload=int window.onload=int; </script></body></html>
聯(lián)系客服