Example #1
0
// void cairo_get_dash (cairo_t *cr, double *dashes, double *offset);
func (self *Surface) GetDash() ([]float64, float64) {
	var offset float64
	length := int(C.cairo_get_dash_count(self.context))
	if length == 0 {
		return nil, 0
	}
	dashes := make([]float64, length)

	C.cairo_get_dash(self.context, (*C.double)(unsafe.Pointer(&dashes[0])), (*C.double)(unsafe.Pointer(&offset)))
	return dashes, offset
}
Example #2
0
// GetDash is a wrapper around cairo_get_dash().
func (v *Context) GetDash() (dashes []float64, offset float64) {
	dashCount := v.GetDashCount()
	cdashes := (*C.double)(C.calloc(8, C.size_t(dashCount)))
	var coffset C.double
	C.cairo_get_dash(v.native(), cdashes, &coffset)
	header := (*reflect.SliceHeader)((unsafe.Pointer(&dashes)))
	header.Data = uintptr(unsafe.Pointer(cdashes))
	header.Len = dashCount
	header.Cap = dashCount
	return dashes, float64(coffset)
}
Example #3
0
//Dashes reports the current dash sequence.
//If dashing is not currently in effect the length of dashes
//is 0.
//
//Originally cairo_get_dash
func (c *Context) Dashes() (offset float64, dashes []float64) {
	ln := c.DashCount()
	if ln == 0 {
		return
	}

	var off C.double
	arr := make([]C.double, ln)
	C.cairo_get_dash(c.c, &arr[0], &off)
	offset = float64(off)

	dashes = make([]float64, ln)
	for i, v := range arr {
		dashes[i] = float64(v)
	}

	return
}