<h1>SVG Marker Level 1</h1>
<pre class='metadata'>
Level: 1
Status: ED
ED: http://dev.w3.org/fxtf/motion-1/
Shortname: svg-markers
Group: svg
Editor: Cameron McCormack, Mozilla Corporation, cam@mcc.id.au
Abstract: Markers are graphical objects that are painted at particular positions along a <a element>path</a>, <a element>line</a>, <a element>polyline</a> or <a element>polygon</a> element.
</pre>
<pre class=link-defaults>
spec:svg2; type:element; text:svg
spec:css-overflow-3; type:value; text:hidden
spec:svg2; type:element; text:a
spec:css-masking-1; type:element; text:clippath
spec:svg2; type:element; text:foreignobject
spec:svg2; type:element; text:script
spec:svg2; type:element; text:style
</pre>

<style>
dl.attrdef-list dl { margin-top: 1em }
dl.attrdef-list > dt { font-weight: normal }

/* Attribute definition tables */
table.attrdef { border-left-color: #888; border-left-width: 0; background-color: #eee; font-size: 90% }
table.attrdef th, table.attrdef td { border-bottom-color: #ccc }

table.attrdef th:first-child,
table.attrdef td:first-child { width: 16em; padding-left: 0 !important }

table.attrdef th:first-child + th,
table.attrdef td:first-child + td { width: auto }

table.attrdef th:first-child + th + th,
table.attrdef td:first-child + td + td { width: 6em }

table.attrdef th:first-child + th + th + th,
table.attrdef td:first-child + td + td + td { width: 6em; padding-right: 0 !important }
</style>

<h2 id="introduction">Introduction</h2>

A marker is a graphical object that is painted at particular positions along
a <a element>path</a>, <a element>line</a>, <a element>polyline</a> or <a element>polygon</a>
element, together known as the <dfn external>markable elements</dfn>.  There are four ways
markers can be placed on these elements:

<ul>
  <li>The 'marker-start' and 'marker-end' properties
  can be used to place markers at the first and last vertex, and the
  'marker-mid' property can be used to place markers at every
  other vertex (aside from the first and last).  The 'marker-start' and
  'marker-end' can be used for example to add arrowheads to paths.
  Markers placed using these properties are known as
  <dfn>vertex markers</dfn>.</li>

  <li>The 'marker-segment' property can be used to place markers
  at the center of every path segment. These markers are known as
  <dfn external>segment markers</dfn>.</li>

  <li>The 'marker-pattern' property can be used to define
  a regular repeating pattern of markers to place along the length of the
  path.  Markers placed with 'marker-pattern' are known as
  <dfn external>repeating markers</dfn>.</li>

  <li>A child <a element>marker</a> element with a <a element-attr for=marker>position</a> attribute
  can be used to place a marker at a particular location along the path.
  Such markers are known as <dfn external>positioned markers</dfn>.</li>
</ul>

ISSUE: There are probably better terms to use than "vertex" and
"segment" markers.  At least, "vertex" would go more naturally with "edge",
but we should use more natural sounding names.

The graphics for a marker are defined by a <a element>marker</a> element.
The 'marker-start', 'marker-end', 'marker-mid',
'marker-segment' and 'marker-pattern' properties, together known
as the <dfn>marker properties</dfn>, reference
<a element>marker</a> elements.

Markers can be animated, and as with <a element>use</a> elements, the animated
effects will show on all current uses of the markers within the document.

Markers on a given element are painted in the following order, from
bottom to top:


* any marker specified by 'marker-start'
* alternating 'marker-mid' and 'marker-segment' markers, in order of their position along the path
* any <a>repeating markers</a>, in order of their position along the path
* any <a>positioned markers</a>, in document order of the <a element>marker</a> element children

<h2 id="MarkerElement">The <a element>marker</a> element</h2>

    <pre class='elementdef'>
    Name: marker
    Categories: Container element
    Contexts: none
    Content Model: Any number of the following statements, in order:
      <ul>
        <li><a>animation elements</a></li>
        <li><a>descriptive elements</a></li>
        <li><a>paint server elements</a></li>
        <li><a>shape elements</a></li>
        <li><a>structural elements</a></li>
        <li><a element>a</a>, <a element>clipPath</a>, <a element>cursor</a>, <a element>filter</a>, <a element>foreignObject</a>, <a element>image</a>, <a element>marker</a>, <a element>mask</a>, <a element>script</a>, <a element>style</a>, <a element>switch</a>, <a element>text</a>, <a element>view</a></li>
      </ul>
    Attributes: refX, refY, orient, viewBox, preserveAspectRatio, markerUnits, markerWidth, markerHeight, position, href
    Attribute Groups: presentation attributes
    DOM Interfaces: SVGMarkerElement
    </pre>

The <a element>marker</a> element defines the graphics that are to
be used for drawing markers on a <a>markable element</a>.

<p id="MarkerAttributes"><em>Attribute definitions:</em></p>

<dl class="attrdef-list">
<dt>
  <table class="attrdef">
    <tr>
      <th>Name</th>
      <th>Value</th>
      <th>Initial value</th>
      <th>Animatable</th>
    </tr>
    <tr>
      <td><dfn dfn-type=element-attr dfn-for=marker>markerUnits</dfn></td>
      <td>strokeWidth | userSpaceOnUse</td>
      <td>strokeWidth</td>
      <td>yes</td>
    </tr>
  </table>
</dt>
<dd>
  <p>The <a element-attr for=marker>markerUnits</a> attribute defines the coordinate system for
  attributes <a element-attr for=marker>markerWidth</a>, <a element-attr for=marker>markerHeight</a> and the
  contents of the <a element>marker</a>.  Values have the
  following meanings:</p>
  <dl dfn-type=value dfn-for=markerUnits>
    <dt><dfn>strokeWidth</dfn></dt>
    <dd><a element-attr for=marker>markerWidth</a>, <a element-attr for=marker>markerHeight</a> and the contents
    of the <a element>marker</a> represent values in a coordinate system
    which has a single unit equal the size in user units of the
    current stroke width (see the 'stroke-width' property) in
    place for the graphic object referencing the marker.</dd>

    <dt><dfn>userSpaceOnUse</dfn></dt>
    <dd><a element-attr for=marker>markerWidth</a>, <a element-attr for=marker>markerHeight</a> and the contents
    of the <a element>marker</a> represent values in the current
    user coordinate system in place for the graphic object
    referencing the marker (i.e., the user coordinate system for
    the element referencing the <a element>marker</a> element via a
    'marker').</dd>
  </dl>
</dd>
<dt>
  <table class="attrdef">
    <tr>
      <th>Name</th>
      <th>Value</th>
      <th>Initial value</th>
      <th>Animatable</th>
    </tr>
    <tr>
      <td><dfn dfn-type=element-attr dfn-for=marker>markerWidth</dfn>,
      <dfn dfn-type=element-attr dfn-for=marker>markerHeight</dfn></td>
      <td><<length>> | <<percentage>> | <<number>></td>
      <td>3</td>
      <td>yes</td>
    </tr>
  </table>
</dt>
<dd>
  The <a element-attr for=marker>markerWidth</a> and
  <a element-attr for=marker>markerHeight</a> attributes
  represent the size of the viewport into which the marker is to
  be fitted according to the <a element-attr>viewBox</a> and
  <a element-attr>preserveAspectRatio</a>
  attributes.  A value of zero for either
  attribute results in nothing being rendered for the marker.  A negative value
  for either attribute is an error (see
  <a href="implnote.html#ErrorProcessing">Error processing</a>).
</dd>
<dt>
  <table class="attrdef">
    <tr>
      <th>Name</th>
      <th>Value</th>
      <th>Initial value</th>
      <th>Animatable</th>
    </tr>
    <tr>
      <td><dfn dfn-type=element-attr dfn-for=marker>refX</dfn></td>
      <td><<length>> | <<percentage>> | <<number>> | left | center | right</td>
      <td>0</td>
      <td>yes</td>
    </tr>
    <tr>
      <td><dfn dfn-type=element-attr dfn-for=marker>refY</dfn></td>
      <td><<length>> | <<percentage>> | <<number>> | top | center | bottom</td>
      <td>0</td>
      <td>yes</td>
    </tr>
  </table>
</dt>
<dd>
  <p class="note">New in SVG 2: geometric keywords (matches use in <a element>symbol</a>).</p>
  <p class="annotation">We will add top/center/bottom, left/center/right keywords to
  refX/refY on marker/symbol. Resolved at
  <a href="http://www.w3.org/2014/08/26-svg-minutes.html#item07">LondonF2F</a>.
  Values inspired by 'background-position'.</p>
  <p>The <a element-attr for=marker>refX</a> and <a element-attr for=marker>refY</a>
  attributes define the reference point of the marker which is to be placed exactly
  at the marker's position on the <a>markable element</a>.  They are interpreted as
  being in the coordinate system of the marker contents, after application of the
  <a element-attr>viewBox</a> and <a element-attr>preserveAspectRatio</a>
  attributes.</p>
</dd>
<dt>
  <table class="attrdef">
    <tr>
      <th>Name</th>
      <th>Value</th>
      <th>Initial value</th>
      <th>Animatable</th>
    </tr>
    <tr>
      <td><dfn dfn-type=element-attr dfn-for=marker>orient</dfn></td>
      <td>auto | auto-start-reverse | <<angle>> | <<number>></td>
      <td>0</td>
      <td>yes&#160;(non-additive)</td>
    </tr>
  </table>
</dt>
<dd>
  <p>The <a element-attr for=marker>orient</a> attribute indicates how the marker
  is rotated when it is placed at its position on the <a>markable element</a>.
  Values have the following meaning:</p>
  <dl>
    <dt>''orient/auto''</dt>
    <dd>
      <p>A value of ''orient/auto''
      indicates that the marker is oriented such that its positive
      x-axis is pointing in the direction of the path at the point
      it is placed.</p>

      <p class="issue">This needs to reference a definition for how
      directionality of a given start/mid/end vertex is calculated.
      Part of that (which should be moved somewhere more appropriate) is in
      the <a href="implnote.html#PathElementImplementationNotes">path element implementation notes</a>.
      Some wording from SVG 1.1 appears to have been lost, compare with <a href="http://www.w3.org/TR/SVG11/painting.html#OrientAttribute">this</a>.
      <br/><br/>
      Here's an example that is a bit unclear currently:
      <code style="white-space:pre">
&lt;svg>
  &lt;marker id="m" orient="auto" overflow="visible">
    &lt;rect x="-1" y="-0.5" width="1" height="1" fill="green"/>
  &lt;/marker>
  &lt;path d="M50,0C50,50 50,100 50,100" marker-end="url(#m)" stroke-width="100" stroke="red"/>
&lt;/svg>
    </code>
    <br/>
    The second control point and the endpoint coincide, should this mean that the direction of the endpoint is a) <em>unknown [aka default to 0 degrees]</em> or
    b) <em>that you have to look at the previous segment(s)/command(s) until a direction can be established</em>?
      </p>

      <p>If the marker is a <a>segment marker</a>, then
      the direction the marker is oriented is, if considering the
      incoming and outgoing directions as unit vectors, in the
      direction of the sum of these two vectors.  If this sum
      is zero, then the marker is oriented in the incoming direction.</p>

      <p>If the marker is on the first or last vertex of a closed subpath, then the
      incoming direction taken from the final path segment and the outgoing
      direction is taken from:</p>

      <ul>
        <li>the first path segment of the <em>following</em> subpath,
        if the following subpath does not begin with a
        <a href="paths.html#PathDataMovetoCommands">moveto</a> command, and</li>
        <li>the first path segment of the <em>current</em> subpath,
        if the following subpath does begin with a
        <a href="paths.html#PathDataMovetoCommands">moveto</a> command
        or if there is no following subpath.</li>
      </ul>
    </dd>
  </dl>

  <dl>
    <dt>''orient/auto-start-reverse''</dt>
    <dd>
      <p>A value of ''orient/auto-start-reverse''
      means the same as ''orient/auto'' except that
      for a marker placed by 'marker-start', the orientation is 180°
      different from the orientation as determined by ''orient/auto''.</p>

      <p class="note">This allows a single arrowhead marker to be defined
      that can be used for both the start and end of a path, point in the right
      directions.</p>
    </dd>
  </dl>

  <dl>
    <dt><<angle>></dt>
    <dt><<number>></dt>
    <dd>
      <p>An <<angle>> value represents the angle the marker's
      positive x-axis makes with the positive x-axis in the user space
      of the <a>markable element</a>, and a <<number>> value
      with no unit represents an angle in degrees.  For example, if a value of
      ''0'' is given, then the marker will be drawn
      such that its x-axis will align with the x-axis of the user
      space of the graphic object referencing the marker.
      A value of ''90deg'' will result in the
      marker being drawn with its positive x-axis in the direction
      of the positive y-axis of the <a>markable element</a>'s user space.</p>
    </dd>
  </dl>

  <p>The orientation occurs after the marker has been fitted into its
  viewport.  See the <a href="#MarkerAlgorithm">Details on how markers are rendered</a>
  section below for an illustrative example.</p>
</dd>
<dt>
  <table class="attrdef">
    <tr>
      <th>Name</th>
      <th>Value</th>
      <th>Initial value</th>
      <th>Animatable</th>
    </tr>
    <tr>
      <td><dfn dfn-type=element-attr dfn-for=marker>position</dfn></td>
      <td><<length>> | <<percentage>> | <<number>></td>
      <td>as&#160;if&#160;not&#160;specified</td>
      <td>yes</td>
    </tr>
  </table>
</dt>
<dd>
  <p>If the <a element>marker</a> element is a child of a <a>markable element</a>,
  then the presence of a  attribute indicates that the marker is
  a <a>positioned marker</a> and that it will be painted at the specified
  distance along the path.  If the value is negative or greater than the length
  of the path, then no marker will be painted.  If this attribute is specified on
  a <a element>marker</a> that is not a child of a <a>markable element</a>, then
  it has no effect beyond being exposed in the DOM.</p>
  <p class="issue">Should a negative or greater than path length value be
  an "in error" / "unsupported" value?</p>
</dd>
<dt>
  <table class="attrdef">
    <tr>
      <th>Name</th>
      <th>Value</th>
      <th>Initial value</th>
      <th>Animatable</th>
    </tr>
    <tr>
      <td><dfn dfn-type=element-attr dfn-for=marker>href</dfn></td>
      <td>URL [[URL]]</td>
      <td>as&#160;if&#160;not&#160;specified</td>
      <td>yes</td>
    </tr>
  </table>
</dt>
<dd>
  <p>When a <a element>marker</a> element is being used as a <a>positioned marker</a>,
  the <a element-attr for=marker>href</a> attribute indicates that the <a element>marker</a>
  referenced by the attribute is to be used as the definition of the marker.  The
  graphical content of the referencing <a element>marker</a> element and any of
  its attributes that affect marker processing are ignored.  Authors must not
  place any child graphical content in the referencing <a element>marker</a> or
  specify the <a element-attr>viewBox</a>, <a element-attr>preserveAspectRatio</a>, <a element-attr for=marker>refX</a>,
  <a element-attr for=marker>refY</a>, <a element-attr for=marker>markerUnits</a>, <a element-attr for=marker>markerWidth</a>, <a element-attr for=marker>markerHeight</a>
  or <a element-attr for=marker>orient</a> attributes on it.</p>

  <p class="issue">We should say something about referencing <a element>marker</a>
  elements that have an <a element-attr for=marker>href</a> with the <a>marker properties</a>.
  I suspect we should just allow this.  Whether we want to allow the full
  element-referencing thing that you can do with gradients, with selective
  overriding of attributes, I'm not sure.</p>
</dd>
<dt>
  <table class="attrdef">
    <tr>
      <th>Name</th>
      <th>Value</th>
      <th>Initial value</th>
      <th>Animatable</th>
    </tr>
    <tr>
      <td><dfn dfn-type=element-attr dfn-for=marker>viewBox</dfn></td>
      <td>see prose</td>
      <td>see prose</td>
      <td>see prose</td>
    </tr>
  </table>
</dt>
<dd>
  <p>The <a element-attr for=marker>viewBox</a> attribute is defined be SVG. See ‘<a href="http://www.w3.org/TR/2011/REC-SVG11-20110816/coords.html#PreserveAspectRatioAttribute">The viewBox attribute</a>’ [[!SVG11]].</p>
</dd>
<dt>
  <table class="attrdef">
    <tr>
      <th>Name</th>
      <th>Value</th>
      <th>Initial value</th>
      <th>Animatable</th>
    </tr>
    <tr>
      <td><dfn dfn-type=element-attr dfn-for=marker>preserveAspectRatio</dfn></td>
      <td>see prose</td>
      <td>see prose</td>
      <td>see prose</td>
    </tr>
  </table>
</dt>
<dd>
  <p>The <a element-attr for=marker>preserveAspectRatio</a> attribute is defined be SVG. See ‘<a href="http://www.w3.org/TR/2011/REC-SVG11-20110816/coords.html#PreserveAspectRatioAttribute">The preserveAspectRatio attribute</a>’ [[!SVG11]].</p>
</dd>
</dl>

The contents of the <a element>marker</a> are relative to a new
coordinate system. The <a element-attr for=marker>markerUnits</a> attribute
determines an initial scale factor for transforming the graphics in the marker
into the user coordinate system for the referencing element. An additional set of
transformations might occur if there is a <a element-attr>viewBox</a>
attribute, in which case the coordinate system for the contents of the
<a element>marker</a> will be transformed due to the processing of attributes
<a element-attr>viewBox</a> and <a element-attr>preserveAspectRatio</a>.
If there is no <a element-attr>viewBox</a>
attribute, then the assumed default value for the <a element-attr>viewBox</a>
attribute has the origin of the viewBox coincident with the origin
of the viewport and the width/height of the viewBox the same as the
width/height of the viewport.

The <a href="styling.html#UAStyleSheet">user agent style sheet</a> sets
the 'overflow' property for <a element>marker</a> elements to
''hidden'', which causes a rectangular clipping
path to be created at the bounds of marker's viewport.  Unless the
'overflow' property is overridden, any graphics within the marker which
goes outside of the marker's viewport will be clipped.

<a href="styling.html#SVGStylingProperties">Properties</a> inherit into the
<a element>marker</a> element from its ancestors; properties do <em>not</em>
inherit from the element referencing the <a element>marker</a> element.

Note: By using the ''context-stroke'' value for the 'fill' or 'stroke'
on elements in its definition, a single marker can be designed to match the
style of the element referencing the marker.

<a element>marker</a> elements are only rendered directly
when they are used as children of a <a>markable element</a>
and have a <a element-attr for=marker>position</a> attribute specified.  This causes the
marker to be painted as a <a>positioned marker</a>.  All other
<a element>marker</a> elements are not rendered directly
and must be referenced by one of the <a>marker properties</a>
to be rendered.  The 'display' property does not apply to the
<a element>marker</a> element; thus, <a element>marker</a> elements are not
directly rendered even if the 'display' property is
set to a value other than ''display/none'', and
<a element>marker</a> elements are available for referencing even when the
'display' property on the <a element>marker</a> element or any of its
ancestors is set to ''display/none''.  <a element>marker</a>
elements that are used as <a>positioned markers</a> can simultaneously be referenced
by the <a>marker properties</a> to be used as
<a>segment markers</a> and <a>repeating markers</a>.

<a href="interact.html#EventAttributes">Event attributes</a> and
<a href="svgdom.html#EventListeners">event listeners</a> attached
to the contents of a <a element>marker</a> element are not processed;
only the rendering aspects of <a element>marker</a> elements are
processed.

ISSUE: Make interaction work on <a>positioned markers</a>.

<div class="example">
  <p>The following example shows the use of <a>positioned markers</a> to
  place symbols at particular distances along a path.</p>

  <pre><code class=html>
&lt;svg xmlns="http://www.w3.org/2000/svg"
     width="600" height="200" viewBox="0 0 600 200">

   &lt;defs>
     &lt;marker id="Square" markerWidth="10" markerHeight="10"
             refX="5" refY="5" orient="auto">
       &lt;path d="M 5,1 L 9,5 5,9 1,5 z" fill="#6a9100"/>
     &lt;/marker>
     &lt;marker id="Circle" markerWidth="10" markerHeight="10"
             refX="5" refY="5" orient="auto">
       &lt;circle cx="5" cy="5" r="2" fill="dodgerblue"/>
     &lt;/marker>
   &lt;/defs>

   &lt;path d="M 100,50 C 100,250 500,-50 300,150"
         fill="none" stroke="deeppink" stroke-width="3">
     &lt;marker href="#Square" position="0"/>
     &lt;marker href="#Square" position="100%"/>
     &lt;marker href="#Circle" position="50px"/>
     &lt;marker href="#Circle" position="calc(100% - 50px)"/>
     &lt;marker refX="5" refY="5" position="50%">
       &lt;!-- the cross -->
       &lt;path d="M 3,3 L 7,7 M 3,7 L 7,3"
             fill="none" stroke="black" stroke-width="2"/>
     &lt;/marker>
   &lt;/path>
&lt;/svg>
  </code></pre>

  <div class="figure">
    <img class="bordered" src="images/markers-positioned.svg"
         alt="Image showing the use of positioned markers."/>
    <p class="caption">Child <a element>marker</a> elements are used to position
    two square and two circular markers.  The cross marker is defined inline
    and does not need an ID.</p>
  </div>
</div>


<h2 id="MarkerReferences">Referencing <a element>marker</a> elements</h2>

A number of marker properties allow specifying a <a element>marker</a> using a <<marker-ref>> value.

<div class="definition">
  <dfn id="DataTypeMarkerRef">&lt;marker-ref></dfn> =<br/>
  <div style="margin-left: 2em">
    <<url>> |<br/>
    child |<br/>
    <<child-selector>>
  </div>
</div>

where:

<div class="definition">
  <dfn>&lt;child-selector></dfn> =
  <div style="margin-left: 4em">select(<a href="http://www.w3.org/TR/selectors4/#compound">&lt;compound selector&gt;</a> #)</div>
</div>

Values have the following meaning

<dl dfn-type=value dfn-for=&lt;marker-ref&gt;>
  <dt><<url>></dt>
  <dd>Indicates that the <a element>marker</a> element referenced
  by the <<url>> value will be used.
  If the <a href="linking.html#URLReference">URL reference</a> is not valid
  (e.g., it points to an object that is undefined or the object is not
  a <a element>marker</a> element), then the marker reference is also not
  valid.</dd>

  <dt>''child''</dt>
  <dd>Indicates that the last child <a element>marker</a> element of the
  element where the property is specified will be used.
  If there is no such element, then the reference is not valid.</dd>

  <dt><<child-selector>></dt>
  <dd>Indicates that the first matching descendent <a element>marker</a>
  specified by the <<child-selector>>, applied in the context of the
  element where the property is specified, will be used.
  If no element matches any of the selectors contained in the
  <<child-selector>>>, or the first match is not a <a element>marker</a>, then the reference is not valid.</dd>
</dl>

<h2 id="VertexMarkerProperties">Vertex markers: the 'marker-start',
'marker-mid' and 'marker-end' properties</h2>

<pre class='propdef'>
Name: marker-start, marker-mid, marker-end
Value: none | <<marker-ref>>
Initial: none
Applies to: <a>markable elements</a>
Inherited: yes
Percentages: n/a
Computed value: as specified, but with <<url>> values (that are part of a <<marker-ref>>) made absolute
Media: visual
Animatable: yes
</pre>

The 'marker-start' and 'marker-end' properties are used
to specify the marker that will be drawn at the first and last vertices
of the given <a>markable element</a>, respectively.  'marker-mid'
is used to specify the marker that will be drawn at all other vertices
(i.e., every vertex except the first and last).
Possible values for 'marker-start', 'marker-mid' and
'marker-end' are:

<dl dfn-for=marker-start dfn-type=value>
  <dt><dfn>none</dfn></dt>
  <dd>Indicates that no marker symbol will be drawn at the given
  vertex or vertices.</dd>

  <dt><dfn>&lt;marker-ref></dfn></dt>
  <dd>Indicates that the <a element>marker</a> element referenced
  by the <<marker-ref>> value will be drawn at the given vertex or
  vertices.
  If the reference is not valid, then no marker will be drawn at the given
  vertex or vertices.</dd>
</dl>

For <a element>polygon</a> elements, the last vertex is the same as the first
vertex, and for <a element>path</a> elements that end with a closed subpath, the last
vertex is the same as the first vertex of that final subpath.
In this case, if the value of 'marker-end' is not
''marker-start/none'', then it is possible that two markers
will be rendered on that final vertex.

Note: 'marker-start' and 'marker-end'
refer to the first and last vertex of the entire path, not each subpath.

<div class="example">
  <p>The following example shows a triangular marker symbol used as a
  <a>vertex marker</a> to form an arrowhead at the end of two paths.</p>

  <pre><code class=html>
&lt;svg xmlns="http://www.w3.org/2000/svg"
     width="275" height="200" viewBox="0 0 275 200">
  &lt;defs>
    &lt;marker id="Triangle" viewBox="0 0 10 10" refX="1" refY="5"
            markerUnits="strokeWidth" markerWidth="4" markerHeight="3"
            orient="auto">
      &lt;path d="M 0 0 L 10 5 L 0 10 z" fill="context-stroke"/>
    &lt;/marker>
  &lt;/defs>

  &lt;g fill="none" stroke-width="10" marker-end="url(#Triangle)">
    &lt;path stroke="crimson" d="M 100,75 C 125,50 150,50 175,75"/>
    &lt;path stroke="olivedrab" d="M 175,125 C 150,150 125,150 100,125"/>
  &lt;/g>
&lt;/svg>
  </code></pre>

  <div class="figure">
    <img class="bordered" src="images/marker-rendering.svg"
         alt="Image showing the use of an automatically oriented marker."/>
    <p class="caption">The triangle is placed at the end of the path and
    oriented automatically so that it points in the right direction.
    The use of ''context-stroke'' ensures
    the fill of the triangle matches the stroke of each <a element>path</a>.</p>
  </div>
</div>

<h2 id="SegmentMarkers">Segment markers: the 'marker-segment' property</h2>

<pre class='propdef'>
Name: marker-segment
Value: none | <<marker-ref>>
Initial: none
Applies to: <a>markable elements</a>
Inherited: yes
Percentages: n/a
Computed value: as specified, but with <<url>> values (that are part of a <<marker-ref>>) made absolute
Media: visual
Animatable: yes
</pre>

Note: New in SVG 2. Added to allow automatically placing marker symbols
on path edges, as is common in for example line graphs.

The 'marker-segment' property is used to specify the marker that will
be drawn at the center of each length path segment.  Possible values
are:

<dl dfn-type=value dfn-for=marker-segment>
  <dt><dfn>none</dfn></dt>
  <dd>Indicates that no marker symbol will be drawn at the given
  vertex or vertices.</dd>

  <dt><dfn>&lt;marker-ref></dfn></dt>
  <dd>Indicates that the <a element>marker</a> element referenced
  by the <<marker-ref>> value will be drawn at the center
  of each path segment.
  If the reference is not valid, then no marker will be drawn at the path
  segment centers.</dd>
</dl>

<div class="example">
  <p>The following example shows the use of both <a>vertex markers</a> and
  <a>segment markers</a> to construct a line graph.</p>

  <pre><code class=html>
&lt;svg xmlns="http://www.w3.org/2000/svg" width="400" height="200">

  &lt;marker id="Circle" markerWidth="8" markerHeight="8" refX="4" refY="4"
          markerUnits="userSpaceOnUse">
    &lt;circle cx="4" cy="4" r="3" fill="deeppink"/>
  &lt;/marker>

  &lt;marker id="Cross" markerWidth="10" markerHeight="10" refX="0" refY="0"
          viewBox="-5 -5 10 10" markerUnits="userSpaceOnUse"
          fill="none">
    &lt;path d="M -4,-4 L 4,4 M -4,4 L 4,-4" stroke="white" stroke-width="4"/>
    &lt;path d="M -4,-4 L 4,4 M -4,4 L 4,-4" stroke="black" stroke-width="2"/>
  &lt;/marker>

  &lt;!-- grid lines -->
  &lt;path stroke="#888" d="M 40,20 360,20 M 40,40 360,40 M 40,60 360,60
                         M 40,80 360,80 M 40,100 360,100 M 40,120 360,120
                         M 40,140 360,140 M 40,160 360,160 M 40,180 360,180"/>

  &lt;!-- the graph line -->
  &lt;polyline points="50,100 100,20 150,50 200,130 250,80 300,170 350,100"
            fill="none" stroke="deeppink" stroke-width="2"
            marker="url(#Circle)" marker-segment="url(#Cross)"/>
&lt;/svg>
  </code></pre>

  <div class="figure">
    <img class="bordered" src="images/markers-segment.svg"
         alt="Image showing the use of segment markers."/>
    <p class="caption">Segment markers are used to place crosses at the center
    of each line segment in the line graph.</p>
  </div>
</div>

<h2 id="RepeatingMarkers">Repeating markers: the 'marker-pattern' property</h3>

<pre class='propdef'>
Name: marker-pattern
Value: <<marker-gap>>? <<marker-ref-group>> [ <<marker-gap>> <<marker-gap>> ]* <<marker-gap>>?
Initial: none
Applies to: <a>markable elements</a>
Inherited: yes
Percentages: n/a
Computed value: as specified, but with <<url>> values (that are part of a <<marker-ref>>) made absolute
Media: visual
Animatable: yes
</pre>

where:

<pre class=prod><dfn>&lt;marker-gap></dfn> = <<length>> | <<percentage>> | <<number>></pre>
<pre class=prod><dfn>&lt;marker-ref-group></dfn> = ''marker-pattern/none'' | <<marker-ref>>+</pre>

Note: New in SVG 2. Added to allow markers to be placed along a path
at positions unrelated to the segments used to form the path.

The 'marker-pattern' property is used to specify a pattern
of markers and gaps to be repeated along the length of the <a>markable element</a>.
Values have the following meanings:

<dl>
  <dt><dfn dfn-type=value dfn-for=marker-pattern>none</dfn></dt>
  <dd>Indicates that no marker will be painted at the current
  position along the path.</dd>

  <dt><<marker-gap>></dt>
  <dd>Indicates the length of a gap in the repeated
  pattern of markers.</dd>

  <dt><<marker-ref>></dt>
  <dd>A reference to a <a element>marker</a> that will be placed at the
  current position along the path.  If the reference is not valid, then no
  marker for that <<marker-ref>> will be painted.</dd>
</dl>

If a value other than ''marker-pattern/none'' is given,
and the sum of the <<length>>s, <<percentage>>s
and <<number>>s is not positive, then it is an
<a href="http://www.w3.org/TR/SVG2/intro.html#TermInvalidValue">invalid value</a>.</p>

Unlike <a>vertex markers</a>, the orientation of an ''orient="auto"''
<a>repeating marker</a> that happens to lie on a vertex does not take into
account the incoming and outgoing directions.  Instead, it is simply oriented
such that its positive x-axis is aligned with the direction of the path
at its position.

<div class="example">
  <p>The following example shows the use of the 'marker-pattern' property
  to specify a repeating pattern of two different markers spaced along a
  path.</p>

  <pre><code class=html>
&lt;svg xmlns="http://www.w3.org/2000/svg" width="600" height="200">

  &lt;marker id="DoubleDash" markerWidth="8" markerHeight="12" refX="0" refY="0"
          viewBox="-4 -6 8 12" markerUnits="userSpaceOnUse" orient="auto">
    &lt;rect x="-3" y="-5" width="2" height="10"/>
    &lt;rect x="1" y="-5" width="2" height="10"/>
  &lt;/marker>
  &lt;marker id="SingleDash" markerWidth="4" markerHeight="12" refX="0" refY="0"
          viewBox="-2 -6 4 12" markerUnits="userSpaceOnUse" orient="auto">
    &lt;rect x="-1" y="-5" width="2" height="10"/>
  &lt;/marker>

  &lt;path d="M 50,100 S 100,132 150,86 200,173 250,76 300,81
                      350,136 400,87 450,166 500,87 550,96"
        stroke="deeppink" stroke-width="2" fill="none"
        marker-pattern="40 url(#DoubleDash) 40 url(#SingleDash)"/>
&lt;/svg>
  </code></pre>

  <div class="figure">
    <img class="bordered" src="images/markers-repeating.svg"
         alt="Image showing the use of repeating markers."/>
    <p class="caption">Markers specified with the 'marker-pattern' property
    are placed along the path at fixed distances, not relative to the path
    vertices.</p>
  </div>
</div>


<h2 id="MarkerShorthand">Marker shorthand: the 'marker' property</h2>

<pre class='propdef'>
Name: marker
Value: <div>[ none | <<marker-ref>> ]{1,4} [ / 'marker-pattern' ]? </div><div style="margin-left: 2em"> | <<marker-ref>>{0,4} [ <<length>> | <<percentage>> | <<number>> ] [ <<length>> | <<percentage>> | <<number>> | <<marker-ref>> ]*</div>
Initial: none
Applies to: <a>markable elements</a>
Inherited: no
Percentages: see individual properties
Computed value: see individual properties
Media: visual
Animatable: see individual properties
</pre>

The 'marker' property sets values for the
'marker-start', 'marker-mid', 'marker-end',
'marker-segment' and 'marker-pattern' properties.
Values for have the following meanings:

<dl>
  <dt>''marker-pattern/none'' | <<marker-ref>></dt>
  <dd>Sets 'marker-start', 'marker-mid' and 'marker-end'
  to the specified value, and sets 'marker-segment' and
  'marker-pattern' to ''marker-pattern/none''.</dd>

  <dt>[ ''marker-pattern/none'' | <<marker-ref>> ]{2}</dt>
  <dd>Sets 'marker-start' and 'marker-end' to the two
  values specified, and sets 'marker-mid', 'marker-segment' and
  'marker-pattern' to ''marker-pattern/none''.</dd>

  <dt>[ ''marker-pattern/none'' | <<marker-ref>> ]{3}</dt>
  <dd>Sets 'marker-start', 'marker-mid' and 'marker-end' to
  the three values specified, and sets 'marker-segment' and
  'marker-pattern' to ''marker-pattern/none''.</dd>

  <dt>[ ''marker-pattern/none'' | <<marker-ref>> ]{4}</dt>
  <dd>Sets 'marker-start', 'marker-segment', 'marker-mid'
  and 'marker-end' to the four <<marker-ref>> values
  specified, and sets 'marker-pattern' to
  ''marker-pattern/none''.</dd>

  <dt>[ ''marker-pattern/none'' | <<marker-ref>> ]{1,4} / 'marker-pattern'</dt>
  <dd>Sets 'marker-start', 'marker-segment', 'marker-mid'
  and 'marker-end' to the four <<marker-ref>> values
  specified before the slash, and sets 'marker-pattern' to
  the value after the slash.</dd>

  <dt>anything else</dt>
  <dd>Sets 'marker-start', 'marker-segment', 'marker-mid'
  and 'marker-end' to ''marker-start/none'',
  and sets 'marker-pattern' to the specified value.</dd>
</dl>

<h2 id="MarkerKnockout">Knocking out the stroke: the 'marker-knockout-left' and 'marker-knockout-right' properties</h2>

ISSUE: The marker knockout properties are still under heavy development
and are subject to change. Feedback on how authors might prefer to specify marker
knockout shapes is welcome.

<pre class='propdef'>
Name: marker-knockout-left, marker-knockout-right
Value: <<knockout-offset>> | <<knockout-shape>> [ at <<knockout-offset>> ]?
Initial: 0
Applies to: <a element>marker</a>
Inherited: no
Percentages: see prose
Computed value: as specified
Media: visual
Animatable: yes
</pre>

where:

<pre class=prod><dfn>&lt;knockout-offset></dfn> = <<length>> | <<percentage>> | <<number>></pre>

<pre class=prod><dfn>&lt;knockout-shape></dfn> =
    [ <<length>> | <<percentage>> | <<number>> ] inverted? circle |
    [ <<length>> | <<percentage>> | <<number>> ]{2} inverted? ellipse |
    [ <<length>> | <<percentage>> | <<number>> ]{1,2} inverted? [ rectangle | triangle ]
</pre>


Note: New in SVG 2.  Added to allow authors to specify
parts of a stroke that should be clipped away when a marker is
placed on a path.  This helps with arrowheads, where the stroke
must not be visible behind the pointy end, and with hollow markers
as seen in metro maps, where the center of a marker is transparent
and the stroke should not show through.

When specified on a <a element>marker</a> element, the
'marker-knockout-left' and 'marker-knockout-right' properties
together specify a shape to clip away when when painting the stroke of an
element that uses the marker.  'marker-knockout-left' specifies the
left side of the shape and 'marker-knockout-right' the right side.
These two sides are joined together with straight lines.

The <<knockout-offset>> part of the value, if specified,
is the offset from the marker position, outwards, along the tangent,
that the knockout shape side is placed at.  This is the <em>knockout shape
side position</em>.  If it is omitted, then the offset is assumed to be zero.
The value can be negative.  Percentage values refer to the width of the marker
contents viewport.

The <<knockout-shape>> part of the value, if specified,
is the left or right side of the knockout shape. Values have the
following meanings:

<dl>
  <dt>[ <<length>> | <<percentage>> | <<number>> ]{2} inverted? ellipse</dt>
  <dd>
    <p>The knockout shape side is an arc.  The lengths or percentages specified
    are the x-radius and y-radius of the ellipse from which the arc is taken.
    A length is interpreted as being in the marker contents coordinate system.
    If the first value is a percentage, then it refers to the width of the
    marker contents viewport, and if the second value is a percentage then
    it refers to the height of the marker contents viewport.</p>

    <p>If the ''inverted'' keyword is not specified,
    then the arc is constructed by placing the center of the ellipse at the knockout
    shape side position.  First we consider only the 180° arc of the ellipse which
    points in the direction of the start of the start of the path, if this is
    the left knockout shape side, or the end of the path if this is the right knockout
    shape side.  If the y-radius is less than or equal to half of the stroke width of
    the path the marker is on, then this 180° arc is the final knockout shape side.
    Otherwise, we intersect the arc with the two lines that are offset, by half
    of the stroke width, from the tangent to the marker orientation.
    The resulting arc with its start and end points on these two lines is the
    final knockout shape side.</p>

    <p>If the ''inverted'' keyword <em>is</em> specified,
    then the arc is constructed by placing the center of the ellipse at a distance
    of two times its x-radius along the tangent to the marker orientation,
    in the direction of the start of the path if this is the left knockout shape
    side, or the end of the path if this is the right knockout shape side.
    We consider only the 180° arc of the ellipse that is pointing in the opposite
    direction.  If the y-radius is less or equal to half of the stroke width
    of the path the marker is on, then this 180° arc is the final knockout shape
    side.  Otherwise, we intersect the arc with the two lines that are offset,
    by half of the stroke width, from the tangent to the marker orientation.
    The resulting arc with its side and end points on these two lines
    is the final knockout shape side.</p>
  </dd>

  <dt>[ <<length>> | <<percentage>> | <<number>> ] inverted? circle</dt>
  <dd>
    <p>The knockout shape side is an arc.  The shape is computed in the same
    way as the ''ellipse'' shape, but with
    both radii of the ellipse being the specified length or percentage,
    and with a percentage referring to the size of the marker contents viewport.</p>
  </dd>

  <dt>[ <<length>> | <<percentage>> | <<number>> ]{1,2} inverted? rectangle</dt>
  <dd>
    <p>The knockout shape side comprises one or two rectangles.  These
    rectangles are aligned such that their top and bottom edges are
    parallel to the tangent to the marker orientation.
    The length or percentage is a width and the second, if specified,
    is a height.  Percentage values here refer to the width and height
    of the marker contents viewport, respectively.</p>

    <p>If the ''inverted'' keyword is not specified,
    then the knockout shape side is a single rectangle.  The width of the
    rectangle is the specified width value.  The height of the rectangle is the maximum
    of the stroke width of the path on which the marker exists and the specified
    height value, if it is specified.  If it is not specified, then the height of the
    rectangle is just the stroke width.
    The rectangle is posisioned such that the center of its right hand edge
    is positioned at the knockout shape side position
    and the extent of its width is in the direction of the start of the path,
    if this is the left knockout shape side, or the end of the path if this
    is the right knockout shape side.</p>

    <p>If the ''inverted'' keyword is specified,
    then the knockout shape side comprises two rectangles.  If the specified
    height is greater than or equal to the stroke width, then the height
    of these rectangles is zero; otherwise, their heights are half of the
    difference between the stroke width and the specified height.  The
    top edge of one of the rectangles is half of the stroke width away
    from the marker orientation tangent line, with its bottom edge closer to the tangent line.
    The other rectangle has its bottom edge half of the stroke width
    away from the tangent line and its top edge closer to the tangent line.
    The right edges of the rectangles are aligned with each other and
    also with the line perpendicular to the marker orientation tangent line.
    The extent of the widths of the rectangles is in the direction
    of the start of the path, if this is the left knockout shape side,
    or the end of the path if this is the right knockout shape side.</p>
  </dd>

  <dt>[ <<length>> | <<percentage>> | <<number>> ]{1,2} inverted? [ rectangle | triangle ]</dt>
  <dd>
    <p>The knockout shape side comprises one or two rectangles.  These
    rectangles are aligned such that their top and bottom edges are
    parallel to the tangent to the marker orientation.
    The length or percentage is a width and the second, if specified,
    is a height.  Percentage values here refer to the width and height
    of the marker contents viewport, respectively.</p>

    <p>If the ''inverted'' keyword is not specified,
    then the knockout shape side is a single rectangle.  The width of the
    rectangle is the specified width value.  The height of the rectangle is the maximum
    of the stroke width of the path on which the marker exists and the specified
    height value, if it is specified.  If it is not specified, then the height of the
    rectangle is just the stroke width.
    The rectangle is positioned such that the center of its right hand edge
    is positioned at the knockout shape side position
    and the extent of its width is in the direction of the start of the path,
    if this is the left knockout shape side, or the end of the path if this
    is the right knockout shape side.</p>

    <p>If the ''inverted'' keyword is specified,
    then the knockout shape side comprises two rectangles.  If the specified
    height is greater than or equal to the stroke width, then the height
    of these rectangles is zero; otherwise, their heights are half of the
    difference between the stroke width and the specified height.  The
    top edge of one of the rectangles is half of the stroke width away
    from the marker orientation tangent line, with its bottom edge closer to the tangent line.
    The other rectangle has its bottom edge half of the stroke width
    away from the tangent line and its top edge closer to the tangent line.
    The right edges of the rectangles are aligned with each other and
    also with the line perpendicular to the marker orientation tangent line.
    The extent of the widths of the rectangles is in the direction
    of the start of the path, if this is the left knockout shape side,
    or the end of the path if this is the right knockout shape side.</p>
  </dd>

  <dt>[ <<length>> | <<percentage>> | <<number>> ]{1,2} inverted? triangle</dt>
  <dd>
    <p class="issue">...</p>
  </dd>
</dl>

ISSUE: A diagram showing the construction of these shapes
would be helpful.

ISSUE: Need to define how the two shape sides are joined together.
It's taking the top and bottom points from both shapes, drawing vertical
lines to the edge of the stroke shape, then drawing two horizontal lines
to join them together.

The two knockout shape sides must not intersect, although they may
touch.  If they do intersect, then no knockout is performed for that
marker when painting the stroke.

Note: For example, using ''8px inverted triangle at -4px'' for 'marker-knockout-left' and
''8px triangle'' for 'marker-knockout-right'
is allowed, as the two straight lines that form the left shape side do not intersect
with either of the two straight lines that form the right shape side.
However, using ''8px triangle at -4px'' for
both properties would obviously cause an intersection, and so would not
be allowed.</p>

<div class="figure">
  <img class="bordered" src="images/knockout-shapes.svg" style="max-width: none"
       alt="Image showing various marker knockout shapes."/>
  <p class="caption">An illustration of the use of inverted and non-inverted circle,
  rectangle and triangle knockout shapes, at both 0px and 10px offsets.
  The value beneath each pink stroke is used for both 'marker-knockout-left'
  and 'marker-knockout-right'.  (The marker itself here has no
  content and does not render anything.)</p>
</div>

<div class="issue">
  <p>While this is nice for straight line segments, if the
  path is curved at the marker position then it might be preferable to
  have the knockout shapes aligned with the tangent at the knockout shape
  side position, rather than with the marker orientation.  Especially
  if the knockout is being used as a fancy dash pattern.  Then we would
  likely want to join the left and right sides of the shape with a curved
  shape (along the stroke) and not just a rectangle.  If we allow this,
  then computing that shape is going to be hard, and will mean that
  determining whether the left and right sides of the knockout shape
  intersect, and determining what the intersections of all of the knockout shapes
  on a path are, is also going to be hard.  Perhaps that can be handled by
  extending dashing line caps with these shapes rather than here?  Regardless of
  whether it is handled by marker knockouts or new line caps, it's going
  to be non-trivial to compute the right shapes.</p>

  <p>Another thing to note is that knockouts here are like setting up
  a clipping path to remove parts of the stroke when it's painted.  That
  means that if the stroke intersects itself over the knockout areas,
  it's going to be knocked out of all bits of the stroke that go
  through those areas.  That may or may not be fine depending on
  your use cases.</p>
</div>


<h2 id="MarkerAlgorithm">Details on how markers are rendered</h2>

Markers are drawn after the given object is filled and stroked.

For each marker that is drawn, a temporary new user coordinate
system is established so that the marker will be positioned and sized
correctly, as follows:

<ul>
  <li>The axes of the temporary new user coordinate system are aligned
  according to the <a element-attr for=marker>orient</a> attribute on the
  <a element>marker</a> element and the slope of the curve at the given vertex.
  (Note: if there is a discontinuity at a vertex, the slope is the
  average of the slopes of the two segments of the curve that join
  at the given vertex. If a slope cannot be determined, the slope is
  assumed to be zero.)</li>

  <li>A temporary new coordinate system is established by attribute
  <a element-attr for=marker>markerUnits</a>. If
  <a element-attr for=marker>markerUnits</a> equals
  ''markerUnits/strokeWidth'', then the temporary new
  user coordinate system is the result of scaling the current
  user coordinate system by the current value of property
  'stroke-width'. If <a element-attr for=marker>markerUnits</a> equals
  ''userSpaceOnUse'', then no extra scale transformation is applied.</li>

  <li>An additional set of transformations might occur if the
  <a element>marker</a> element includes a <a element-attr>viewBox</a> attribute, in
  which case additional transformations are set up to produce the necessary
  result due to attributes <a element-attr>viewBox</a> and
  <a element-attr>preserveAspectRatio</a>.</li>

  <li>If the 'overflow' property on the <a element>marker</a> element
  indicates that the marker needs to be clipped to its viewport, then an
  implicit clipping path is established at the bounds of the viewport.</li>
</ul>

The rendering effect of a marker is as if the contents of the
referenced <a element>marker</a> element were deeply cloned
into a separate non-exposed DOM tree for each instance of the
marker. Because the cloned DOM tree is non-exposed, the SVG DOM
does not show the cloned instance of the marker.

For user agents that support <a href="styling.html#StylingWithCSS">Styling
with CSS</a>, the conceptual deep cloning of the referenced
<a element>marker</a> element into a non-exposed DOM tree also
copies any property values resulting from
<a href="http://www.w3.org/TR/2011/REC-CSS2-20110607/cascade.html">the CSS cascade</a>
([<a href="refs.html#ref-CSS21">CSS21</a>], chapter 6) and
property inheritance on the referenced element and its contents. CSS 2.1
selectors can be applied to the original (i.e., referenced) elements
because they are part of the formal document structure. CSS 2.1 selectors
cannot be applied to the (conceptually) cloned DOM tree because its
contents are not part of the formal document structure.

<div class=example>
  <p>For illustrative purposes, we'll repeat the marker example shown earlier:</p>

  <pre><code class=html>
&lt;?xml version="1.0" standalone="no"?&gt;
&lt;svg width="4in" height="2in"
     viewBox="0 0 4000 2000"
     xmlns="http://www.w3.org/2000/svg"&gt;
  &lt;defs&gt;
    &lt;marker id="Triangle"
      viewBox="0 0 10 10" refX="0" refY="5"
      markerUnits="strokeWidth"
      markerWidth="4" markerHeight="3"
      orient="auto"&gt;
      &lt;path d="M 0 0 L 10 5 L 0 10 z" /&gt;
    &lt;/marker&gt;
  &lt;/defs&gt;
  &lt;rect x="10" y="10" width="3980" height="1980"
       fill="none" stroke="blue" stroke-width="10" /&gt;
  &lt;desc&gt;Placing an arrowhead at the end of a path.
  &lt;/desc&gt;
  &lt;path d="M 1000 750 L 2000 750 L 2500 1250"
        fill="none" stroke="black" stroke-width="100"
        marker-end="url(#Triangle)"  /&gt;
&lt;/svg&gt;
  </code></pre>
</div>

<div class=example>
  <p>The rendering effect of the above file will be visually identical to
  the following:</p>

  <pre><code class=html>
&lt;?xml version="1.0" standalone="no"?&gt;
&lt;svg width="4in" height="2in"
     viewBox="0 0 4000 2000"
     xmlns="http://www.w3.org/2000/svg"&gt;
  &lt;desc&gt;File which produces the same effect
      as the marker example file, but without
      using markers.
  &lt;/desc&gt;
  &lt;rect x="10" y="10" width="3980" height="1980"
       fill="none" stroke="blue" stroke-width="10" /&gt;
  &lt;!-- The path draws as before, but without the marker properties --&gt;
  &lt;path d="M 1000 750 L 2000 750 L 2500 1250"
        fill="none" stroke="black" stroke-width="100"  /&gt;
  &lt;!-- The following logic simulates drawing a marker
       at final vertex of the path. --&gt;
  &lt;!-- First off, move the origin of the user coordinate system
       so that the origin is now aligned with the end point of the path. --&gt;
  <strong>&lt;g transform="translate(2500,1250)" &gt;</strong>
    &lt;!-- Rotate the coordinate system 45 degrees because
         the marker specified orient="auto" and the final segment
         of the path is going in the direction of 45 degrees. --&gt;
    <strong>&lt;g transform="rotate(45)" &gt;</strong>
      &lt;!-- Scale the coordinate system to match the coordinate system
           indicated by the 'markerUnits' attributes, which in this case has
           a value of 'strokeWidth'. Therefore, scale the coordinate system
           by the current value of the 'stroke-width' property, which is 100. --&gt;
      <strong>&lt;g transform="scale(100)" &gt;</strong>
        &lt;!-- Translate the coordinate system by
             (-refX*viewBoxToMarkerUnitsScaleX, -refY*viewBoxToMarkerUnitsScaleY)
             in order that (refX,refY) within the marker will align with the vertex.
             In this case, we use the default value for preserveAspectRatio
             ('xMidYMid meet'), which means find a uniform scale factor
             (i.e., viewBoxToMarkerUnitsScaleX=viewBoxToMarkerUnitsScaleY)
             such that the viewBox fits entirely within the viewport ('meet') and
             is center-aligned ('xMidYMid'). In this case, the uniform scale factor
             is markerHeight/viewBoxHeight=3/10=.3. Therefore, translate by
             (-refX*.3,-refY*.3)=(0*.3,-5*.3)=(0,-1.5). --&gt;
        <strong>&lt;g transform="translate(0,-1.5)" &gt;</strong>
          &lt;!-- There is an implicit clipping path because the user agent style
               sheet says that the 'overflow' property for markers has the value
               'hidden'. To achieve this, create a clipping path at the bounds
               of the viewport. Note that in this case the viewport extends
               0.5 units to the left and right of the viewBox due to
               a uniform scale factor, different ratios for markerWidth/viewBoxWidth
               and markerHeight/viewBoxHeight, and 'xMidYMid' alignment --&gt;
          <strong>&lt;clipPath id="cp1" &gt;
            &lt;rect x="-0.5" y="0" width="4" height="3" /&gt;
          &lt;/clipPath&gt;</strong>
          <strong>&lt;g clip-path="url(#cp1)" &gt;</strong>
            &lt;!-- Scale the coordinate system by the uniform scale factor
                 markerHeight/viewBoxHeight=3/10=.3 to set the coordinate
                 system to viewBox units. --&gt;
            <strong>&lt;g transform="scale(.3)" &gt;</strong>
              &lt;!-- This 'g' element carries all property values that result from
                   cascading and inheritance of properties on the original 'marker' element.
                   In this example, neither fill nor stroke was specified on the 'marker'
                   element or any ancestors of the 'marker', so the initial values of
                   "black" and "none" are used, respectively. --&gt;
             <strong>&lt;g fill="black" stroke="none" &gt;</strong>
                &lt;!-- Expand out the contents of the 'marker' element. --&gt;
                <strong>&lt;path d="M 0 0 L 10 5 L 0 10 z" /&gt;</strong>
              <strong>&lt;/g&gt;</strong>
            <strong>&lt;/g&gt;</strong>
          <strong>&lt;/g&gt;</strong>
        <strong>&lt;/g&gt;</strong>
      <strong>&lt;/g&gt;</strong>
    <strong>&lt;/g&gt;</strong>
  <strong>&lt;/g&gt;</strong>
&lt;/svg&gt;
  </code></pre>

  <p class="view-as-svg"><a href="images/marker-simulated.svg">View this example as SVG (SVG-enabled browsers only)</a></p>
</div>
