[cairo] Layered stroke / fill

Uli Schlachter psychon at znc.in
Sun Aug 19 05:51:00 PDT 2012


On 19.08.2012 13:44, Lockert Fredrick wrote:
[...]
> There's one problem I've got though, and I can't quite figure out how
> to fix it. When the user draws out rectangles, they "merge" into each
> other, rather then being painted on top of each other. I'm sure this
> is an easy fix, but I couldn't find an answer after searching the web
> and the documentation (probably used the wrong keywords...)
[...]

This your code for drawing the rectangles:

    for(int i = 0; (unsigned)i < mRects.size(); ++i)
    {
        cr->rectangle(mRects[i].left, mRects[i].top, mRects[i].right,
mRects[i].bottom);
    }
    cr->stroke_preserve();
    cr->set_source_rgb(1.0, 1.0, 1.0);
    cr->fill();
    cr->restore();

Try swapping the calls to stroke and fill:

    cr->fill_preserve();
    cr->set_source_rgb(1.0, 1.0, 1.0);
    cr->stroke();

The fill() will otherweise erase part of the earlier stroke().

Uli
-- 
my $key = "\x49\x03\x93\x08\x19\x94\x96\x94\x28\x93\x83\x04\x68\x28\xa8\xf5".
          "\x0a\xb9\x94\x02\x45\x81\x93\x1f\xbc\xd7\xf3\xad\x93\xf5\x32\x93";
my $cipher = Crypt::Rijndael->new( $key, Crypt::Rijndael::MODE_ECB() );
my $plain = $ciper->decrypt($daten);


More information about the cairo mailing list