Example #1
0
// CreateForRectangle is a wrapper around cairo_surface_create_for_rectangle().
func (v *Surface) CreateForRectangle(x, y, width, height float64) *Surface {
	c := C.cairo_surface_create_for_rectangle(v.native(), C.double(x),
		C.double(y), C.double(width), C.double(height))
	s := wrapSurface(c)
	runtime.SetFinalizer(s, (*Surface).destroy)
	return s
}
Example #2
0
func (self *Surface) CreateForRectangle(x, y, width, height float64) *Surface {
	return &Surface{
		context: self.context,
		surface: C.cairo_surface_create_for_rectangle(self.surface,
			C.double(x), C.double(y), C.double(width), C.double(height)),
	}
}
Example #3
0
//CreateSubsurface creates a window into e defined by r.
//All operations performed on s are clipped and translated to e.
//No operation on s performed outside the bounds of r are performed on e.
//
//This is useful for passing constrained child surfaces to routines that draw
//directly on the parent surface with no further allocations, double buffering,
//or copies.
//
//Warning
//
//The semantics of subsurfaces have not yet been finalized in libcairo, unless
//r is: in full device units, is contained within the extents of the target
//surface, and the target or subsurface's device transforms are not changed.
//
//Originally cairo_surface_create_for_rectangle.
func (e *XtensionSurface) CreateSubsurface(r Rectangle) (s Subsurface, err error) {
	r = r.Canon()
	x0, y0 := r.Min.c()
	x1 := C.double(r.Dx())
	y1 := C.double(r.Dy())
	ss := C.cairo_surface_create_for_rectangle(e.s, x0, y0, x1, y1)
	o := Subsurface{NewXtensionPagedVectorSurface(ss)}
	return o, o.Err()
}