Пример #1
0
func drawImage(w, h int, data unsafe.Pointer) {
	var stride C.VGint = C.VGint(w * 4)
	var format C.VGImageFormat = C.VG_sABGR_8888
	var quality C.VGbitfield = C.VG_IMAGE_QUALITY_BETTER
	var img C.VGImage

	img = C.vgCreateImage(format, C.VGint(w), C.VGint(h), quality)
	C.vgImageSubData(img, data, stride, format,
		0, 0, C.VGint(w), C.VGint(h))

	// vgDrawImage() applies the scale transformation,
	// vgSetPixels() does not
	C.vgDrawImage(img)
	C.vgDestroyImage(img)
}
Пример #2
0
// poly converts coordinate slices
func poly(x, y []float64) (*C.VGfloat, *C.VGfloat, C.VGint) {
	size := len(x)
	if size != len(y) {
		return nil, nil, 0
	}
	px := make([]C.VGfloat, size)
	py := make([]C.VGfloat, size)
	for i := 0; i < size; i++ {
		px[i] = C.VGfloat(x[i])
		py[i] = C.VGfloat(y[i])
	}
	return &px[0], &py[0], C.VGint(size)
}
Пример #3
0
// ClipRect limits the drawing area to specified rectangle
func ClipRect(x, y, w, h int) {
	C.ClipRect(C.VGint(x), C.VGint(y), C.VGint(w), C.VGint(h))
}