Commit 4edc3ea2 authored by mrbean-bremen's avatar mrbean-bremen Committed by mrbean-bremen
Browse files

Added handling of rounded caps for dashed lines using dasharray

- fixes #191
parent 1653f010
......@@ -256,10 +256,27 @@ namespace Svg
// handle odd dash arrays by repeating them once
this.StrokeDashArray.AddRange(this.StrokeDashArray);
}
/* divide by stroke width - GDI behaviour that I don't quite understand yet.*/
pen.DashPattern = this.StrokeDashArray.ConvertAll(u => ((u.ToDeviceValue(renderer, UnitRenderingType.Other, this) <= 0) ? 1 : u.ToDeviceValue(renderer, UnitRenderingType.Other, this)) /
((strokeWidth <= 0) ? 1 : strokeWidth)).ToArray();
if (this.StrokeLineCap == SvgStrokeLineCap.Round)
{
// to handle round caps, we have to adapt the dash pattern
// by increasing the dash length by the stroke width - GDI draws the rounded
// edge inside the dash line, SVG draws it outside the line
var pattern = new float[pen.DashPattern.Length];
int offset = 1; // the values are already normalized to dash width
for ( int i = 0; i < pen.DashPattern.Length; i++)
{
pattern[i] = pen.DashPattern[i] + offset;
offset *= -1; // increase dash length, decrease spaces
}
pen.DashPattern = pattern;
pen.DashCap = DashCap.Round;
}
if (this.StrokeDashOffset != null && this.StrokeDashOffset.Value != 0)
{
pen.DashOffset = ((this.StrokeDashOffset.ToDeviceValue(renderer, UnitRenderingType.Other, this) <= 0) ? 1 : this.StrokeDashOffset.ToDeviceValue(renderer, UnitRenderingType.Other, this)) /
......
......@@ -174,6 +174,7 @@ __issue-109-01
__issue-116-01
__issue-123-01
__issue-143-01
__issue-191-01
__issue-202-01
__issue-214-01
__issue-227-01
......
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