New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle overlapping caps by joining the lines #510
Conversation
@H1Gdev - please have a look! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{ | ||
if (this.StrokeDashArray.Count % 2 != 0) | ||
strokeWidth = strokeWidth <= 0 ? 1 : strokeWidth; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What this condition is or will be true in case ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has been used below twice - I just factored out for better readability of the code where it is used.
It seems to make sure that stroke width is set to 1 if StrokeWidth is invalid.
/* divide by stroke width - GDI behaviour that I don't quite understand yet.*/ | ||
pen.DashPattern = this.StrokeDashArray.Select(u => ((u.ToDeviceValue(renderer, UnitRenderingType.Other, this) <= 0) ? 1 : u.ToDeviceValue(renderer, UnitRenderingType.Other, this)) / | ||
((strokeWidth <= 0) ? 1 : strokeWidth)).ToArray(); | ||
SvgUnit dashOffset = StrokeDashOffset != null ? StrokeDashOffset : 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use var
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I tried that and it doesn't work with 0 - but I will check again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use SvgUnit.Empty
!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, turns out it works with 0 too - I was wrong!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
{ | ||
// add the next dash segment to the current one | ||
dashPattern[i - 1] += dashPattern[i] + dashPattern[i + 1]; | ||
dashPattern[i] = dashPattern[i + 2]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note to self: this line can be incorporated into the loop below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
@H1Gdev - thanks for the review!
Yes - nothing we can do about that 😛 |
Is Chrome the ideal rendering ? |
- overlapping cups led to a crash - fixes svg-net#508 - workaround to avoid the crash and not deviate too much from correct drawing
883b511
to
4ef0b80
Compare
Maybe not ideal, but overall it seems to be nearer to the standard than the other browsers after my checks, at least most times. So yes, I tend to use it as a standard, if there is nothing matching in the W3C examples, though that maybe debatable. Thanks for your review! I'll merge this now to fix the crash - we can always think about more improvements later. |
To show what it does:
Here is the example used in the test in Chrome:
And here in the testrunner using SVG lib: