Beispiel:SVG-Shape-Morphing-02.html

Aus SELFHTML-Wiki
Wechseln zu: Navigation, Suche
<!DOCTYPE html>
<html lang="de">
<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: 100%;
  height:410px;
  margin: 1 rem;
  padding: 0;
  background: white;
  border: 1px dotted #306f91;
}  
path {
  fill: #dfac20;
  stroke: #306f91;
  stroke-width: 3;
}
 
  </style>
  <title>Beispiel: Shape-Morphing 2</title>
</head>
 
<body>
<h1>Beispiel: Shape-Morphing 2</h1>

<svg viewbox="100 0 400 260">
<path id="pentagon" d="M100,200 l-15,-50 l-15,-50 l40,-30 l40,-30 l40,30 l40,30 l-15,50 l-15,50 l-51,0 l-51,0">
  <animate attributeName="d" 
    values="M100,200 l-15,-50 l-15,-50 l40,-30 l40,-30 l40,30 l40,30 l-15,50 l-15,50 l-51,0 l-51,0;
            M100,200 l18,-60 l-48,-40 l60,0 l20,-60 l20,60 l60,0 l-48,38 l17,60 l-49,-38 l-49,38;
            M100,200 l-15,-50 l-15,-50 l40,-30 l40,-30 l40,30 l40,30 l-15,50 l-15,50 l-51,0 l-51,0;"
    dur="2s" 
    repeatCount="indefinite" 
  />
</path>
	
<path id="hexagon" d="M420,200 l-40,-80 l40,-80 h100 l40,80 l-40,80Z">
  <animate attributeName="d" 
           values="M420,200 l-40,-80 l40,-80 h100 l40,80 l-40,80Z;
                   M400,200 l0,-80 l0,-80 h140 l0,80 l0,80Z;
                   M420,200 l-40,-80 l40,-80 h100 l40,80 l-40,80Z;"
           begin="hexagon.mouseover"
           end="hexagon.click"
           dur="2s"
           repeatCount="indefinite" 
  />	
</path>
 
  </svg>
 <p>Das Fünfeck wird zum Stern; die Animation läuft unendlich.</p>
 <p>Das Sechseck wird erst bei <code>mouseover</code> animiert; zum Beenden klicken Sie auf die Figur.</p>

</body>
</html>