Fixed Stroke Width Calculation

狂风中的少年 提交于 2019-12-25 12:49:34

问题


I would like to have a fixed stroke width into my views using the SVG tag. I mean, having the strokes 1 pixel wide no matter the scale transformations.

It seems the vector-effect="non-scaling-stroke" property approach is still not supported in Edge/IE, so I am thinking about calculating this manually.

If I discover the scaling factor of the viewbox, then I will be able to calculate a fixed stroke width.

How can I get this "scaling factor"?

<svg version="1.1"
    baseProfile="full"
    width="100%" height="Auto"
    viewBox="0 0 @sheet.SheetShape.Bounds.Width @sheet.SheetShape.Bounds.Height"
    xmlns="http://www.w3.org/2000/svg">

<rect width="100%" height="100%" stroke="red" fill="white" />

@foreach (var cut in sheet.SheetCuts)
{
    <line stroke-width="2" stroke="black" stroke-dasharray="5, 5" x1=@cut.Start.X y1=@cut.Start.Y x2=@cut.End.X y2=@cut.End.Y />
}
</svg>

Thank you,

来源:https://stackoverflow.com/questions/44114996/fixed-stroke-width-calculation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!