canvas實現的鋸齒效果程式碼例項
本章節分享一段程式碼例項,它實現了邊框內部鋸齒效果,有興趣的朋友可以做一下自行分析。
程式碼如下:
[HTML] 純文字檢視 複製程式碼<!DOCTYPE html> <html> <head> <meta charset=" utf-8"> <meta name="author" content="http://www.softwhy.com/" /> <title>螞蟻部落</title> <script type="text/javascript"> window.addEventListener("load",eventWindowLoaded, false); function eventWindowLoaded(){ var x,y; var theCanvas = document.getElementById("canvas"); var context = theCanvas.getContext("2d"); context.strokeStyle = '#00f'; context.lineWidth=10; context.strokeRect(0, 0, theCanvas.width-0, theCanvas.height-0); context.fillStyle = "#00f"; for(x=5;x<=canvas.width;x=x+10){ context.beginPath(); context.arc(x,5,5,0,Math.PI,false); context.closePath(); context.fill(); context.beginPath(); context.arc(x,canvas.height-5,5,0,Math.PI,true); context.closePath(); context.fill(); } for(y=5;y<=canvas.height;y=y+10){ context.beginPath(); context.arc(5,y,5,0,Math.PI*2,true); context.arc(canvas.width-5,y,5,0,Math.PI*2,true); context.closePath(); context.fill(); } } </script> </head> <body> <div style="position: absolute; top: 100px; left: 100px;"> <canvas id="canvas" width="300" height="300">瀏覽器不支援</canvas> </div> </body> </html>
相關文章
- css3鋸齒形邊框效果程式碼例項CSSS3
- canvas實現的鐘表效果程式碼例項Canvas
- canvas實現的驗證碼效果程式碼例項Canvas
- 利用canvas實現的驗證碼效果程式碼例項Canvas
- canvas實現的雪花飄落效果程式碼例項Canvas
- canvas實現的藍色雨滴效果程式碼例項Canvas
- canvas實現的彈力小球效果程式碼例項Canvas
- canvas實現煙花燃放效果程式碼例項Canvas
- canvas實現的七巧板效果程式碼例項Canvas
- canvas實現的動態心形效果程式碼例項Canvas
- canvas實現的圓形鐘錶效果程式碼例項Canvas
- canvas實現的簡單畫板效果程式碼例項Canvas
- canvas火焰效果程式碼例項Canvas
- canvas實現的賽貝爾曲線效果程式碼例項Canvas
- canvas實現的小球四壁碰撞效果程式碼例項Canvas
- canvas實現文字線性漸變效果程式碼例項Canvas
- canvas實現的刮刮樂程式碼例項Canvas
- canvas實現的旋轉的太極圖效果程式碼例項Canvas
- canvas字母雨效果程式碼例項Canvas
- canvas載入效果程式碼例項Canvas
- canvas擺動效果程式碼例項Canvas
- canvas實現的美猴王程式碼例項Canvas
- canvas實現點選產生放射性效果程式碼例項Canvas
- canvas水位進度效果程式碼例項Canvas
- canvas原型鐘錶效果程式碼例項Canvas原型
- canvas氣泡上浮效果程式碼例項Canvas
- canvas田字格效果程式碼例項Canvas
- canvas繪製圓環效果程式碼例項Canvas
- canvas螞蟻線效果程式碼例項Canvas
- canvas實現的變幻線程式碼例項Canvas線程
- canvas實現的多邊形程式碼例項Canvas
- canvas實現的千輪眼程式碼例項Canvas
- jquery實現的選項卡效果例項程式碼jQuery
- canvas模擬彈幕效果程式碼例項Canvas
- canvas繪製箭頭效果程式碼例項Canvas
- canvas繪製夜空小屋效果程式碼例項Canvas
- canvas流星劃過星空效果程式碼例項Canvas
- canvas繪製鐘錶效果程式碼例項Canvas