Clipper for Cairo

64 views
Skip to first unread message

Angus Johnson

unread,
Nov 2, 2010, 5:37:14 AM11/2/10
to Delphi on Rails
I've just created a new Delphi unit that integrates my polygon
clipping library 'Clipper' into Cairo.
Here's a link to the Delphi code (that also includes a very simple
demo) : http://www.angusj.com/delphi/cairo_clipper.zip
I've only just started experimenting with Cairo so I'm very open to
suggestions if the integration can be done more elegantly.

Henri Gourvest

unread,
Nov 2, 2010, 6:35:43 AM11/2/10
to Delphi on Rails
nice work, I'm impressed.
Have you tried using the standard clipping functions from cairo ?
Is clipper faster ?

Pierre Y.

unread,
Nov 2, 2010, 6:42:43 AM11/2/10
to Delphi on Rails
Angus,

Impressive ;-)

Have you seen that there is a cairo_copy_path_flat API in CAIRO that
transforms CAIRO_CURVE_TO polygons into CAIRO_LINE_TO ones ?

http://cairographics.org/manual/cairo-Paths.html#cairo-copy-path
http://cairographics.org/manual/cairo-Paths.html#cairo-copy-path-flat

So that you won't have to recompute all the points of the curves (but
I must say that your Beziers Curves rendering function is amazing...)

Regards,

--
Pierre Yager

On Nov 2, 10:37 am, Angus Johnson <ang...@myrealbox.com> wrote:

Angus Johnson

unread,
Nov 2, 2010, 7:17:17 AM11/2/10
to Delphi on Rails
On 2/11/2010 9:35 PM, Henri Gourvest wrote:

> nice work, I'm impressed.
> Have you tried using the standard clipping functions from cairo ?
> Is clipper faster ?

Hi Henri.
Thanks. No I haven't tried the standard clipping functions. For some
reason I thought they only did rectangular clipping.
As for speed, Clipper is significantly faster than other libraries
I've compared it
with (eg http://angusj.com/delphi/clipper.php#features ).


Angus Johnson

unread,
Nov 2, 2010, 7:19:16 AM11/2/10
to Delphi on Rails
On 2/11/2010 9:42 PM, Pierre Y. wrote:
> Angus,
>
> Impressive ;-)
>
> Have you seen that there is a cairo_copy_path_flat API in CAIRO that
> transforms CAIRO_CURVE_TO polygons into CAIRO_LINE_TO ones ?
>

Thanks Pierre.
I was using IContext.CopyPath because initially I was passing a
PCairoPath pointer to the CairoToDoublePointArray function (instead of
an ICairoContext) and I didn't want to limit the paths to flat paths.
When I decided to pass an ICairoContext to the function, I just forgot
to change the CopyPath to CopyPathFlat.

Angus Johnson

unread,
Nov 2, 2010, 7:23:40 AM11/2/10
to Delphi on Rails
ps: Is there a reason why I can't reply by email?
I've tried replying several times to delphi...@googlegroups.com
and my emails have bounced each time.
I've had to resort to the web interface (which isn't as convenient).

Angus Johnson

unread,
Nov 2, 2010, 7:39:01 AM11/2/10
to Delphi on Rails
On Nov 2, 10:17 pm, Angus Johnson <ang...@myrealbox.com> wrote:
> Thanks. No I haven't tried the standard clipping functions. For some
> reason I thought they only did rectangular clipping.

Firstly, sorry for all the replies. I won't make a habit of it :).

Regarding Cairo's clipping, AFAICT it's more like a mask than a proper
boolean clip (intersection, union etc) which returns a path that you
can fill and stroke.

Henri Gourvest

unread,
Nov 2, 2010, 7:46:33 AM11/2/10
to delphi...@googlegroups.com
Propably because you don't use a gmail account.

2010/11/2 Angus Johnson <ang...@myrealbox.com>

Marcos Barreto

unread,
Nov 2, 2010, 6:49:33 PM11/2/10
to delphi...@googlegroups.com
What I can do using Cairo library?

2010/11/2 Henri Gourvest <hgou...@gmail.com>



--
Marcos Barreto
MicroProcess Sistemas Ltda - Diretor
Graduado em Ciência da Computação - UESB-BA
Pós-Graduado em Gestão Hospitalar - FIJ-RJ

Henri Gourvest

unread,
Nov 3, 2010, 4:50:47 AM11/3/10
to delphi...@googlegroups.com
Cairo is an Open Source multi-platform 2D graphics library.
In Delphi on Rails, it can be used to create PNG, SVG, PDF and PS.

2010/11/2 Marcos Barreto <mrba...@gmail.com>
Reply all
Reply to author
Forward
0 new messages