[prev in list] [next in list] [prev in thread] [next in thread] 

List:       cairo
Subject:    Re: [cairo] Strange behaviour on arc drawing with big line width
From:       Maurizio Berti <maurizio.berti () gmail ! com>
Date:       2014-09-25 0:04:26
Message-ID: CAPn+-XRaX7GC6dn9JrsL17hmoomT+7vaYNZT6a0zADjhcM-_kg () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


Thank you all for your efforts, I hope I will able to try it as soon as
possible, even if unfortunally on my system I can't afford to use cairo
from git.
To answer to Tobias, I could draw lines and fill the arc, but that's not
what I'd need, since I have to be able to use arcs with line width smaller
than the radius, so I should create two arcs and then fill, but that would
require me 3 further commands from a python script that has to be as light
and fast as possible while drawing (I need 50-60fps refresh rate and try to
keep cpu usage low).

Thank you again,
Maurizio

2014-09-23 0:10 GMT+02:00 Bryce Harrington <bryce@osg.samsung.com>:

> Chris posted a patch to the bug tracker for this issue:
>
>   https://bugs.freedesktop.org/show_bug.cgi?id=84115
>
> Bryce
>
> On Sun, Sep 21, 2014 at 01:34:23PM +0200, Tobias Hoffmann wrote:
> > 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@osg.samsung.com <mailto:bryce@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
> > >
> > >
> >
>



-- 
È difficile avere una convinzione precisa quando si parla delle ragioni del
cuore. - "Sostiene Pereira", Antonio Tabucchi
http://www.jidesk.net

[Attachment #5 (text/html)]

<div dir="ltr">Thank you all for your efforts, I hope I will able to try it as soon \
as possible, even if unfortunally on my system I can&#39;t afford to use cairo from \
git.<div>To answer to Tobias, I could draw lines and fill the arc, but that&#39;s not \
what I&#39;d need, since I have to be able to use arcs with line width smaller than \
the radius, so I should create two arcs and then fill, but that would require me 3 \
further commands from a python script that has to be as light and fast as possible \
while drawing (I need 50-60fps refresh rate and try to keep cpu usage \
low).</div><div><br></div><div>Thank you again,</div><div>Maurizio</div></div><div \
class="gmail_extra"><br><div class="gmail_quote">2014-09-23 0:10 GMT+02:00 Bryce \
Harrington <span dir="ltr">&lt;<a href="mailto:bryce@osg.samsung.com" \
target="_blank">bryce@osg.samsung.com</a>&gt;</span>:<br><blockquote \
class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex">Chris posted a patch to the bug tracker for this issue:<br> \
<br>  <a href="https://bugs.freedesktop.org/show_bug.cgi?id=84115" \
target="_blank">https://bugs.freedesktop.org/show_bug.cgi?id=84115</a><br> <br>
Bryce<br>
<div><div class="h5"><br>
On Sun, Sep 21, 2014 at 01:34:23PM +0200, Tobias Hoffmann wrote:<br>
&gt; Hi,<br>
&gt;<br>
&gt; I tried a few things, and expected the correct result to be this:<br>
&gt;              cr.arc(200, 200, 200, 0*(math.pi/180), -60*(math.pi/180))<br>
&gt;              cr.line_to(200,200)<br>
&gt;              cr.close_path()<br>
&gt;              cr.fill()<br>
&gt;<br>
&gt; but actually PostScript (ghostscript&#39;s interpretation of it) will<br>
&gt; not draw a horizontal line at the beginning, either:<br>
&gt;   $ gs<br>
&gt;   GS&gt; 200 setlinewidth<br>
&gt;   GS&gt; 200 500 100 0 60 arcn stroke<br>
&gt;<br>
&gt; (Note: I&#39;ve used arcn instead of arc and 60 instead of -60 because<br>
&gt; the postscript coordinate system has its Y-axis going upwards,<br>
&gt; unlike pygtk.)<br>
&gt;<br>
&gt; Also, when using LINE_CAP_SQUARE (and a smaller line-width), I can<br>
&gt; see that cairo and ghostscript disagrees on the tangent-direction at<br>
&gt; the endpoints of the arc...<br>
&gt;<br>
&gt; What cairo seems to do, is use different tangent directions for the<br>
&gt; inner and the outer part of the stroked arc, but (AFAICS) *only at<br>
&gt; the beginning* of the arc -- the end of it is always unaffected!<br>
&gt; That seems strange to me.<br>
&gt; But I&#39;m not sure, which tangent is actually the &#39;correct&#39; one.<br>
&gt;<br>
&gt; If you want a perfect horizontal line, you should not stroke the<br>
&gt; arc, but fill it (see my first code snippet).<br>
&gt;<br>
&gt; Maybe someone with better knowledge of how cairo actually draws<br>
&gt; (tesselates?) these arcs wants to explain the current behavior?<br>
&gt;<br>
&gt;     Tobias<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; On 20/09/14 02:04, Maurizio Berti wrote:<br>
&gt; &gt;Hello,<br>
&gt; &gt;I&#39;m writing a cairo python script, which loads graphics and<br>
&gt; &gt;animations from a custom file to create &quot;fancy&quot; (and unuseful)<br>
&gt; &gt;graphics like those seen in videogames and scifi movies.<br>
&gt; &gt;I have a problem with arcs, though: I need to be able to draw them<br>
&gt; &gt;interactively, with user given coords, start/end and line width.<br>
&gt; &gt;When I try to draw arcs with a certain line width I have a strange<br>
&gt; &gt;behaviour: the beginning of the line is not straight as it should<br>
&gt; &gt;be, you can see an example of it here:<br>
&gt; &gt;<a href="http://jidesk.net/sypy/strangearc2.jpg" \
target="_blank">http://jidesk.net/sypy/strangearc2.jpg</a><br> &gt; &gt;<br>
&gt; &gt;Here is the code I used for this test:<br>
&gt; &gt;<a href="https://bpaste.net/show/e1f3b8d1f842" \
target="_blank">https://bpaste.net/show/e1f3b8d1f842</a><br> &gt; &gt;<br>
&gt; &gt;I&#39;m using cairo 1.12.16 from the official Gentoo portage (the<br>
&gt; &gt;problem still remains with the latest -r3 version in the portage),<br>
&gt; &gt;with pycairo 1.10.0-r4, also latest stable from the portage.<br>
&gt; &gt;<br>
</div></div>&gt; &gt;CC&#39;ing to <a \
href="mailto:bryce@osg.samsung.com">bryce@osg.samsung.com</a> &lt;mailto:<a \
href="mailto:bryce@osg.samsung.com">bryce@osg.samsung.com</a>&gt; who<br> <div \
class="HOEnZb"><div class="h5">&gt; &gt;confirmed the issue on #cairo using cairo<br> \
&gt; &gt;1.13.0~20140204-0ubuntu1, but was not present using cairo<br> &gt; \
&gt;1.12.16-0ubuntu1.1~bryce~precise6, with little different results:<br> &gt; &gt;<a \
href="http://jidesk.net/sypy/strangearc-bryce.png" \
target="_blank">http://jidesk.net/sypy/strangearc-bryce.png</a><br> &gt; &gt;<br>
&gt; &gt;To draw single and simple &quot;filled&quot; arcs I could use lines and<br>
&gt; &gt;curves, but that would affect the performances of my script (and<br>
&gt; &gt;would require a lot of complex calculations), so I&#39;m here to ask<br>
&gt; &gt;if someone can confirm that this is a bug indeed.<br>
&gt; &gt;<br>
&gt; &gt;Thanks,<br>
&gt; &gt;Maurizio<br>
&gt; &gt;<br>
&gt; &gt;--<br>
&gt; &gt;Č difficile avere una convinzione precisa quando si parla delle<br>
&gt; &gt;ragioni del cuore. - &quot;Sostiene Pereira&quot;, Antonio Tabucchi<br>
&gt; &gt;<a href="http://www.jidesk.net" \
target="_blank">http://www.jidesk.net</a><br> &gt; &gt;<br>
&gt; &gt;<br>
&gt;<br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br>È difficile \
avere una convinzione precisa quando si parla delle ragioni del cuore. - \
&quot;Sostiene Pereira&quot;, Antonio Tabucchi<br><a \
href="http://www.jidesk.net">http://www.jidesk.net</a> </div>



-- 
cairo mailing list
cairo@cairographics.org
http://lists.cairographics.org/mailman/listinfo/cairo

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic