[cairo] Strange behaviour on arc drawing with big line width
Tobias Hoffmann
lcairo-list at thax.hardliners.org
Sun Sep 21 04:34:23 PDT 2014
Hi,
I tried a few things, and expected the correct result to be this:
cr.arc(200, 200, 200, 0*(math.pi/180), -60*(math.pi/180))
cr.line_to(200,200)
cr.close_path()
cr.fill()
but actually PostScript (ghostscript's interpretation of it) will not
draw a horizontal line at the beginning, either:
$ gs
GS> 200 setlinewidth
GS> 200 500 100 0 60 arcn stroke
(Note: I've used arcn instead of arc and 60 instead of -60 because the
postscript coordinate system has its Y-axis going upwards, unlike pygtk.)
Also, when using LINE_CAP_SQUARE (and a smaller line-width), I can see
that cairo and ghostscript disagrees on the tangent-direction at the
endpoints of the arc...
What cairo seems to do, is use different tangent directions for the
inner and the outer part of the stroked arc, but (AFAICS) *only at the
beginning* of the arc -- the end of it is always unaffected!
That seems strange to me.
But I'm not sure, which tangent is actually the 'correct' one.
If you want a perfect horizontal line, you should not stroke the arc,
but fill it (see my first code snippet).
Maybe someone with better knowledge of how cairo actually draws
(tesselates?) these arcs wants to explain the current behavior?
Tobias
On 20/09/14 02:04, Maurizio Berti wrote:
> Hello,
> I'm writing a cairo python script, which loads graphics and animations
> from a custom file to create "fancy" (and unuseful) graphics like
> those seen in videogames and scifi movies.
> I have a problem with arcs, though: I need to be able to draw them
> interactively, with user given coords, start/end and line width. When
> I try to draw arcs with a certain line width I have a strange
> behaviour: the beginning of the line is not straight as it should be,
> you can see an example of it here:
> http://jidesk.net/sypy/strangearc2.jpg
>
> Here is the code I used for this test:
> https://bpaste.net/show/e1f3b8d1f842
>
> I'm using cairo 1.12.16 from the official Gentoo portage (the problem
> still remains with the latest -r3 version in the portage), with
> pycairo 1.10.0-r4, also latest stable from the portage.
>
> CC'ing to bryce at osg.samsung.com <mailto:bryce at osg.samsung.com> who
> confirmed the issue on #cairo using cairo 1.13.0~20140204-0ubuntu1,
> but was not present using cairo 1.12.16-0ubuntu1.1~bryce~precise6,
> with little different results: http://jidesk.net/sypy/strangearc-bryce.png
>
> To draw single and simple "filled" arcs I could use lines and curves,
> but that would affect the performances of my script (and would require
> a lot of complex calculations), so I'm here to ask if someone can
> confirm that this is a bug indeed.
>
> Thanks,
> Maurizio
>
> --
> È difficile avere una convinzione precisa quando si parla delle
> ragioni del cuore. - "Sostiene Pereira", Antonio Tabucchi
> http://www.jidesk.net
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cairographics.org/archives/cairo/attachments/20140921/18c9f61d/attachment.html>
More information about the cairo
mailing list