這篇文章主要介紹如何使用html5 canvas繪制實心原形,文中介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們一定要看完!
<style>
#canvas{
width: 500px;
height: 500px;
}
</style>
<body>
<canvas id="canvas"></canvas>
</body>
<script>
var canvas=document.getElementById("canvas");
var ctx=canvas.getContext("2d");
//畫一個空心圓
ctx.beginPath();
// arc()方法是創建弧/曲線(用于創建圓或部分圓)
// context.arc(x,y,r,sAngle,eAngle,counterclockwise);
// 起始角為 0
// 結束角為 2*Math.PI
ctx.arc(100,75,50,0,2*Math.PI);
ctx.lineWidth=5;
ctx.strokeStyle="green";
// 使用 stroke()或fill()方法在畫布上繪制實際的弧
ctx.stroke();//畫空心圓
ctx.closePath();
//畫一個實心圓
// ctx.beginPath();
// ctx.arc(200,100,50,0,360,false);
// ctx.fillStyle="red";//填充顏色,默認是黑色
// ctx.fill();//畫實心圓
// ctx.closePath();
//空心和實心的組合
// ctx.beginPath();
// ctx.arc(100,100,50,0,360,false);
// ctx.fillStyle="red";
// ctx.fill();
// ctx.strokeStyle="green";
// ctx.stroke();
// ctx.closePath();
</script>以上是“如何使用html5 canvas繪制實心原形”這篇文章的所有內容,感謝各位的閱讀!希望分享的內容對大家有幫助,更多相關知識,歡迎關注億速云行業資訊頻道!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。