SVG <ellipse>

SVG Ellips - <ellipse>

<ellipse> Elemen ini digunakan untuk menciptakan ellips.

Ellips sangat kerapatan dengan lingkaran. Perbedaan utamanya adalah bahwa jari-jari x dan y ellips berbeda, sedangkan lingkaran memiliki jari-jari x dan y yang sama:

Contoh 1

Contoh berikut menciptakan ellips:

Ini adalah kode SVG:

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

Coba Sendiri

Penjelasan kode:

  • Properti cx menentukan koordinat x pusat ellips
  • Properti cy menentukan koordinat y pusat ellips
  • Properti rx menentukan jari-jari horizontal
  • Properti ry menentukan jari-jari vertikal

Contoh 2

Contoh berikut menciptakan tiga ellips yang saling terlambat:

Ini adalah kode 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>

Coba Sendiri

Contoh 3

Contoh berikut menggabungkan dua ellips (salah satunya berwarna kuning dan putih):

Ini adalah kode 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>

Coba Sendiri