Commit 6964ca91 authored by heindlalex's avatar heindlalex Committed by mrbean-bremen
Browse files

Fix issue with percentage unit in "stroke-width", now taken from the viewbox...

Fix issue with percentage unit in "stroke-width", now taken from the viewbox width/height normalised diagonale for x/y elements e.g. circle
Test images and svg under #338
parent 13d66a39
...@@ -164,6 +164,14 @@ namespace Svg ...@@ -164,6 +164,14 @@ namespace Svg
case UnitRenderingType.VerticalOffset: case UnitRenderingType.VerticalOffset:
_deviceValue = (size.Height / 100) * value + boundable.Location.Y; _deviceValue = (size.Height / 100) * value + boundable.Location.Y;
break; break;
case UnitRenderingType.Other:
// Calculate a percentage value of the normalized viewBox diagonal length.
if (owner.OwnerDocument != null && owner.OwnerDocument.ViewBox != null && owner.OwnerDocument.ViewBox.Width!=0 && owner.OwnerDocument.ViewBox.Height != 0)
{
_deviceValue = (float)(Math.Sqrt(Math.Pow(owner.OwnerDocument.ViewBox.Width, 2) + Math.Pow(owner.OwnerDocument.ViewBox.Height, 2)) / Math.Sqrt(2) * value / 100.0);
}
else _deviceValue = (float)(Math.Sqrt(Math.Pow(size.Width, 2) + Math.Pow(size.Height, 2)) / Math.Sqrt(2) * value / 100.0);
break;
default: default:
_deviceValue = (float)(Math.Sqrt(Math.Pow(size.Width, 2) + Math.Pow(size.Height, 2)) / Math.Sqrt(2) * value / 100.0); _deviceValue = (float)(Math.Sqrt(Math.Pow(size.Width, 2) + Math.Pow(size.Height, 2)) / Math.Sqrt(2) * value / 100.0);
break; break;
......
<svg width="600" height="200" viewBox="0 0 30 10" xmlns="http://www.w3.org/2000/svg">
<!-- Default stroke width: 1 -->
<circle cx="5" cy="5" r="3" stroke="green"
stroke-width="1" />
<!-- Stroke width as a number -->
<circle cx="15" cy="5" r="3" stroke="green"
stroke-width="0.5" />
<!-- Stroke width as a percentage -->
<circle cx="25" cy="5" r="3" stroke="green"
stroke-width="2%" />
</svg>
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment