本文整理匯總了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])
}
示例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)
}
示例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)
}
示例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])
}
示例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])
}
示例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))
}
示例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))
}
示例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))
}
示例9: Shear
// Shear warps the coordinate system by (x,y)
func Shear(x, y float64) {
C.Shear(C.VGfloat(x), C.VGfloat(y))
}
示例10: Translate
// Translate translates the coordinate system to (x,y)
func Translate(x, y float64) {
C.Translate(C.VGfloat(x), C.VGfloat(y))
}
示例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))
}
示例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))
}
示例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))
}
示例14: Shear
// Shear warps the coordinate system by (x,y)
func Shear(x, y VGfloat) {
C.Shear(C.VGfloat(x), C.VGfloat(y))
}
示例15: Scale
// Scale scales the coordinate system by (x,y)
func Scale(x, y VGfloat) {
C.Scale(C.VGfloat(x), C.VGfloat(y))
}