当前位置: 首页>>代码示例>>Golang>>正文


Golang C.VGfloat函数代码示例

本文整理汇总了Golang中C.VGfloat函数的典型用法代码示例。如果您正苦于以下问题:Golang VGfloat函数的具体用法?Golang VGfloat怎么用?Golang VGfloat使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了VGfloat函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: Image

// Image places the image in s image at (x,y) with dimensions (w,h)
func Image(x, y float64, w, h int, s string) {
	f, ferr := os.Open(s)
	if ferr != nil {
		fakeimage(x, y, w, h, s)
		return
	}
	defer f.Close()
	img, _, err := image.Decode(f)
	if err != nil {
		fakeimage(x, y, w, h, s)
		return
	}
	bounds := img.Bounds()
	minx := bounds.Min.X
	maxx := bounds.Max.X
	miny := bounds.Min.Y
	maxy := bounds.Max.Y
	data := make([]C.VGubyte, w*h*4)
	n := 0
	// println("minx", minx, "maxx", maxx, "miny", miny, "maxy", maxy)
	for y := miny; y < maxy; y++ {
		for x := minx; x < maxx; x++ {
			r, g, b, a := img.At(x, (maxy-1)-y).RGBA() // OpenVG has origin at lower left, y increasing up
			data[n] = C.VGubyte(r)
			n++
			data[n] = C.VGubyte(g)
			n++
			data[n] = C.VGubyte(b)
			n++
			data[n] = C.VGubyte(a)
			n++
		}
	}
	C.makeimage(C.VGfloat(x), C.VGfloat(y), C.int(w), C.int(h), &data[0])
}
开发者ID:xranby,项目名称:openvg,代码行数:36,代码来源:openvg.go

示例2: poly

// 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)
}
开发者ID:xranby,项目名称:openvg,代码行数:14,代码来源:openvg.go

示例3: makeramp

// makestops prepares the color/stop vector
func makeramp(r []Offcolor) (*C.VGfloat, C.int) {
	lr := len(r)
	nr := lr * 5
	cs := make([]C.VGfloat, nr)
	j := 0
	for i := 0; i < lr; i++ {
		cs[j] = C.VGfloat(r[i].Offset)
		j++
		cs[j] = C.VGfloat(VGfloat(r[i].Red) / 255.0)
		j++
		cs[j] = C.VGfloat(VGfloat(r[i].Green) / 255.0)
		j++
		cs[j] = C.VGfloat(VGfloat(r[i].Blue) / 255.0)
		j++
		cs[j] = C.VGfloat(r[i].Alpha)
		j++
	}
	return &cs[0], C.int(lr)
}
开发者ID:jhautefeuille,项目名称:openvg,代码行数:20,代码来源:openvg.go

示例4: Image

// Image places the named image at (x,y) with dimensions (w,h)
func Image(x, y float64, w, h int, s string) {
	var img image.Image
	var derr error
	f, err := os.Open(s)
	if err != nil {
		fakeimage(x, y, w, h, s)
		return
	}
	img, _, derr = image.Decode(f)
	defer f.Close()
	if derr != nil {
		fakeimage(x, y, w, h, s)
		return
	}
	bounds := img.Bounds()
	minx := bounds.Min.X
	maxx := bounds.Max.X
	miny := bounds.Min.Y
	maxy := bounds.Max.Y
	data := make([]C.VGubyte, w*h*4)
	n := 0
	var r, g, b, a uint32
	for yp := miny; yp < maxy; yp++ {
		for xp := minx; xp < maxx; xp++ {
			r, g, b, a = img.At(xp, (maxy-1)-yp).RGBA() // OpenVG has origin at lower left, y increasing up
			data[n] = C.VGubyte(r)
			n++
			data[n] = C.VGubyte(g)
			n++
			data[n] = C.VGubyte(b)
			n++
			data[n] = C.VGubyte(a)
			n++
		}
	}
	C.makeimage(C.VGfloat(x), C.VGfloat(y), C.int(w), C.int(h), &data[0])
}
开发者ID:remogatto,项目名称:openvg,代码行数:38,代码来源:openvg.go

示例5: Img

// Img places an image object at (x,y)
func Img(x, y VGfloat, im image.Image) {
	bounds := im.Bounds()
	minx := bounds.Min.X
	maxx := bounds.Max.X
	miny := bounds.Min.Y
	maxy := bounds.Max.Y
	data := make([]C.VGubyte, bounds.Dx()*bounds.Dy()*4)
	n := 0
	var r, g, b, a uint32
	for yp := miny; yp < maxy; yp++ {
		for xp := minx; xp < maxx; xp++ {
			r, g, b, a = im.At(xp, (maxy-1)-yp).RGBA() // OpenVG has origin at lower left, y increasing up
			data[n] = C.VGubyte(r >> 8)
			n++
			data[n] = C.VGubyte(g >> 8)
			n++
			data[n] = C.VGubyte(b >> 8)
			n++
			data[n] = C.VGubyte(a >> 8)
			n++
		}
	}
	C.makeimage(C.VGfloat(x), C.VGfloat(y), C.int(bounds.Dx()), C.int(bounds.Dy()), &data[0])
}
开发者ID:jhautefeuille,项目名称:openvg,代码行数:25,代码来源:openvg.go

示例6: Ellipse

// Ellipse draws an ellipse at (x,y) with dimensions (w,h)
func Ellipse(x, y, w, h float64, style ...string) {
	C.Ellipse(C.VGfloat(x), C.VGfloat(y), C.VGfloat(w), C.VGfloat(h))
}
开发者ID:xranby,项目名称:openvg,代码行数:4,代码来源:openvg.go

示例7: Roundrect

// Rect draws a rounded rectangle at (x,y) with dimensions (w,h).
// the corner radii are at (rw, rh)
func Roundrect(x, y, w, h, rw, rh float64, style ...string) {
	C.Roundrect(C.VGfloat(x), C.VGfloat(y), C.VGfloat(w), C.VGfloat(h), C.VGfloat(rw), C.VGfloat(rh))
}
开发者ID:xranby,项目名称:openvg,代码行数:5,代码来源:openvg.go

示例8: Arc

// Arc draws an arc at (x,y) with dimensions (w,h).
// the arc starts at the angle sa, extended to aext
func Arc(x, y, w, h, sa, aext VGfloat) {
	C.Arc(C.VGfloat(x), C.VGfloat(y), C.VGfloat(w), C.VGfloat(h), C.VGfloat(sa), C.VGfloat(aext))
}
开发者ID:jhautefeuille,项目名称:openvg,代码行数:5,代码来源:openvg.go

示例9: Shear

// Shear warps the coordinate system by (x,y)
func Shear(x, y float64) {
	C.Shear(C.VGfloat(x), C.VGfloat(y))
}
开发者ID:xranby,项目名称:openvg,代码行数:4,代码来源:openvg.go

示例10: Translate

// Translate translates the coordinate system to (x,y)
func Translate(x, y float64) {
	C.Translate(C.VGfloat(x), C.VGfloat(y))
}
开发者ID:xranby,项目名称:openvg,代码行数:4,代码来源:openvg.go

示例11: Cbezier

// Cbezier draws a cubic bezier curve with extrema (sx, sy) and (ex, ey).
// Control points at (cx, cy) and (px, py)
func Cbezier(sx, sy, cx, cy, px, py, ex, ey float64, style ...string) {
	C.Cbezier(C.VGfloat(sx), C.VGfloat(sy), C.VGfloat(cx), C.VGfloat(cy), C.VGfloat(px), C.VGfloat(py), C.VGfloat(ex), C.VGfloat(ey))
}
开发者ID:xranby,项目名称:openvg,代码行数:5,代码来源:openvg.go

示例12: BackgroundRGB

// BackgroundRGB clears the screen with the specified background color using a RGBA quad
func BackgroundRGB(r, g, b uint8, alpha float64) {
	C.BackgroundRGB(C.uint(r), C.uint(g), C.uint(b), C.VGfloat(alpha))
}
开发者ID:xranby,项目名称:openvg,代码行数:4,代码来源:openvg.go

示例13: FillRGB

// FillRGB sets the fill color, using RGB triples
func FillRGB(r, g, b uint8, alpha float64) {
	C.Fill(C.uint(r), C.uint(g), C.uint(b), C.VGfloat(alpha))
}
开发者ID:xranby,项目名称:openvg,代码行数:4,代码来源:openvg.go

示例14: Shear

// Shear warps the coordinate system by (x,y)
func Shear(x, y VGfloat) {
	C.Shear(C.VGfloat(x), C.VGfloat(y))
}
开发者ID:jhautefeuille,项目名称:openvg,代码行数:4,代码来源:openvg.go

示例15: Scale

// Scale scales the coordinate system by (x,y)
func Scale(x, y VGfloat) {
	C.Scale(C.VGfloat(x), C.VGfloat(y))
}
开发者ID:jhautefeuille,项目名称:openvg,代码行数:4,代码来源:openvg.go


注:本文中的C.VGfloat函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。