如何使用 HTML5 畫布繪製橢圓?
你可以嘗試執行以下程式碼,在 HTML5 畫布中繪製橢圓 -
示例
<!DOCTYPE HTML>
<html>
<head>
</head>
<body>
<canvas id="newCanvas" width="450" height="300"></canvas>
<script>
// canvas
var c = document.getElementById('newCanvas');
var context = c.getContext('2d');
var cX = 0;
var cY = 0;
var radius = 40;
context.save();
context.translate(c.width / 2, c.height / 2);
context.scale(2, 1);
context.beginPath();
context.arc(cX, cY, radius, 0, 2 * Math.PI, false);
context.restore();
context.fillStyle = '#000000';
context.fill();
context.lineWidth = 2;
context.strokeStyle = 'yellow';
context.stroke();
</script>
</body>
</html>輸出

廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP