XML technologies / SVG / Filters, transformations and gradients / Using and combining filters and lighting effectively / Lighting effects / Defining distant light sources

(Excerpt from “Das Einsteigerseminar SVG — Webgrafiken mit XML” by Helma Spona)

The element <feDistantLight> defines distant light sources. It has these attributes:

For a rectangle, such a light source simply brightens the filtered SVG object uniformly. Irregular objects instead show lighting and shadows. Brightness depends on both attributes and the parent tag’s settings.

<filter id="FLicht01">
  <feDiffuseLighting in="SourceGraphic" diffuseConstant="1" surfaceScale="10" style="lighting-color:white">
    <feDistantLight azimuth="0" elevation="30" />
  </feDiffuseLighting>
</filter>

Note:
The example uses the tag <feDiffuseLighting> for lighting. Several attributes are required to make its effect visible; their meanings and purposes are explained shortly.

Applying the preceding filter with

<circle cx="50" cy="50" r="20" style="fill:red;filter:url(#FLicht01)" />

to a simple red-filled circle (gray in the figure) produces this output.

Effects of the feDistantLight filter

Figure: Effects of the feDistantLight filter.

   

 

 

 

back to top