[cairo] Mesh gradients
Tavmjong Bah
tavmjong at free.fr
Fri Nov 19 04:31:05 PST 2010
This is quite timely. The SVG working group has begun to look at the
possibility of adding mesh gradients (and/or other advance gradients) to
the standard. Support for mesh gradients has been a much asked for
feature by Inkscape users. Having support in Cairo would help the cause.
I prepared a quick web page to start the SVG working group discussion:
http://tavmjong.free.fr/SVG/MESH/Mesh.html
Tav
On Fri, 2010-11-19 at 12:29 +0100, Andrea Canciani wrote:
> Sorry for reopening a very old thread, but I started reworking the
> code to merge it
> in master, so I think that this might be an appropriate time to
> discuss about the
> API for mesh patterns.
>
> On Mon, Sep 7, 2009 at 1:06 AM, Behdad Esfahbod <behdad at behdad.org> wrote:
> > Hi Adrian,
> >
> > My main comment is that given the number of new API additions, I'd rather see
> > them under a cairo_pattern_mesh_* namespace rather than cairo_pattern_*.
>
> Yes, this looks like a good idea.
>
> > Other than that, not a huge fan of moveto/lineto/curveto, but can live with it.
>
> I'm not very keen on them, but so far they are probably the easiest way that
> has been proposed to specify patches.
>
> One problem of the current API is that it should be made clear that the order
> used to specify the patch is important (in particular the patch with A,B,C,D as
> edges is different, in general, from the patch D,A,B,C).
>
> A different API might make it more obvious, but I'm unable to figure out how
> we could do it.
>
> Andrea
>
> >
> > Thanks for all the work,
> >
> > behdad
> >
> > On 09/06/2009 08:45 AM, Adrian Johnson wrote:
> >> I've updated the mesh gradient API on my mesh branch[1] to change the
> >> set corner color and set control point API to:
> >>
> >> void
> >> cairo_pattern_set_corner_color_rgb[a] (cairo_pattern_t *pattern,
> >> int point_num,
> >> double red, double green,
> >> double blue);
> >> void
> >> cairo_pattern_set_control_point (cairo_pattern_t *pattern,
> >> int point_num,
> >> double x,
> >> double y);
> >>
> >> I found this change to be easier and less confusing to use. The complete
> >> API is at the end of this message. The gtk-doc dcoumentation in the code
> >> documents the use of this API. The mesh branch also includes some
> >> patches from Andrea to fix some bugs.
> >>
> >> I've updated the cairo backend of poppler to use cairo mesh gradients[2]
> >> for PDF Type 4,5,6, and 7 shadings. Some sample renderings of PDF files
> >> using this poppler-cairo branch are at:
> >>
> >> http://people.freedesktop.org/~ajohnson/mesh/
> >>
> >> monkey.png, rendered from monkey.pdf, is from laidout [3]. The others
> >> are from smooth shading samples [4] converted to PDF then rendered with
> >> poppler-cairo. Some of these have a few white pixels in them. I have not
> >> worked out what is causing that.
> >>
> >> Any comments on this API and the implementation? Should the mesh
> >> gradient rasterizer be moved into pixman?
> >>
> >>
> >> [1] http://cgit.freedesktop.org/~ajohnson/cairo/log/?h=mesh
> >>
> >> [2] http://cgit.freedesktop.org/~ajohnson/poppler/log/?h=mesh
> >>
> >> [3] http://www.laidout.org/
> >>
> >> [4]http://partners.adobe.com/public/developer/en/ps/sdk/sample/smooth.zip
> >>
> >>
> >> Complete Mesh gradient API
> >> --------------------------
> >>
> >> cairo_pattern_t *
> >> cairo_pattern_create_mesh (void);
> >>
> >> void
> >> cairo_pattern_begin_patch (cairo_pattern_t *pattern);
> >>
> >> void
> >> cairo_pattern_end_patch (cairo_pattern_t *pattern);
> >>
> >> void
> >> cairo_pattern_curve_to (cairo_pattern_t *pattern,
> >> double x1,
> >> double y1,
> >> double x2,
> >> double y2,
> >> double x3,
> >> double y3);
> >>
> >> void
> >> cairo_pattern_line_to (cairo_pattern_t *pattern,
> >> double x,
> >> double y);
> >>
> >> void
> >> cairo_pattern_move_to (cairo_pattern_t *pattern,
> >> double x,
> >> double y);
> >>
> >> void
> >> cairo_pattern_set_corner_color_rgb (cairo_pattern_t *pattern,
> >> int point_num,
> >> double red, double green,
> >> double blue);
> >>
> >> void
> >> cairo_pattern_set_corner_color_rgba (cairo_pattern_t *pattern,
> >> int point_num,
> >> double red, double green,
> >> double blue, double alpha);
> >>
> >> void
> >> cairo_pattern_set_control_point (cairo_pattern_t *pattern,
> >> int point_num,
> >> double x,
> >> double y);
> >>
> >> cairo_status_t
> >> cairo_pattern_get_patch_count (cairo_pattern_t *pattern,
> >> int *count);
> >>
> >> cairo_path_t *
> >> cairo_pattern_get_path (cairo_pattern_t *pattern,
> >> int patch_num);
> >>
> >> cairo_status_t
> >> cairo_pattern_get_corner_color_rgba (cairo_pattern_t *pattern,
> >> int patch, int corner,
> >> double *red, double *green,
> >> double *blue, double *alpha);
> >>
> >> cairo_status_t
> >> cairo_pattern_get_control_point (cairo_pattern_t *pattern,
> >> int patch, int point,
> >> double *x, double *y);
> >>
> >>
> >> _______________________________________________
> >> cairo mailing list
> >> cairo at cairographics.org
> >> http://lists.cairographics.org/mailman/listinfo/cairo
> >>
> > _______________________________________________
> > cairo mailing list
> > cairo at cairographics.org
> > http://lists.cairographics.org/mailman/listinfo/cairo
> >
> --
> cairo mailing list
> cairo at cairographics.org
> http://lists.cairographics.org/mailman/listinfo/cairo
More information about the cairo
mailing list