func cPatch(m Mesh, n C.uint) (*Patch, error) { if m.p == nil { return nil, ErrInvalidLibcairoHandle } p := &Patch{} for i := C.uint(0); i < 4; i++ { var x, y, r, g, b, a *C.double C.cairo_mesh_pattern_get_control_point(m.p, n, i, x, y) C.cairo_mesh_pattern_get_corner_color_rgba(m.p, n, i, r, g, b, a) if x != nil { p.Controls = append(p.Controls, cPt(*x, *y)) } if r != nil { p.Colors = append(p.Colors, cColor(*r, *g, *b, *a)) } } path := C.cairo_mesh_pattern_get_path(m.p, n) defer C.cairo_path_destroy(path) Path, err := cPath(path) if err != nil { return nil, err } p.Path = Path return p, nil }
//AppendPath appends path onto the current path of c. // //Originally cairo_append_path. func (c *Context) AppendPath(path Path) error { p, err := path.c() if err != nil { return err } C.cairo_append_path(c.c, p) C.cairo_path_destroy(p) return c.Err() }
// cairo_path_t* cairo_copy_path_flat (cairo_t *cr); func (self *Surface) CopyPathFlat() (PathData, Status) { path := C.cairo_copy_path_flat(self.context) defer C.cairo_path_destroy(path) raw_data := make(PathData, int(path.num_data*2)) C.memcpy(unsafe.Pointer(&raw_data[0]), unsafe.Pointer(path.data), C.size_t(path.num_data*16)) return raw_data, Status(path.status) }
//CopyPathFlat returns a linearized copy of the current path. // //CopyPathFlat behaves like CopyPath except that any curves in the path will be //approximated with piecewise-linear approximations, accurate to within the //current tolerance value. //That is, the result is guaranteed to not have any elements of type PathCurveTo //which will instead be replaced by a series of PathLineTo elements. // //Originally cairo_copy_path_flat. func (c *Context) CopyPathFlat() (Path, error) { p := C.cairo_copy_path_flat(c.c) defer C.cairo_path_destroy(p) return cPath(p) }