SVGGradientElement: spreadMethod プロパティ
Baseline
Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2015年7月.
spreadMethod は SVGGradientElement インターフェイスの読み取り専用プロパティで、この要素の spreadMethod 属性を反映します。これは、このインターフェイスで定義された SVG_SPREADMETHOD_* 定数のいずれかを取ります。
値
例
>spreadMethod プロパティのアクセス
html
<svg xmlns="http://www.w3.org/2000/svg" width="200" height="200">
<defs>
<linearGradient id="gradient2" spreadMethod="reflect">
<stop offset="0%" stop-color="red" />
<stop offset="50%" stop-color="yellow" />
<stop offset="100%" stop-color="blue" />
</linearGradient>
</defs>
<rect x="10" y="10" width="180" height="180" fill="url(#gradient2)" />
</svg>
js
const gradient = document.getElementById("gradient2");
console.log(gradient.spreadMethod.baseVal); // 出力: 2 (SVG_SPREADMETHOD_REFLECT)
仕様書
| Specification |
|---|
| Scalable Vector Graphics (SVG) 2> # __svg__SVGGradientElement__spreadMethod> |