Beispiel:SVG-Filter-06.html

Aus SELFHTML-Wiki
Wechseln zu: Navigation, Suche
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0;" />
  <link rel="stylesheet" type="text/css" media="screen" href="./Beispiel:SELFHTML-Beispiel-Grundlayout.css" />
  <style>
svg {
  width: 96%;
  padding:0;
  margin:0;
  background: white;
}

 
  </style>
  <title>Beispiel: Der Filter feDiffuseLighting</title>
</head>
 
<body>
  <h1>SVG-Filter feDiffuseLighting</h1>
 
  <main>

<svg  viewBox="0 0 880 500" >
<defs>
  <filter id="beleuchtung1">
    <feDiffuseLighting in="SourceGraphic" result="light" lighting-color="white">
      <feDistantLight azimuth="50" elevation="50"/>
    </feDiffuseLighting>

    <feComposite in="SourceGraphic" in2="light"
                 operator="arithmetic" k1="1" k2="0" k3="0" k4="0"/>
  </filter>
  
  <filter id="beleuchtung2">
    <feDiffuseLighting in="SourceGraphic" result="light" lighting-color="white">
      <fePointLight x="30" y="30" z="20" />
    </feDiffuseLighting>
    <feComposite in="SourceGraphic" in2="light"
                 operator="arithmetic" k1="1" k2="0" k3="0" k4="0"/>
  </filter>
  
 <filter id="beleuchtung3">
    <feDiffuseLighting in="SourceGraphic" result="light" lighting-color="white">
      <feSpotLight x="-20" y="5" z="30" limitingConeAngle="20"
                   pointsAtX="50" pointsAtY="50" pointsAtZ="0"/>
    </feDiffuseLighting>

    <feComposite in="SourceGraphic" in2="light"
                 operator="arithmetic" k1="1" k2="0" k3="0" k4="0"/>
  </filter>
  
  <symbol id="kreis">
    <circle  cx="50" cy="50" r="50" fill="#3983ab" ></circle>
  </symbol>	
  <symbol id="viereck">
    <rect x="0" y="0" width="100" height="100" fill="#dfac20" />
  </symbol>
  <symbol id="ellipse">
    <rect x="0" y="0" width="100" height="100" rx="20" ry="50" fill="#c32e04" />
  </symbol>
  
</defs>
  <!-- kein Beleuchtungsfilter -->
  <text text-anchor="middle" x="60" y="22">kein Filter</text>
  <use xlink:href="#kreis" transform="translate(50,50)"/>
  <use xlink:href="#viereck" transform="translate(50,200)"/>  
  <use xlink:href="#ellipse" transform="translate(50,350)"/>  
    
  <!-- weiche Beleuchtung -->
  <text text-anchor="middle" x="300" y="22">feDistantLight</text>
  <use xlink:href="#kreis"
        transform="translate(250,50)"
           filter="url(#beleuchtung1)" 
  />
  <use xlink:href="#viereck"
        transform="translate(250,200)"
           filter="url(#beleuchtung1)" 
  />
    <use xlink:href="#ellipse"
        transform="translate(250,350)"
           filter="url(#beleuchtung1)" 
  />

  <!-- Punktlichtquelle -->
  <text text-anchor="middle" x="500" y="22">fePointLight</text>
  <use xlink:href="#kreis"
        transform="translate(450,50)"
           filter="url(#beleuchtung2)" 
  />
  <use xlink:href="#viereck"
        transform="translate(450,200)"
           filter="url(#beleuchtung2)" 
  />
  <use xlink:href="#ellipse"
        transform="translate(450,350)"
           filter="url(#beleuchtung2)" 
  />
  <!-- Scheinwerfer -->
  <text text-anchor="middle" x="700" y="22">feSpotLight</text>
  <use xlink:href="#kreis"
        transform="translate(650,50)"
           filter="url(#beleuchtung3)" 
  />
  <use xlink:href="#viereck"
        transform="translate(650,200)"
           filter="url(#beleuchtung3)" 
  />
    <use xlink:href="#ellipse"
        transform="translate(650,350)"
           filter="url(#beleuchtung3)" 
  />

</svg>

  </main>
</body>
</html>