Unverified Commit 13d66a39 authored by mrbean-bremen's avatar mrbean-bremen
Browse files

Handle dasharray with odd number of elements by repeating them

- fixes #58
parent b2357c33
...@@ -251,6 +251,11 @@ namespace Svg ...@@ -251,6 +251,11 @@ namespace Svg
{ {
if (this.StrokeDashArray != null && this.StrokeDashArray.Count > 0) if (this.StrokeDashArray != null && this.StrokeDashArray.Count > 0)
{ {
if (this.StrokeDashArray.Count % 2 != 0)
{
// 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.*/ /* 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)) / 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(); ((strokeWidth <= 0) ? 1 : strokeWidth)).ToArray();
......
...@@ -50,6 +50,7 @@ painting-fill-05-b ...@@ -50,6 +50,7 @@ painting-fill-05-b
painting-stroke-01-t painting-stroke-01-t
painting-stroke-02-t painting-stroke-02-t
painting-stroke-04-t painting-stroke-04-t
painting-stroke-06-t
painting-stroke-09-t painting-stroke-09-t
painting-stroke-10-t painting-stroke-10-t
paths-data-01-t paths-data-01-t
......
...@@ -39,6 +39,7 @@ masking-path-06-b.svg ...@@ -39,6 +39,7 @@ masking-path-06-b.svg
masking-path-03-b.svg masking-path-03-b.svg
metadata-example-01-t.svg metadata-example-01-t.svg
painting-control-04-f.svg painting-control-04-f.svg
painting-stroke-06-t.svg
painting-stroke-09-t.svg painting-stroke-09-t.svg
painting-stroke-10-t.svg painting-stroke-10-t.svg
pservers-grad-01-b.svg pservers-grad-01-b.svg
......
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