SVGFESpotLightElement: limitingConeAngle 属性

Baseline 已广泛支持

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

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

一个 SVGAnimatedNumber 对象。

示例

访问 <feSpotLight> 元素的 limitingConeAngle 属性

在此示例中,我们通过使用 SVGFESpotLightElement 接口的只读属性 limitingConeAngle 来访问聚光灯轴(即光源与它指向的点之间的轴)与聚光灯锥之间的角度(以度为单位)。

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="40"
        lighting-color="lime"
        surfaceScale="5">
        <feSpotLight
          x="100"
          y="100"
          z="50"
          pointsAtX="100"
          pointsAtY="100"
          limitingConeAngle="30"
          specularExponent="40" />
      </feSpecularLighting>
    </filter>
  </defs>

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

// Access the limitingConeAngle property
console.log(spotLightElement.limitingConeAngle.baseVal); // Output: 30

规范

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

浏览器兼容性

另见