[cairo] Cairo and OpenVG Radial Gradient

KULBHUSHAN PACHAURI kb.pachauri at samsung.com
Tue Oct 9 17:30:09 PDT 2007


Hi Emmanuel,

       Thanks a lot for your all the help.  I tried below code after the changing stops[1] to stops[pattern->base.n_stops - 1]

        For code snippet given below : 

           cairo_status_t  
           radial_test (cairo_t* cr, unsigned int width, unsigned int height) {
           
            cairo_pattern_t *pat;
            pat = cairo_pattern_create_radial (width/2.0, height/2.0, 10, width/2.0, height/2.0, 10);
            cairo_pattern_add_color_stop_rgba (pat, 0, 0, 0, 1, 1);             /* blue  */
            cairo_pattern_add_color_stop_rgba (pat, 1, 1, 0.5, 0, 1);          /* orange* /

            //cairo_pattern_set_extend (pat, CAIRO_EXTEND_PAD);
            //cairo_pattern_set_extend (pat, CAIRO_EXTEND_REPEAT);
              cairo_pattern_set_extend (pat, CAIRO_EXTEND_REFLECT);
            //cairo_pattern_set_extend (pat, CAIRO_EXTEND_NONE);	
	
            cairo_set_source (cr, pat);
            cairo_rectangle (cr, 0, 0, width, height);
            cairo_fill (cr);
            cairo_pattern_destroy (pat);
           
             return cairo_status (cr);
            } 


           Image and glitz backend is giving same output i.e rectangle is filled with  blue color but for svg backend rectangle is filled with orange color.(??)

           Thanks in advance.
      
            Pachauri


>Hi,

> Le samedi 29 septembre 2007 à 06:57 +0000, KULBHUSHAN PACHAURI a écrit :
> As per your reply for my query cairo to openvg radial gradient
> conversion i looked at the how cairo radial gradient is mapped to svg.
> 
>  But i have some doubt about that mapping..
>  
>  for the case if two circle radius are equal  and extend is not equal
> to cairo_extend_none and no of stops is greater than 2.  in that case
> that mapping works or ot. 
>  (line no: 1466 & file name cairo-svg-surface.c)

> It looks like there's a bug here. stops[1] should probably be
> stops[pattern->base.n_stops - 1] lines 1498 - 1500. Apart from that,
> it's supposed to work.

>  Also the offset for both the stops are 0. (??) (lineno: 1494 & file
>  name cairo-svg_surface.c)

>That's fine. SVG says:

> "If two gradient stops have the same offset value, then the latter
> gradient stop controls the color value at the overlap point. In
> particular: 
> <stop offset="0" stop-color="white"/>
> <stop offset=".2" stop-color="red"/>
> <stop offset=".2" stop-color="blue"/>
> <stop offset="1" stop-color="black"/>
 > will have approximately the same effect as: 
> <stop offset="0" stop-color="white"/>
> <stop offset=".1999999999" stop-color="red"/>
> <stop offset=".2" stop-color="blue"/>
> <stop offset="1" stop-color="black"/>
> which is a gradient that goes smoothly from white to red, then abruptly
> shifts from red to blue, and then goes smoothly from blue to black."

> Emmanuel.









More information about the cairo mailing list