SVG <ellipse>

SVG 椭円 - <ellipse>

<ellipse> 要素は円を作成するために使用されます。

円と円は非常に密接に関連しています。違いは、円の x と y 半径が異なること、円は x と y 半径が等しいことです:

例1

以下は、円を生成する例です:

これは SVG コードです:

<svg height="140" width="500">
  <ellipse cx="200" cy="80" rx="100" ry="50"
  style="fill:yellow;stroke:purple;stroke-width:2" />
</svg>

実際に試してみる

コードの説明:

  • cx 属性は円の中心の x 座標を定義します
  • cy 属性は円の中心の y 座標を定義します
  • rx 属性は水平半径を定義します
  • ry 属性は垂直半径を定義します

例2

以下は、お互いに重なった三つの円を生成する例です:

これは SVG コードです:

<svg height="150" width="500">
  <ellipse cx="240" cy="100" rx="220" ry="30" style="fill:purple" />
  <ellipse cx="220" cy="70" rx="190" ry="20" style="fill:lime" />
  <ellipse cx="210" cy="45" rx="170" ry="15" style="fill:yellow" />
</svg>

実際に試してみる

例3

以下は、二つの円(黄色と白色)を組み合わせた例です:

これは SVG コードです:

<svg height="100" width="500">
  <ellipse cx="240" cy="50" rx="220" ry="30" style="fill:yellow" />
  <ellipse cx="220" cy="50" rx="190" ry="20" style="fill:white" />
</svg>

実際に試してみる