[cairo] Fill not overlapping stroke?
Bill Spitzak
spitzak at gmail.com
Tue Jun 1 18:39:57 PDT 2010
David Trallero wrote:
>> I suppose what I want is a way to just fill inside the stroke and not overlap it;
>> or a way to pass fill and stroke at the same time.
>
> If I understood you well, you are looking for something like this:
>
> cairo_push_group_with_content( cr, CAIRO_CONTENT_COLOR_ALPHA ) ;
> cairo_set_line_width( cr, 10.0 ) ;
>
> cairo_rectangle( cr, 0, 0, 200, 200 ) ;
>
> cairo_set_source_rgba( cr, 1.0, 0.0, 0.0, .8 ) ;
> cairo_fill_preserve( cr ) ;
>
> cairo_set_operator( cr, CAIRO_OPERATOR_DEST_OUT ) ;
>
> cairo_set_source_rgba( cr, 0.0, 0.0, 0.0, .5 ) ;
> cairo_stroke( cr ) ;
>
> cairo_pop_group_to_source( cr ) ;
> cairo_set_operator( cr, CAIRO_OPERATOR_DEST_OVER ) ;
> cairo_paint( cr );
I think to make the stroke be an arbitrary color and alpha, you instead
use CAIRO_OPERATOR_SOURCE when doing the stroke step.
More information about the cairo
mailing list