canvas-a13prototype.html
生活随笔
收集整理的這篇文章主要介紹了
canvas-a13prototype.html
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><title>擴(kuò)展方法</title>
</head>
<body><canvas id="canvas" style="margin:0 auto;border:1px #ddd solid">The current browser does not support Canvas, can replace the browser a try!</canvas><script>var canvas = document.getElementById('canvas');// 新的API
CanvasRenderingContext2D.prototype.fillStar = function(r,R,x,y,rot){this.beginPath();for(var i=0;i<5;i++){this.lineTo(Math.cos( (18+i*72 -rot)/180*Math.PI )*R+x,-Math.sin( (18+i*72 -rot)/180*Math.PI )*R+y);this.lineTo(Math.cos( (54+i*72 -rot)/180*Math.PI )*r+x,-Math.sin( (54+i*72 -rot) /180*Math.PI )*r+y);
}this.closePath();this.fill();}window.onload = function(){canvas.width = 1024;canvas.height = 768;if(canvas.getContext('2d')){var context = canvas.getContext('2d');// begin
context.fillStyle = "#058";// 調(diào)用新的API
context.fillStar(150,300,400,400,0)}else{alert('當(dāng)前游覽器不支持Canvas,請(qǐng)更換游覽器后再試!');}}</script>
</body>
</html>
?
轉(zhuǎn)載于:https://www.cnblogs.com/cynthia-wuqian/p/4991199.html
總結(jié)
以上是生活随笔為你收集整理的canvas-a13prototype.html的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: MIT Scheme 使用 Edwin
- 下一篇: 常用安卓开发技巧汇总