SVGFESpotLightElement:pointsAtZ 属性

Baseline 已广泛支持

此特性已相当成熟,可在许多设备和浏览器版本上使用。自 ⁨2015 年 7 月⁩以来,各浏览器均已提供此特性。

SVGFESpotLightElement 接口的只读属性 pointsAtZ 反映了给定 <feSpotLight> 元素的 pointsAtZ 属性。

一个 SVGAnimatedNumber 对象。

示例

访问 <feSpotLight> 元素的 pointsAtZ 属性

在此示例中,我们通过使用 SVGFESpotLightElement 接口的只读属性 pointsAtZ,来访问 SVG 坐标系统中由 <feSpotLight> SVG 滤镜元素创建的光源的 z 位置。

html
<svg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg">
  <defs>
    <filter id="specularLightingFilter">
      <!-- Apply a specular light effect to the SourceGraphic -->
      <feSpecularLighting
        in="SourceGraphic"
        specularExponent="20"
        lighting-color="hotpink"
        surfaceScale="30">
        <feSpotLight
          x="10"
          y="50"
          z="150"
          pointsAtX="150"
          pointsAtY="100"
          pointsAtZ="0"
          specularExponent="20" />
      </feSpecularLighting>
    </filter>
  </defs>

  <!-- A circle to display the effect of the lighting -->
  <circle cx="100" cy="100" r="50" filter="url(#specularLightingFilter)" />
</svg>
js
// Select the feSpotLight element
const spotLightElement = document.querySelector("feSpotLight");
console.log(spotLightElement.pointsAtZ.baseVal); // Output: 0

规范

规范
滤镜效果模块第 1 级
# dom-svgfespotlightelement-pointsatz

浏览器兼容性

另见