Baza wiedzyCentrum egzaminacyjne
PLPolski
Wybierz język13

CKTIS / CSS

Właściwość CSS `lighting-color`

`lighting-color` ustala kolor, z którego prymitywy SVG `feDiffuseLighting` i `feSpecularLighting` wyliczają oświetlone piksele.

Wersja: CSS modules; captured CSSWG editor index includes draft and obsolete features requiring review

Składnia

<color>

lighting-color ustala kolor, z którego prymitywy SVG feDiffuseLighting i feSpecularLighting wyliczają oświetlone piksele.

Przykład odczytuje początkową biel, nadaje feDiffuseLighting kolor RGB i potwierdza, że prostokąt rzeczywiście używa tego filtra.

Składnia: <color>.

Właściwość działa na prymitywach oświetlenia SVG; ustawienie jej na zwykłym elemencie HTML nie tworzy światła. Nie jest dziedziczona, a przestrzeń obliczeń koloru zależy także od color-interpolation-filters.

Przykłady

<!doctype html>
<html lang="en"><meta charset="utf-8"><title>lighting-color behavior</title>
<body><svg width="40" height="40"><filter id="f"><feDiffuseLighting id="light" surfaceScale="1"><feDistantLight azimuth="45" elevation="60"/></feDiffuseLighting></filter><rect id="sample" width="40" height="40" filter="url(#f)"/></svg><pre id="result"></pre><script>
const light=document.querySelector('#light');const sample=document.querySelector('#sample');
const before=getComputedStyle(light).lightingColor;light.style.lightingColor='rgb(10 20 30)';const after=getComputedStyle(light).lightingColor;
document.querySelector('#result').textContent='primitive='+light.localName+'; color='+before+'->'+after+'; target-filter='+(getComputedStyle(sample).filter!=='none');
</script></body></html>

Wynik

primitive=feDiffuseLighting; color=rgb(255, 255, 255)->rgb(10, 20, 30); target-filter=true

Przykład uruchomiono lokalnie w izolowanej, bezsieciowej sesji Chrome; wynik pochodzi z API CSS przeglądarki.

Źródła