使用html5和js畫(huà)個(gè)太極圖
<canvas id="mycanvas" width="600" height="400" style="border: 1px solid #ccc; background-color: #ccc;">你的瀏覽器不支持canvas</canvas>
<script>
var canvas = document.getElementById('mycanvas');
var ctx = canvas.getContext('2d');
//左邊半個(gè)黑圓
ctx.beginPath();
ctx.fillStyle="#000";
ctx.arc(200,200,150,0.5*Math.PI,1.5*Math.PI,false);
ctx.fill();
//右邊半個(gè)白圓
ctx.beginPath();
ctx.fillStyle="#fff";
ctx.arc(200,200,150,1.5*Math.PI,2.5*Math.PI,false);
ctx.fill();
//圓心
/*ctx.beginPath();
ctx.strokeStyle="#000";
ctx.arc(200,200,1,0,2*Math.PI,false);
ctx.stroke();*/
//上面半個(gè)圓
ctx.beginPath();
ctx.fillStyle="#fff";
ctx.arc(200,125,75,0.5*Math.PI,1.5*Math.PI,false);
ctx.fill();
//上面半個(gè)圓中小黑圓
ctx.beginPath();
ctx.fillStyle="#000";
ctx.arc(200,125,10,0,2*Math.PI,false);
ctx.fill();
//下面半個(gè)圓
ctx.beginPath();
ctx.fillStyle="#000";
ctx.arc(200,275,75,1.5*Math.PI,2.5*Math.PI,false);
ctx.fill();
//下面半個(gè)圓中個(gè)小白圓
ctx.beginPath();
ctx.fillStyle="#fff";
ctx.arc(200,275,10,0,2*Math.PI,false);
ctx.fill();
</script>
中國(guó)· 上海

關(guān)鍵詞
辦公室:上海市浦東新區(qū)郭守敬路351號(hào)
CopyRight?2009-2019 上海谷谷網(wǎng)絡(luò)科技有限公司 All Rights Reserved. 滬ICP備11022482號(hào)-8
- top
- 在線咨詢
-
添加微信咨詢