[cairo] Polyline overshoot

Frans Meulenbroeks fransmeulenbroeks at yahoo.com
Mon Mar 14 07:54:36 UTC 2022


 Hi Uli,
Thanks for your reply.Using rounding indeed gives a much better picture so it fixes my problem.
What I do not fully understand is why miter join would create the overshoot I was seeing.

I had expected that this would not draw before or after the coordinate the line ends (and at least not overshooting two or three pixels)
Kind regards, Frans

    Op woensdag 9 maart 2022 16:56:10 CET schreef Uli Schlachter <psychon at znc.in>:  
 
 Hi,

Am 09.03.22 um 14:34 schrieb Frans Meulenbroeks:
[...]
> However when I look at the resulting image I get things like the image below.
> E.g. I am not very happy with the pixel at 798, 205 as I am drawing no lines with x < 800 at all.As these are measurement results I would like to see less overshoot.As you can see from the code above I already added 0.5 to the coordinates.Is there a way to improve this? Or where is my expectation wrong?

I tried to turn your code sample into an executable program. The result
is attached (I also guess a line width of 1). Next I also guessed that
this is due to a line join. The default join is miter, which is
documented as:

 * @CAIRO_LINE_JOIN_MITER: use a sharp (angled) corner, see
 * cairo_set_miter_limit() (Since 1.0)

I set the line join to round and the result changed. This is already
done in the attached program.

> PS: this is all rendered using an ARGB32 surface of 1920x1080 pixels

I went with a 15x15 image. And with RGB24 since my image viewer would
otherwise not tell me where the top left corner of the image is.

Cheers,
Uli
-- 
"In the beginning the Universe was created. This has made a lot of
 people very angry and has been widely regarded as a bad move."  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.cairographics.org/archives/cairo/attachments/20220314/158e6a01/attachment.htm>


More information about the cairo mailing list