Beispiel #1
0
func (i *Image) SetColor(col ...float64) {
	var r, g, b, a C.double = 0, 0, 0, 1
	// Single channel, use alpha
	if len(col) == 1 {
		if i.ColorSpace == MODE_A8 {
			// When using alphas, draw on alpha
			a = C.double(col[0])
		} else if i.ColorSpace == MODE_G8 {
			// When using grayscale, draw RGB
			r = C.double(col[0])
			g = r
			b = r
		}
	} else if len(col) >= 3 {
		r, g, b = C.double(col[0]), C.double(col[1]), C.double(col[2])
	}
	if len(col) == 4 {
		a = C.double(col[3])
	}
	C.cairo_set_source_rgba(i.Ctx, r, g, b, a)
}
Beispiel #2
0
func (self *Surface) SetSourceRGBA(red, green, blue, alpha float64) {
	C.cairo_set_source_rgba(self.context, C.double(red), C.double(green), C.double(blue), C.double(alpha))
}
Beispiel #3
0
// SetSourceRGBA is a wrapper around cairo_set_source_rgba().
func (v *Context) SetSourceRGBA(red, green, blue, alpha float64) {
	C.cairo_set_source_rgba(v.native(), C.double(red), C.double(green),
		C.double(blue), C.double(alpha))
}
Beispiel #4
0
//SetSourceColor sets the source pattern to col.
//This color will be used for any subsequent drawing operations, until a new
//source pattern is set.
//
//Originally cairo_set_source_rgba.
func (c *Context) SetSourceColor(col color.Color) *Context {
	r, g, b, a := colorToAlpha(col).c()
	C.cairo_set_source_rgba(c.c, r, g, b, a)
	return c
}