In my current project, I am developing an interactive application that allows for direct manipulation of shapes through SVG. To illustrate a specific issue, let's take a look at how a star is rendered in Chrome.
When experimenting with different values of stroke-dasharray
, it becomes evident that the strokes on the arms of this star appear inconsistent. Some edges are blunt while others are sharp. Although adjusting stroke-linejoin
can change the appearance of the star, it does not completely address the inconsistency across all arms.
<svg width="800" height="600" xmlns="http://www.w3.org/2000/svg">
<polygon stroke="red"
stroke-width="20"
stroke-dasharray="5 5"
points="350,75 379,161 469,161 397,215
423,301 350,250 277,301 303,215
231,161 321,161" />
</svg>
https://i.sstatic.net/1Glil.png
While adjusting each arm's stroke using stroke-dashoffset
might achieve consistency in this scenario, it seems challenging to make sharp turns in strokes appear consistent in a more general context considering how stroke-dasharray
operates. However, there is pressure from my team to find a solution to ensure consistency in stroke appearance, so I need to explore this further.
Therefore, I want to confirm: Is there a universal solution to ensure strokes appear consistent around sharp corners when utilizing stroke-dasharray
?