示例#1
0
//New creates a script device from writer in mode.
//
//Originally cairo_script_create_for_stream.
func New(w io.Writer, mode mode) (Device, error) {
	wp := cairo.XtensionWrapWriter(w)
	d := C.cairo_script_create_for_stream(cairo.XtensionCairoWriteFuncT, wp)
	D, err := cNew(d, mode)
	D.XtensionRegisterWriter(wp)
	return D, err
}
示例#2
0
文件: pdf.go 项目: jimmyfrasche/cairo
//New creates a new PDF of the specified size.
//W is the Writer the PDF is written to.
//Width and height are in the unit of a typographical point
//(1 point = 1/72 inch).
//
//Originally cairo_pdf_surface_create_for_stream.
func New(w io.Writer, width, height float64) (Surface, error) {
	wp := cairo.XtensionWrapWriter(w)
	pdf := C.cairo_pdf_surface_create_for_stream(cairo.XtensionCairoWriteFuncT, wp, C.double(width), C.double(height))
	S, err := news(pdf)
	S.XtensionRegisterWriter(wp)
	return S, err
}
示例#3
0
文件: svg.go 项目: jimmyfrasche/cairo
//New creates a new SVG surface that writes to writer.
//
//If writer needs to be flushed or closed, that is the responsibility
//of the caller.
//
//The parameters width and height are in the unit of a typographical point
//(1 point = 1/72 inch).
//
//Originally cairo_svg_surface_create_for_stream.
func New(w io.Writer, width, height float64) (Surface, error) {
	wp := cairo.XtensionWrapWriter(w)
	svg := C.cairo_svg_surface_create_for_stream(cairo.XtensionCairoWriteFuncT, wp, C.double(width), C.double(height))
	s := Surface{
		XtensionVectorSurface: cairo.NewXtensionVectorSurface(svg),
	}
	s.XtensionRegisterWriter(wp)
	return s, s.Err()
}
示例#4
0
文件: ps.go 项目: jimmyfrasche/cairo
//New creates a new PostScript of the specified size.
//
//W is the Writer the PostScript is written to.
//Width and height are in the unit of a typographical point
//(1 point = 1/72 inch).
//Eps specifies whether this will be Encapsulated PostScript.
//Header is any DSC comments to apply to the header section.
//Setup is any DSC comment to apply to the setup section.
//
//Originally cairo_ps_surface_create_for_stream
//and cairo_ps_surface_set_eps and cairo_ps_surface_dsc_comment
//and cairo_ps_surface_dsc_begin_setup and
//cairo_ps_surface_dsc_begin_page_setup.
func New(w io.Writer, width, height float64, eps bool, header, setup Comments) (S Surface, err error) {
	if err = errChk(header, setup); err != nil {
		return
	}

	wp := cairo.XtensionWrapWriter(w)
	ps := C.cairo_ps_surface_create_for_stream(cairo.XtensionCairoWriteFuncT, wp, C.double(width), C.double(height))

	cfgSurf(ps, eps, header, setup)

	S, err = news(ps, eps)

	S.XtensionRegisterWriter(wp)

	return S, err
}