blob: c80f180a34fb6383c5152c35309ecb52b2dd13da [file] [log] [blame]
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1 Basic//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-basic.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" id="svg-root" width="100%" height="100%" viewBox="0 0 480 360" onload="createMarker()">
<defs id="defs">
<marker id="markerStart" viewBox="0 0 10 10" markerWidth="2" markerHeight="2" refX="5" refY="5" markerUnits="strokeWidth">
<rect width="10" height="10" fill="red" stroke="none"/>
</marker>
<marker id="markerEnd" viewBox="0 0 10 10" markerWidth="2" markerHeight="2" refX="5" refY="5" markerUnits="strokeWidth">
<path d="M 5 0 L 10 10 L 0 10 Z" fill="blue" stroke="none"/>
</marker>
</defs>
<g id="content"/>
<script>
var defs = document.getElementById("defs");
var content = document.getElementById("content");
function createObject()
{
var path = document.createElementNS("http://www.w3.org/2000/svg", "path");
path.setAttribute("fill", "none");
path.setAttribute("stroke", "black");
path.setAttribute("stroke-width", "8");
path.setAttribute("marker-start", "url(#markerStart)");
path.setAttribute("marker-mid", "url(#markerMiddle)");
path.setAttribute("marker-end", "url(#markerEnd)");
path.setAttribute("d", "M 130 135 L 180 135 L 180 185");
content.appendChild(path);
}
function createMarker()
{
createObject();
var marker = document.createElementNS("http://www.w3.org/2000/svg", "marker");
marker.setAttribute("id", "markerMiddle");
marker.setAttribute("viewBox", "0 0 10 10");
marker.setAttribute("markerWidth", "2");
marker.setAttribute("markerHeight", "2");
marker.setAttribute("refX", "5");
marker.setAttribute("refY", "5");
marker.setAttribute("markerUnits", "strokeWidth");
var circle = document.createElementNS("http://www.w3.org/2000/svg", "circle");
circle.setAttribute("cx", "5");
circle.setAttribute("cy", "5");
circle.setAttribute("r", "5");
circle.setAttribute("fill", "green");
circle.setAttribute("stroke", "none");
marker.appendChild(circle);
defs.appendChild(marker);
}
</script>
</svg>