SVGEllipseElement: cy-Eigenschaft

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since January 2020.

Die schreibgeschützte cy-Eigenschaft der SVGEllipseElement-Schnittstelle beschreibt die y-Achsen-Koordinate des Mittelpunkts der Ellipse als SVGAnimatedLength. Sie spiegelt den berechneten Wert des cy-Attributs auf dem <ellipse>-Element wider.

Der Attributwert ist eine \<length>, \<percentage> oder \<number>. Der numerische Wert von SVGAnimatedLength.baseVal ist die y-Koordinate des Mittelpunkts der Ellipse im Benutzerkoordinatensystem.

Wert

Beispiel

Angenommen, wir haben das folgende SVG:

html
<svg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg">
  <ellipse cx="50" cy="75" rx="30" ry="20" fill="blue" />
  <ellipse cx="25%" cy="50%" rx="10%" ry="5%" fill="red" />
</svg>

Wir können die berechneten Werte der cy-Attribute abrufen:

js
const ellipses = document.querySelectorAll("ellipse");
const cyPos0 = ellipses[0].cy;
const cyPos1 = ellipses[1].cy;

console.dir(cyPos0.baseVal.value); // output: 75
console.dir(cyPos1.baseVal.value); // output: 100 (50% of the viewBox height, 200)

Spezifikationen

Specification
Scalable Vector Graphics (SVG) 2
# __svg__SVGEllipseElement__cy

Browser-Kompatibilität

Siehe auch