Пример #1
//New creates a new tee surface.
//Originally cairo_tee_surface_create.
func New(masterSurface cairo.Surface, surfaces ...cairo.Surface) (Surface, error) {
	m := C.cairo_tee_surface_create(masterSurface.XtensionRaw())
	for _, s := range surfaces {
		C.cairo_tee_surface_add(m, s.XtensionRaw())
	S := Surface{cairo.NewXtensionPagedVectorSurface(m)}
	return S, S.Err()
Пример #2
func embed(s cairo.Surface, mime mime, bs []byte) error {
	raw := s.XtensionRaw()
	len := C.size_t(uintptr(len(bs)))

	//We make this copy as bs will be GC'd.
	//We could track the object lifetime and cache the []byte in this package
	//until it is destroyed, which is a fine optimization but necessitates a lot
	//of code.
	data := (*C.uchar)(C.malloc(len))
	C.memcpy(unsafe.Pointer(data), unsafe.Pointer(&bs[0]), len)

	st := C.cairo_surface_set_mime_data(raw, mime.c(), data, C.ulong(len), C.gocairo_free_get(), nil)
		return errors.New("could not set mime data")

	return nil
Пример #3
//Proxy creates a script surface p that renders to s and records to d.
//Originally cairo_script_surface_create_for_target.
func (d Device) Proxy(s cairo.Surface) (p Surface, err error) {
	sr := C.cairo_script_surface_create_for_target(d.XtensionRaw(), s.XtensionRaw())
	return cNewSurf(sr)