SVGTransform: setScale()-Methode
Baseline
Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since Juli 2015.
Die setScale()-Methode des SVGTransform-Interfaces setzt den Transformationstyp auf SVG_TRANSFORM_SCALE. Die Parameter sx und sy definieren die Skalierungsfaktoren.
Syntax
js
setScale(sx, sy)
Parameter
Rückgabewert
Keiner (undefined).
Ausnahmen
NoModificationAllowedErrorDOMException-
Wird geworfen, wenn das Attribut oder das
SVGTransform-Objekt schreibgeschützt ist.
Beispiele
>Skalierung eines SVG-Elements
js
// Select an SVG element and create a transform object
const svgElement = document.querySelector("svg");
const transform = svgElement.createSVGTransform();
// Set the scale values for the transform
transform.setScale(2, 3);
// Output the scale details
console.log(`Scale X: ${transform.matrix.a}`); // Output: 2
console.log(`Scale Y: ${transform.matrix.d}`); // Output: 3
Spezifikationen
| Specification |
|---|
| Scalable Vector Graphics (SVG) 2> # __svg__SVGTransform__setScale> |
Browser-Kompatibilität
Loading…