[pygtk] Drawing polygon with Cairo
Pietro Battiston
toobaz at email.it
Wed Dec 2 01:28:12 WST 2009
Il giorno mar, 01/12/2009 alle 22.39 +0530, nipun batra ha scritto:
>
>
> On Tue, Dec 1, 2009 at 10:37 PM, Pietro Battiston <toobaz a email.it>
> wrote:
> Il giorno mar, 01/12/2009 alle 22.11 +0530, nipun batra ha
> scritto:
> > There seems to be an easy way to draw polygons using
> Graphics Context
> > as described in chap 12 of manual.How can the same thing be
> done using
> > cairo
>
>
> What (easy) way?
> What manual?
> Some particular kind of polygon?
>
> For a generic polygon, I don't think anythink sensibly
> "easier" than a
> sequence of "line_to" followed by "close" and "strike" (or
> "fill") is
> conceivable.
>
> But I think that, both to increase the probability of a
> satisfying
> answer and as a mere matter of respect for people to whom
> you're asking
> to help you, you should be more clear in your questions.
>
> Pietro
>
>
>
> This is what i have thought as of now.wanted to use faster
> implementations.
>
>
> def draw_polygon(x0, y0,x1,y1,x2,y2,x3,y3):
> cr.move_to(x0,y0)
> cr.line_to(x1,y1)
> cr.move_to(x1,y1)
> cr.line_to(x2,y2)
> cr.move_to(x2,y2)
> cr.line_to(x3,y3)
> cr.move_to(x3,y3)
> cr.line_to(x0,y0)
>
> #cr.arc(x, y, 2, 0, 2 * pi)
> cr.set_source_rgba(0, 0, 0, 1)
> cr.stroke()
>
>
What makes you think this is slow?
Pietro
More information about the pygtk
mailing list