Esempio n. 1
0
func (self *Surface) ClipRectangleList() ([]Rectangle, Status) {
	list := C.cairo_copy_clip_rectangle_list(self.context)
	defer C.cairo_rectangle_list_destroy(list)
	rects := make([]Rectangle, int(list.num_rectangles))
	C.memcpy(unsafe.Pointer(&rects[0]), unsafe.Pointer(list.rectangles), C.size_t(list.num_rectangles*8))
	return rects, Status(list.status)
}
Esempio n. 2
0
//ClipRectangles reports the current clip region as a list of rectangles
//in user coordinates or an error if the clip region cannot be so represented.
//
//Originally cairo_copy_clip_rectangle_list.
func (c *Context) ClipRectangles() (list []Rectangle, err error) {
	rects := C.cairo_copy_clip_rectangle_list(c.c)
	if err := toerr(rects.status); err != nil {
		return nil, err
	}

	n := int(rects.num_rectangles)
	if n == 0 {
		return nil, nil
	}
	rs := (*[1 << 30]C.cairo_rectangle_t)(unsafe.Pointer(rects.rectangles))[:n:n]
	list = make([]Rectangle, n)
	for i, v := range rs {
		list[i] = cRect(v.x, v.y, v.x+v.width, v.y+v.height)
	}

	C.cairo_rectangle_list_destroy(rects)

	return
}