[cairo] Clipping

alexo at mail333.com alexo at mail333.com
Wed Jan 21 18:12:56 PST 2009


Hi all !
I can't understand how cairo clipping work.
I have code:

void OnPaint(HWND hwnd)
{
	PAINTSTRUCT ps;
	HDC hdc=::BeginPaint(hwnd,&ps);

	RECT rect;
	::GetClientRect(hwnd,&rect);

	cairo_surface_t*    surface=cairo_win32_surface_create(hdc);
	cairo_t * cr = cairo_create (surface);

	cairo_set_operator(cr,CAIRO_OPERATOR_DEST_OVER);//this is default operation
	cairo_rectangle(cr,100,100,200,200);
	cairo_clip(cr);

	cairo_set_source_rgb(cr,1,0,0);
	cairo_rectangle(cr,0,0,rect.right,rect.bottom);
	cairo_fill(cr);


	cairo_destroy(cr);
	cairo_surface_destroy(surface);

	SelectClipRgn(hdc,NULL);

	::EndPaint(hwnd,&ps);
}

I need to fill surrounding space of cairo_rectangle(100,100,200,200).
But that code fiil only this box.
Changing flag in cairo_set_operator do nothing.
How can I do this?
And what difference between clipping and masking?






More information about the cairo mailing list