[cairo] Clipping
Travis Griggs
tgriggs at cincom.com
Thu Jan 22 16:47:07 PST 2009
On Jan 22, 2009, at 1:39 AM, alexo at mail333.com wrote:
> Thank You Travis,
> but this code have the same result :(
> I'm use cairo binary 1.8.0 in Windows.
>
> void OnPaint(HWND hwnd)
> {
> PAINTSTRUCT ps;
> HDC hdc=::BeginPaint(hwnd,&ps);
>
> cairo_surface_t* surface=cairo_win32_surface_create(hdc);
> cairo_t* cr=cairo_create(surface);
>
> cairo_rectangle(cr, 100, 300, 200, -200);
> cairo_clip(cr);
> cairo_set_source_rgb(cr, 1, 0, 0);
> cairo_paint(cr);
>
> cairo_destroy(cr);
> cairo_surface_destroy(surface);
>
> ::EndPaint(hwnd,&ps);
> }
OK, add one more line in there, let me know if it fixes it.
Directly above the cairo_rectangle line, add this line:
cairo_rectangle(cr,0,0,rect.right,rect.bottom);
(where rect is the bounds of the Window gotten from the
GetClientRect() function).
So basically you do two rectangles, the outer one, and then the inner
one, but the inner one goes backwards (because ONE of it's dimensions
is negative). And then set the result of that aggregate path as your
clip. I know this works on OSX, I just tried it.
Hope that works
--
Travis Griggs
Objologist
"I think that we should be men first, and subjects afterward." - Henry
David Thoreau
More information about the cairo
mailing list