diffuseConstant

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.

Thuộc tính diffuseConstant biểu thị giá trị kd trong mô hình chiếu sáng Phong. Trong SVG, đây có thể là bất kỳ số không âm nào.

Thuộc tính này được dùng để xác định giá trị RGB cuối cùng của một pixel cho trước. Ánh sáng-color càng sáng thì số này càng nên nhỏ.

Bạn có thể dùng thuộc tính này với phần tử SVG sau:

Ví dụ

html
<svg viewBox="0 0 420 200" xmlns="http://www.w3.org/2000/svg">
  <filter id="diffuseLighting1" x="0" y="0" width="100%" height="100%">
    <feDiffuseLighting in="SourceGraphic" diffuseConstant="1">
      <fePointLight x="60" y="60" z="20" />
    </feDiffuseLighting>
  </filter>
  <filter id="diffuseLighting2" x="0" y="0" width="100%" height="100%">
    <feDiffuseLighting in="SourceGraphic" diffuseConstant="2">
      <fePointLight x="60" y="60" z="20" />
    </feDiffuseLighting>
  </filter>

  <rect x="0" y="0" width="200" height="200" filter="url(#diffuseLighting1)" />
  <rect
    x="220"
    y="0"
    width="200"
    height="200"
    filter="url(#diffuseLighting2)" />
</svg>

Ghi chú sử dụng

Giá trị <number>
Giá trị mặc định 1
Có thể hoạt ảnh

Thông số kỹ thuật

Specification
Filter Effects Module Level 1
# element-attrdef-fediffuselighting-diffuseconstant

Khả năng tương thích trình duyệt

Xem thêm