[cairo] drawing tons of circles
Nicola Fontana
ntd at entidi.it
Mon Oct 5 07:44:17 PDT 2009
Il giorno Mon, 5 Oct 2009 15:26:13 +0200
Mami <wpmami at gmail.com> ha scritto:
> I need to draw tons of filled circles (thousand, actually) and I
> found that using cairo_arc is not the way to go; it lacks the
> performance I need.
>
> Can you recommend a method for drawing such a lot of objects in an
> acceptable timeframe?
If the bottleneck is not in the backend I'd compute only once the circle
path, rendering it multiple times with different matrices. Something
like this (not tested):
cairo_arc(cr, 0, 0, 1, 0, M_PI*2);
path = cairo_copy_path(cr);
cairo_matrix_init(&matrix, radius1, 0, 0, radius1, x1, y1);
cairo_set_matrix(cr, &matrix);
cairo_fill(cr);
cairo_matrix_init(&matrix, radius2, 0, 0, radius2, x2, y2);
cairo_set_matrix(cr, &matrix);
cairo_append_path(cr, path);
cairo_fill(cr);
...
cairo_path_destroy(path);
--
Nicola
More information about the cairo
mailing list