Clipper2 icon indicating copy to clipboard operation
Clipper2 copied to clipboard

Add support for JoinType Bevel from PDF and SVG

Open StipoR opened this issue 3 years ago • 3 comments

Thank you Mr. Johnson for such a great library!

I have one feature request: add support for JoinType Bevel as specified in the PDF specification and the SVG specification. I think that the same definition is used in other graphics frameworks, such as GDI+ and WPF.

Perhaps the following StackExchange post illustrates the difference between the existing JoinType.Square (Thickness in that post) and Bevel (Orthogonal in that post): What is a bevel join of two lines exactly (Illustrator)?

StipoR avatar Aug 13 '23 18:08 StipoR

I have one feature request: add support for JoinType Bevel as specified in the PDF specification and the SVG specification.

Both Clipper1 and earlier versions of Clipper2 did perform this exact style of bevel joining (even though they were called Square joins. As per the PDF documentation, this style butt offsets the adjacent segments before triangular filling (see below).

Butt offsetting of adjacent segments (before triangle filling): butt offsetting After triangle filling: Bevel join

However, 12 months ago I did change the behavior of Clipper2's Square joins so that squaring/beveling occurred at exactly at 1 delta (ie the offset distance) away from each join (because I believe it just looks so much better, even though the code was much more complex).

test2

Nevertheless, I'm reluctant to have Clipper2 perform 4 join types: miter, round, square (ie current squaring) and bevel (old squaring). That seems like overkill, especially given that most other graph libraries support only 3 join types. Unless there are strong objections, I'd be inclined to revert to the former squaring/bevelling behavior (ie to the style that you're requesting, even though IMHO it doesn't look as good) since this appears to be the most widely implemented behavior.

AngusJohnson avatar Sep 23 '23 08:09 AngusJohnson

Honestly, though, if the code is already written, I'd say it would be worth keeping it and going to 4, just because it serves more needs. Changing behavior may break existing users and, again, the effort was already spent implementing it.

philstopford avatar Sep 23 '23 14:09 philstopford

Thank you Mr. Johnson for implementing this feature!

StipoR avatar Sep 25 '23 09:09 StipoR