canvas繪製實心圓形程式碼例項
本章節分享一段程式碼例項,它實現了繪製圓形效果。
並且這個圓形內部是填充的,需要的朋友可以做一下參考。
程式碼例項如下:
[HTML] 純文字檢視 複製程式碼<!doctype html> <html> <head> <meta charset="utf-8"> <meta name="author" content="http://www.softwhy.com/" /> <title>螞蟻部落</title> <script type="text/javascript"> function drawCircle(id) { var canvas = document.getElementById(id); if (canvas) { var context = canvas.getContext("2d"); context.fillStyle = "gray"; context.strokeStyle = "black"; context.fillRect(0, 0, 400, 400); context.beginPath(); context.arc(100, 100, 50, 0, Math.PI * 2, true); context.closePath(); context.fillStyle = "green"; context.fill(); } else { return; } } window.onload = function () { drawCircle("canvas"); } </script> </head> <body> <canvas id="canvas" width="400" style="background:red;" height="400"></canvas> </body> </html>
相關文章
- canvas繪製圓形鐘錶程式碼例項Canvas
- css繪製圓形程式碼例項CSS
- canvas繪製圓角矩形程式碼例項Canvas
- canvas繪製橢圓效果程式碼例項Canvas
- canvas繪製網狀圓圈程式碼例項Canvas
- javascript繪製心形圖案程式碼例項JavaScript
- canvas 繪製圓形Canvas
- canvas繪製扇形程式碼例項Canvas
- canvas繪製星星程式碼例項Canvas
- canvas 繪製雞蛋程式碼例項Canvas
- css3繪製心形圖案程式碼例項CSSS3
- border-radius繪製圓形圖案程式碼例項
- svg繪製半圓程式碼例項SVG
- 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
- html5利用canvas圓形和多邊形程式碼例項HTMLCanvas
- 使用canvas繪製圓形進度條Canvas
- html5中canvas繪製圓形HTMLCanvas
- canvas繪製機器貓頭像程式碼例項Canvas
- canvas繪製矩形並填充顏色程式碼例項Canvas
- canvas繪製貝濟埃曲線程式碼例項Canvas線程
- canvas繪製憤怒小鳥形象程式碼例項Canvas
- HTML5利用canvas繪製矩形程式碼例項HTMLCanvas
- canvas繪製五角星程式碼例項Canvas
- css實現圓形、橢圓和半圓效果程式碼例項CSS