[Webkit-unassigned] [Bug 19243] [CAIRO] Masker in SVG

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Sun May 25 11:37:18 PDT 2008


http://bugs.webkit.org/show_bug.cgi?id=19243





------- Comment #2 from vbs85 at gmx.de  2008-05-25 11:37 PDT -------
only a complement: The source pattern is masked in cairo. A group has to be on
one pattern and this pattern have to be added to the source pattern.

An example:
in SVG
  <g id="group" x="20" y="260" width="320" height="250" mask="url(#m1)">
    <circle cx="80" cy="400" r="50" fill="blue" />
    <circle cx="180" cy="300" r="50" fill="green" />
    <circle cx="280" cy="400" r="50" fill="yellow" />
  </g>

in Cairo it could look like:
  cairo_surface_t* surface;
  cairo_surface_t* mask;
  cairo_surface_t* group;
  cairo_t* cr_group;

  // The masked group is added to a new context
  surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 360, 260);
  cr_group = cairo_create(surface);

  cairo_arc (cr_group, 100.0, 160.0, 50.0, 0, 2*3.14159265);
  cairo_set_source_rgb(cr_group, 0, 0, 1);
  cairo_fill(cr_group);

  cairo_arc (cr_group, 200.0, 60.0, 50.0, 0, 2*3.14159265);
  cairo_set_source_rgb(cr_group, 0, 1, 0);
  cairo_fill(cr_group);

  cairo_arc (cr_group, 300.0, 160.0, 50.0, 0, 2*3.14159265);
  cairo_set_source_rgb(cr_group, 1, 1, 0);
  cairo_fill(cr_group);

  // Add the group to the source
  group = cairo_get_target(cr_group);
  cairo_set_source_surface(cr, group, 0, 0);

  // Apply the mask to the source
  mask = cairo_image_surface_create_from_png ("image2.png");
  cairo_mask_surface(cr, mask, 0, 0);
  cairo_destroy(cr); 

this code demonstrates the procedure.


-- 
Configure bugmail: http://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.



More information about the webkit-unassigned mailing list