# [cairo] Interpretation of zero-length segments

Krzysztof Kosiński tweenk.pl at gmail.com
Thu Aug 5 12:01:46 PDT 2010

```W dniu 5 sierpnia 2010 10:15 użytkownik Chris Wilson
<chris at chris-wilson.co.uk> napisał:
> And what length is "very short"? That sounds like a capping issue. A
> degenerate path segment should still be capped if the normal is known.

I'm not sure if the pictures got through (they're probably stuck in
the moderation queue) so I'll have to explain. In SVG, a rectangle
with zero height, non-zero width W, stroke width S looks like this:
- with miter join, it looks like a rectangle with width = W+S and
height = S with the upper-left corner at -S/2,-S/2
- with bevel join, it looks like the path M 0,0 L W,0 W+S/2,S/2 W,S
0,S -S/2,S/2 Z drawn under translation by 0,-S/2
- with round join, it looks like a line from 0,0 to W,0 with stroke
width S and round caps

In Cairo, regardless of join type, it looks like a rectangle with
width = W and height = S with upper-left corner at 0,-S/2.

> Hmm, this sounds like a bug in our handling of degenerate closed paths. The
> stroke of such a rectangle has a non-zero width, yet the shape of the joins
> as the width/height tends to zero is eluding me.

Essentially there should be no discontinuity when approaching zero
height or zero segment length. I described this in terms of tangents
etc. because this interpretation is sensible for arbitrary paths, not
only rectangles.

> The easiest way to demonstrate this would be to draw rectangles from -4x-4
> to 4x4 (including 0x0) for each of the line join modes and then we can
> argue about what the semantics for 0x0 should be...

I don't think there is any 100% sensible way to interpret 0x0
rectangles - the problem is 0xH and Wx0 rectangles, which are
legitimate and sometimes used in practice.

Regards, Krzysztof
```