问题标签 [svg-marker]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
2 回答
84316 浏览

svg - How to place multiple evenly-spaced arrowheads along an SVG line?

I am new to SVG and I am trying to draw a straight line between two points. I managed so far by using this command:

<line x1="50" y1="50" x2="150" y2="150" style="stroke:rgb(255,255,0); stroke-width:2" stroke-dasharray="5,3" />"

What is the simplest way to add tiny triangles or arrow heads (evenly spaced) over this line in order to indicate the direction?

Edit 1:

Just to be more clear, I am not after an arrow at the end of the line, but multiple triangles (evenly spaced) along the whole line. If possible, I would like to replace each dash in the dashed line with a triangle pointing in the direction of the line.

Edit 2

Based on Phrogz' suggestion, I created a page as shown below, but nothing is showing up. What am I doing wrong?

0 投票
0 回答
67 浏览

svg - SVG 标记上下文填充失败

SVG 标记填充无法按照https://svgwg.org/specs/markers/中的说明工作。

箭头的预期颜色是深红色和橄榄色,但都是黑色。知道是否有解决方案吗?