[cairo] Rectangle Border Widths

Travis Griggs travisgriggs at gmail.com
Tue Apr 10 15:25:20 PDT 2012


On Apr 10, 2012, at 11:29 AM, robertk54 at aol.com wrote:

>  >> Is it possible to render rectangles whose vertical lines are different in 
> width from the horizontal lines?
> 
> >cairo_rectangle(cr, x, y, width, height);
> >cairo_save(cr);
> >cairo_scale(cr, stroke_width, stroke_height);
> >cairo_set_line_width(cr, 1);
> >cairo_stroke(cr);
> >cairo_restore(cr);

This is a cool solution. Clever but simple.
> 
> 
> Thanks Chris!
> Given this solution, what are the resulting dimensions of the rectangles?  Both the rectangle outside the line and the one within the line?  I need to fill the inner rectangle with a color .  I also need to use the inner rectangle for clipping other content which will be rendered on top of it.
> 

If you're doing the above though…

Why not just do

cairo_rectangle(cr, ...outer_border_dimensions…);
cairo_set_source(cr, …border color…);
cairo_fill(cr);
cairo_rectangle(cr, …inner_border_dimensions…);
cairo_set_source(cr, …fill color…);
cairo_fill_preserve(cr);
cairo_clip(cr);

?

--
Travis Griggs
Objologist
"Some of them wanted to sell me snake oil and I'm not necessarily going to dismiss all of these, as I have never found a rusty snake." --Terry Pratchett

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cairographics.org/archives/cairo/attachments/20120410/32ad9200/attachment.htm>


More information about the cairo mailing list