How to reuse <marker> defined in <defs> tag with different dimensions?

Viewed 56

Say I have a defined in tag contained in tag like:

<svg>
    <defs>
        <marker markerUnits="userSpaceOnUse" markerWidth="16" markerHeight="16">
            ...
        </marker>
    </defs>
</svg>

Notice that markerUnits, markerWidth and markerHeight have been applied so that the size of the marker will be irrelevant with how thick the path being applied with the marker is.

But it seems that width and height are hard coded and I have no chance to set the dimension of the marker when I apply it with marker-end or marker-start.

Is there a way to reuse the marker with dimension customization?

1 Answers

No. Markers of type markerUnits="userSpaceOnUse" are rendered exactly as defined. You can't set their size at each usage.

The only alternative is to use markerUnits="strokeWidth" markers. They are scaled to match the stroke-width value.

Related