Beispiel:SVG-marker-1.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:Grundlayout.css">
  <style>
marker {
  stroke: #000;
  fill:url(#verlauf1);
} 
 
path, rect {
  stroke: steelblue;
  fill:none;
  stroke-width: 10;
  animation-name:             widen;
  animation-duration:         4s;
  animation-direction:        alternate;
  animation-timing-function:  ease-in-out;
  animation-iteration-count:  infinite;
}
 
@keyframes widen {
  from {
    stroke-width: 10;
  }
  to {
    stroke-width: 30;
  }
}

text {
	font-family: monospace;
	font-size: 16px;
}

svg {
  width: 96%;
  }  
  </style>
  <title>SVG - marker + markerUnits</title>
</head>
 
<body>
  <h1>Markierungen in SVG</h1>
<svg viewbox="0 0 600 430">
	<defs>
		<marker id="eins" markerWidth="22" markerHeight="22" refX="1" refY="1">
			<circle cx="1" cy="1" r=".5" stroke-width=".05" /> </marker>
		<marker id="zwei" markerWidth="22" markerHeight="22" markerUnits="userSpaceOnUse"
		refX="10" refY="10">
			<circle cx="10" cy="10" r="9" stroke-width="1" /> </marker>
		<radialGradient id="verlauf1">
			<stop offset="3%" stop-color="firebrick" />
			<stop offset="90%" stop-color="gold" /> </radialGradient>
	</defs>
	<path d="M100,50 c-80,-50 -80,40 -30,70 c 80,50 20,120 -30,70 m110,-150 l50,160 50,-160 m150,30 a 70,80,0 1 0 0,100 v30 m0,-30 h-30"
	style="marker: url(#eins); stroke-linejoin: round;" />
	<text x="100" y="230">markerUnits="strokeWidth" (Standardwert)</text>
	<path d="M20,400 h100 a20,20 0 0,0 20,-20 v-50 c0,-100 300,-100 300,10  a50,50 0 0,0 100,0 v-150"
	style="marker: url(#zwei);" />
	<text x="180" y="400">markerUnits="userSpaceOnUse"</text>
	<rect x="500" y="50" width="100" height="100"
	style="marker: url(#eins); stroke-linejoin: round;" />
  </svg>
<p> Der untere Pfad  erhält mit <code>markerUnits="userSpaceOnUse"</code> das Koordinatensystem der Viewbox. Strichstärken können so einheitlich verwendet werden</p>
<p>Der obere Pfad (SVG)  hat keine Festlegung - alle Werte beziehen sich auf die Strichstärke (<em>strokeWidth</em>). Einerseits passt sich die Markierung flexibel an spätere Änderungen der Strichstärke an - andererseits muss die Strichstärke der Markierung mit <code>0.05</code> entsprechend ermittelt und gesetzt werden.
<p>Anders als in der Spec und MDN angegeben, erhält das Rechteck rechts oben keine Markierungen.</p>
</body>
</html>