Beispiel:SVG-Filter-12.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" media="screen" href="./Beispiel:SELFHTML-Beispiel-Grundlayout.css">  
  <style>
svg {
  width: 96%;
}
  </style>
  <title>Beispiel: feMorphology</title>
</head>
 
<body>
<h1>SVG-Filter feMorphology</h1>

<svg viewBox="0 0 800 500">
  <defs>	
    <filter id="f1">
      <feMorphology operator="erode" radius="1" />
    </filter>
    <filter id="f2">
      <feMorphology operator="dilate" radius="1" />
    </filter>
<!-- zusätzlich mit feGaussianBlur, feOffset,
        feTurbulence, feDisplacementMap und feMerge -->
    <filter id="f3"
      x="-.3" y="-.5" width="1.9" height="1.9">
      <feGaussianBlur in="SourceAlpha"
        stdDeviation="2"
        result="out1" />
      <feOffset in="out1"
        dx="4" dy="-.5"
        result="out2" />
      <feTurbulence in="SourceGraphic"
        baseFrequency=".7" type="turbulence"
        result="out3" />
      <feDisplacementMap in="SourceGraphic" in2="out3"
        scale="5"
        result="out4" />
      <feMorphology in="out4"
        operator="erode" radius=".5"
        result="out5" />
      <feMerge>
        <feMergeNode in="out2" />
        <feMergeNode in="out5" />
      </feMerge>
    </filter>
	
    <filter id="f4"
      x="-.3" y="-.5" width="1.9" height="1.9">
      <feGaussianBlur in="SourceAlpha" stdDeviation="2" />
      <feOffset dx="4" dy="-.5"
        result="out2" />
      <feTurbulence in="SourceGraphic" baseFrequency=".7" type="turbulence"
        result="out3" />
      <feDisplacementMap in="SourceGraphic" in2="out3"
        scale="5" />
      <feMorphology operator="dilate" radius=".5"
        result="out5" />
      <feMerge>
        <feMergeNode in="out2" />
        <feMergeNode in="out5" />
      </feMerge>
    </filter>
	
    <symbol id="bild" >
	  <image x="0" y="0" width="200px" height="200px"
         href="http://wiki.selfhtml.org/images/f/fe/Doppeldecker.svg">
        <title>Doppeldecker</title>
      </image>		
	</symbol>
  </defs>

  <text x="20" y="25"> ohne Filter</text>
  <use href="#bild" transform="translate(20,50) " />
  
  <text x="250" y="25" font-weight="bold"> feMorphology</text>
  <text x="250" y="50">operator="erode" radius=1"</text>
  <use href="#bild" transform="translate(250,80)"
    filter="url(#f1)" />
  <text x="250" y="290">operator="dilate" radius=1"</text>	
  <use href="#bild" transform="translate(250,320)"
    filter="url(#f2)" />
	
<text x="500" y="25" font-weight="bold"> zusätzlich mit feGaussianBlur, feOffset,  </text>
<text x="500" y="50" font-weight="bold">feTurbulence, feDisplacementMap</text>
<text x="500" y="75" font-weight="bold">feMerge</text>
  <use href="#bild" transform="translate(500,80)"
    filter="url(#f3)" />
  <use href="#bild" transform="translate(500,320)"
    filter="url(#f4)" />

</svg>
</body>
</html>