HTML Canvas 円形

あなたのブラウザは HTML5 canvas タグをサポートしていません。
const canvas = document.getElementById("myCanvas");
const ctx = canvas.getContext("2d");
ctx.beginPath();
ctx.arc(95, 50, 40, 0, 2 * Math.PI);
ctx.stroke();

自分で試してみてください

円を描画

キャンバス上に円を描画するには、以下のメソッドを使用してください:

  • beginPath() - 路径を開始します。
  • arc(x,y,r,start,end) - 円を定義します。
  • stroke() - 描画

arc(x,y,r,start,end) - 弧(曲線)を作成します。

円を作成するには、始点角度を 0 に、終点角度を 2 * Math.PI に設定してください。

x と y パラメータは円の中心の座標を定義します。

r パラメータは円の半径を定義します。

も参照してください:

CodeW3C.com の完全な Canvas リファレンスマニュアル