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 cy-Eigenschaft der Schnittstelle SVGEllipseElement beschreibt die y-Achsen-Koordinate des Mittelpunkts der Ellipse als ein SVGAnimatedLength. Sie spiegelt den berechneten Wert des cy-Attributs am <ellipse>-Element wider.

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

Wert

Beispiel

Angenommen, folgendes 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 auf die berechneten Werte der cy-Attribute zugreifen:

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

BCD tables only load in the browser

Siehe auch