本文整理汇总了Golang中github.com/Ebiroll/openvg.VGfloat函数的典型用法代码示例。如果您正苦于以下问题:Golang VGfloat函数的具体用法?Golang VGfloat怎么用?Golang VGfloat使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了VGfloat函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: main
func main() {
var cx, cy, cw, ch, midy int
message := "Now is the time for all good men to come to the aid of the party"
w, h := openvg.Init()
var speed openvg.VGfloat = 0.5
var x openvg.VGfloat = 0
midy = (h / 2)
fontsize := w / 50
cx = 0
ch = fontsize * 2
cw = w
cy = midy - (ch / 2)
rx, ry, rw, rh := openvg.VGfloat(cx), openvg.VGfloat(cy), openvg.VGfloat(cw), openvg.VGfloat(ch)
// scroll the text, only in the clipping rectangle
for x = 0; x < rw+speed; x += speed {
openvg.Start(w, h)
openvg.Background(255, 255, 255)
openvg.FillRGB(0, 0, 0, .2)
openvg.Rect(rx, ry, rw, rh)
openvg.ClipRect(cx, cy, cw, ch)
openvg.Translate(x, ry+openvg.VGfloat(fontsize/2))
openvg.FillRGB(0, 0, 0, 1)
openvg.Text(0, 0, message, "sans", fontsize)
openvg.ClipEnd()
openvg.End()
}
bufio.NewReader(os.Stdin).ReadBytes('\n')
openvg.Finish()
os.Exit(0)
}
开发者ID:Ebiroll,项目名称:openvg,代码行数:32,代码来源:clip.go
示例2: imagetest
// imgtest draws images at the corners and center
func imagetest(w, h int) {
openvg.Start(w, h)
imgw := 422
imgh := 238
fiw := openvg.VGfloat(imgw)
fih := openvg.VGfloat(imgh)
fw := openvg.VGfloat(w)
fh := openvg.VGfloat(h)
vgzero := openvg.VGfloat(0.0)
cx := (fw / 2) - (fiw / 2)
cy := (fh / 2) - (fih / 2)
ulx := vgzero
uly := fh - fih
urx := fw - fiw
ury := uly
llx := vgzero
lly := vgzero
lrx := urx
lry := lly
openvg.Start(w, h)
openvg.Background(0, 0, 0)
openvg.Image(cx, cy, imgw, imgh, "desert1.jpg")
openvg.Image(ulx, uly, imgw, imgh, "desert2.jpg")
openvg.Image(urx, ury, imgw, imgh, "desert3.jpg")
openvg.Image(llx, lly, imgw, imgh, "desert4.jpg")
openvg.Image(lrx, lry, imgw, imgh, "desert5.jpg")
openvg.End()
}
开发者ID:Ebiroll,项目名称:openvg,代码行数:29,代码来源:shapedemo.go
示例3: main
func main() {
var color string
openvg.Start(width, height)
openvg.Background(200, 200, 200)
for i := 0; i < niter; i++ {
x := random(0, width)
y := random(height/3, (height*2)/3)
r := random(0, 10000)
switch {
case r >= 0 && r <= 2500:
color = "white"
case r > 2500 && r <= 5000:
color = "maroon"
case r > 5000 && r <= 7500:
color = "gray"
case r > 7500 && r <= 10000:
color = "black"
}
openvg.FillColor(color, openvg.VGfloat(opacity))
openvg.Circle(openvg.VGfloat(x), openvg.VGfloat(y), openvg.VGfloat(size))
}
openvg.End()
bufio.NewReader(os.Stdin).ReadByte()
openvg.Finish()
}
开发者ID:Ebiroll,项目名称:openvg,代码行数:25,代码来源:bubtrail.go
示例4: loadimage
// loadimage loads all the images of the deck into a map for later display
func loadimage(d deck.Deck, m map[string]image.Image) {
firstrun++
w, h := d.Canvas.Width, d.Canvas.Height
cw := openvg.VGfloat(w)
ch := openvg.VGfloat(h)
msize := int(cw * .01)
mx := cw / 2
my := ch * 0.05
mbg := "white"
mfg := "black"
for ns, s := range d.Slide {
for ni, i := range s.Image {
if !modfile(i.Name, StartTime) {
continue
}
openvg.Start(w, h)
if i.Link != "" {
fmt.Fprintf(os.Stderr, "Found altimg %s\n", i.Link)
}
f, err := os.Open(i.Name)
if err != nil {
fmt.Fprintf(os.Stderr, "%v\n", err)
continue
}
img, _, err := image.Decode(f)
if err != nil {
fmt.Fprintf(os.Stderr, "%v\n", err)
continue
}
openvg.FillColor(mbg)
openvg.Rect(0, 0, cw, ch)
openvg.FillColor(mfg)
openvg.TextMid(mx, my, fmt.Sprintf("Loading image %s %d from slide %d", i.Name, ni, ns), "sans", msize)
bounds := img.Bounds()
iw := i.Width
ih := i.Height
if i.Scale > 0 {
iw = int(float64(iw) * (i.Scale / 100))
ih = int(float64(ih) * (i.Scale / 100))
}
// if the specified dimensions are native use those, otherwise resize
if iw == (bounds.Max.X-bounds.Min.X) && ih == (bounds.Max.Y-bounds.Min.Y) {
m[i.Name] = img
} else {
g := gift.New(gift.Resize(iw, ih, gift.BoxResampling))
resized := image.NewRGBA(g.Bounds(img.Bounds()))
g.Draw(resized, img)
m[i.Name] = resized
}
f.Close()
openvg.End()
}
}
}
开发者ID:Ebiroll,项目名称:openvg,代码行数:55,代码来源:xmlview.go
示例5: arrowhand
func arrowhand(cx, cy, px, py, r openvg.VGfloat, t float64, value int, color string) {
ax := []openvg.VGfloat{cx, 0, px, 0, cx}
ay := []openvg.VGfloat{cy, 0, py, 0, cy}
t = minadjust(t, value) * deg2rad
rf := float64(r * 0.9)
tf := math.Pi / 45.0
ax[1] = cx + openvg.VGfloat(rf*math.Cos(t-tf))
ay[1] = cy + openvg.VGfloat(rf*math.Sin(t-tf))
ax[3] = cx + openvg.VGfloat(rf*math.Cos(t+tf))
ay[3] = cy + openvg.VGfloat(rf*math.Sin(t+tf))
openvg.FillColor(color)
openvg.Polygon(ax, ay)
}
开发者ID:Ebiroll,项目名称:openvg,代码行数:13,代码来源:clock.go
示例6: raspi
// raspberry pi, scaled to the screen dimensions
func raspi(w, h int, s string) {
midx := openvg.VGfloat(w) / 2
midy := openvg.VGfloat(h) / 2
rw := midx
rh := (rw * 2) / 3
fontsize := w / 25
openvg.Start(w, h)
openvg.Background(255, 255, 255)
makepi(midx-(rw/2), midy-(rh/2), rw, rh)
openvg.FillRGB(128, 0, 0, 1)
openvg.TextMid(midx, midy-(rh/2)-openvg.VGfloat(fontsize*2), s, "sans", fontsize)
openvg.End()
}
开发者ID:Ebiroll,项目名称:openvg,代码行数:14,代码来源:shapedemo.go
示例7: planets
//planets is an exploration of scale
func planets(width, height int, message string) {
w := openvg.VGfloat(width)
h := openvg.VGfloat(height)
y := h / 2
margin := openvg.VGfloat(100.0)
minsize := openvg.VGfloat(7.0)
labeloc := openvg.VGfloat(100.0)
bgcolor := "black"
labelcolor := "white"
maxsize := (h / 2) * 0.05
origin := sun.distance
mostDistant := neptune.distance
firstSize := mercury.radius
lastSize := neptune.radius
openvg.Start(width, height)
openvg.BackgroundColor(bgcolor)
for _, p := range solarSystem {
x := vmap(p.distance, origin, mostDistant, margin, w-margin)
r := vmap(p.radius, firstSize, lastSize, minsize, maxsize)
if p.name == "Sun" {
openvg.FillRGB(p.color.Red, p.color.Green, p.color.Blue, 1)
openvg.Circle(margin-(r/2), y, r)
} else {
light(x, y, r, p.color)
openvg.Circle(x, y, r)
if p.name == "Saturn" {
ringwidth := r * 2.35 // Saturn's rings are over 2x the planet radius
openvg.StrokeWidth(3)
openvg.StrokeRGB(p.color.Red, p.color.Green, p.color.Blue, 1)
openvg.Line((x - ringwidth/2), y, (x + ringwidth/2), y)
openvg.StrokeWidth(0)
}
}
if p.name == "Earth" && len(message) > 1 {
openvg.StrokeColor(labelcolor)
openvg.StrokeWidth(1)
openvg.Line(x, y+(r/2), x, y+labeloc)
openvg.StrokeWidth(0)
openvg.FillColor(labelcolor)
openvg.TextMid(x, y+labeloc+10, message, "sans", 12)
}
}
openvg.End()
}
开发者ID:Ebiroll,项目名称:openvg,代码行数:51,代码来源:shapedemo.go
示例8: draw
func draw(w, h openvg.VGfloat) {
paintBG(w, h)
var p particle
var grav = openvg.VGfloat(gravity)
for i := 0; i < nparticles; i++ {
p = particles[i]
openvg.FillRGB(p.r, p.g, p.b, 1)
openvg.Circle(p.x, p.y, p.radius)
// Apply the velocity
p.x += p.vx
p.y += p.vy
p.vx *= 0.98
if p.vy > 0 {
p.vy *= 0.97
}
// Gravity
p.vy -= grav
// Stop p leaving the canvas
if p.x < -50 {
p.x = w + 50
}
if p.x > w+50 {
p.x = -50
}
// When particle reaches the bottom of screen reset velocity & start posn
if p.y < -50 {
p.x = 0
p.y = 0
p.vx = openvg.VGfloat(rand.Intn(maxrand)%30) + 30
p.vy = openvg.VGfloat(rand.Intn(maxrand)%20) + 40
if directionRTL {
p.vx *= -1
p.x = w
}
}
if p.y > h+50 {
p.y = -50
}
particles[i] = p
}
openvg.End()
}
开发者ID:Ebiroll,项目名称:openvg,代码行数:50,代码来源:particles.go
示例9: combohand
func combohand(cx, cy, px, py, r, stroke openvg.VGfloat, t float64, value int, color string) {
thinr := float64(r * 0.25)
t = minadjust(t, value) * deg2rad
tx := cx + openvg.VGfloat(thinr*math.Cos(t))
ty := cy + openvg.VGfloat(thinr*math.Sin(t))
openvg.FillColor(color)
openvg.Ellipse(px, py, stroke*2, stroke*2)
openvg.Ellipse(tx, ty, stroke*2, stroke*2)
openvg.StrokeWidth(stroke)
openvg.StrokeColor(color)
openvg.Line(cx, cy, tx, ty)
openvg.StrokeWidth(stroke * 2)
openvg.Line(tx, ty, px, py)
openvg.StrokeWidth(0)
}
开发者ID:Ebiroll,项目名称:openvg,代码行数:15,代码来源:clock.go
示例10: main
// raspberry pi, scaled to the screen dimensions
func main() {
w, h := openvg.Init()
midx := openvg.VGfloat(w) / 2
midy := openvg.VGfloat(h) / 2
rw := midx
rh := (rw * 2) / 3
fontsize := w / 25
openvg.Start(w, h)
openvg.Background(255, 255, 255)
makepi(midx-(rw/2), midy-(rh/2), rw, rh)
makepi(200, 100, 75, 50)
openvg.FillRGB(128, 0, 0, 1)
openvg.TextMid(midx, midy-(rh/2)-openvg.VGfloat(fontsize*2), "The Raspberry Pi", "sans", fontsize)
WaitEnd()
}
开发者ID:Ebiroll,项目名称:openvg,代码行数:16,代码来源:raspi.go
示例11: main
func main() {
width, height := openvg.Init()
w := openvg.VGfloat(width)
h := openvg.VGfloat(height)
y := h / 2
var (
margin openvg.VGfloat = 100.0
minsize openvg.VGfloat = 7.0
labeloc openvg.VGfloat = 100.0
)
bgcolor := "black"
labelcolor := "white"
maxsize := (h / 2) * 0.05
origin := sun.distance
mostDistant := neptune.distance
firstSize := mercury.radius
lastSize := neptune.radius
openvg.Start(width, height)
openvg.BackgroundColor(bgcolor)
for _, p := range solarSystem {
x := vmap(p.distance, origin, mostDistant, margin, w-margin)
r := vmap(p.radius, firstSize, lastSize, minsize, maxsize)
if p.name == "Sun" {
openvg.FillRGB(p.color.Red, p.color.Green, p.color.Blue, 1)
openvg.Circle(margin-(r/2), y, r)
} else {
light(x, y, r, p.color)
openvg.Circle(x, y, r)
}
if p.name == "Earth" && len(os.Args) > 1 {
openvg.StrokeColor(labelcolor)
openvg.StrokeWidth(1)
openvg.Line(x, y+(r/2), x, y+labeloc)
openvg.StrokeWidth(0)
openvg.FillColor(labelcolor)
openvg.TextMid(x, y+labeloc+10, os.Args[1], "sans", 12)
}
}
openvg.End()
bufio.NewReader(os.Stdin).ReadByte()
openvg.Finish()
}
开发者ID:Ebiroll,项目名称:openvg,代码行数:48,代码来源:planets.go
示例12: fitwidth
// adjust the font to fit within a width
func (f *FW) fitwidth(width, adj int, s string) {
f.tw = openvg.TextWidth(s, f.font, f.fontsize)
for f.tw > openvg.VGfloat(width) {
f.fontsize -= adj
f.tw = openvg.TextWidth(s, f.font, f.fontsize)
}
}
开发者ID:Ebiroll,项目名称:openvg,代码行数:8,代码来源:shapedemo.go
示例13: rshapes
// rshapes draws shapes with random colors, openvg.Strokes, and sizes.
func rshapes(width, height, n int) {
var sx, sy, cx, cy, px, py, ex, ey, pox, poy openvg.VGfloat
np := 10
polyx := make([]openvg.VGfloat, np)
polyy := make([]openvg.VGfloat, np)
openvg.Start(width, height)
for i := 0; i < n; i++ {
openvg.FillRGB(randcolor(), randcolor(), randcolor(), openvg.VGfloat(rand.Float32()))
openvg.Ellipse(randf(width), randf(height), randf(200), randf(100))
openvg.Circle(randf(width), randf(height), randf(100))
openvg.Rect(randf(width), randf(height), randf(200), randf(100))
openvg.Arc(randf(width), randf(height), randf(200), randf(200), randf(360), randf(360))
sx = randf(width)
sy = randf(height)
openvg.StrokeRGB(randcolor(), randcolor(), randcolor(), 1)
openvg.StrokeWidth(randf(5))
openvg.Line(sx, sy, sx+randf(200), sy+randf(100))
openvg.StrokeWidth(0)
sx = randf(width)
sy = randf(height)
ex = sx + randf(200)
ey = sy
cx = sx + ((ex - sx) / 2.0)
cy = sy + randf(100)
openvg.Qbezier(sx, sy, cx, cy, ex, ey)
sx = randf(width)
sy = randf(height)
ex = sx + randf(200)
ey = sy
cx = sx + ((ex - sx) / 2.0)
cy = sy + randf(100)
px = cx
py = sy - randf(100)
openvg.Cbezier(sx, sy, cx, cy, px, py, ex, ey)
pox = randf(width)
poy = randf(height)
for j := 0; j < np; j++ {
polyx[j] = pox + randf(200)
polyy[j] = poy + randf(100)
}
openvg.Polygon(polyx, polyy) // , np)
pox = randf(width)
poy = randf(height)
for j := 0; j < np; j++ {
polyx[j] = pox + randf(200)
polyy[j] = poy + randf(100)
}
openvg.Polyline(polyx, polyy) // , np)
}
openvg.FillRGB(128, 0, 0, 1)
openvg.Text(20, 20, "OpenVG on the Raspberry Pi", "sans", 32)
openvg.End()
}
开发者ID:Ebiroll,项目名称:openvg,代码行数:61,代码来源:shapedemo.go
示例14: main
func main() {
width, height := openvg.Init() // OpenGL, etc initialization
w2 := openvg.VGfloat(width / 2)
h2 := openvg.VGfloat(height / 2)
w := openvg.VGfloat(width)
openvg.Start(width, height) // Start the picture
openvg.BackgroundColor("black") // Black background
openvg.FillRGB(44, 100, 232, 1) // Big blue marble
openvg.Circle(w2, 0, w) // The "world"
openvg.FillColor("white") // White text
openvg.TextMid(w2, h2, "hello, world", "serif", width/10) // Greetings
openvg.End() // End the picture
bufio.NewReader(os.Stdin).ReadBytes('\n') // Pause until [RETURN]
openvg.Finish() // Graphics cleanup
}
开发者ID:Ebiroll,项目名称:openvg,代码行数:17,代码来源:hellovg.go
示例15: tb
// tb draws a block of text
func tb(w, h int) {
para := []string{
"For lo,",
"the winter is past,",
"the rain is over and gone",
"the flowers appear on the earth;",
"the time for the singing of birds is come,",
"and the voice of the turtle is heard in our land",
}
tmargin := openvg.VGfloat(w) * 0.50
lmargin := openvg.VGfloat(w) * 0.10
top := openvg.VGfloat(h) * .9
mid := openvg.VGfloat(h) * .6
bot := openvg.VGfloat(h) * .3
fontsize := 24
leading := openvg.VGfloat(40.0)
lfontsize := fontsize * 2
midb := ((leading * 2) + (leading / 2)) - openvg.VGfloat(lfontsize/2)
openvg.Start(w, h)
openvg.FillRGB(49, 79, 79, 1)
textlines(tmargin, top, para, "serif", fontsize, leading)
textlines(tmargin, mid, para, "sans", fontsize, leading)
textlines(tmargin, bot, para, "mono", fontsize, leading)
openvg.Text(lmargin, top-midb, "Serif", "sans", lfontsize)
openvg.Text(lmargin, mid-midb, "Sans", "sans", lfontsize)
openvg.Text(lmargin, bot-midb, "Mono", "sans", lfontsize)
openvg.End()
}
开发者ID:Ebiroll,项目名称:openvg,代码行数:32,代码来源:shapedemo.go
示例16: initParticles
// Initialize _all_ the particles
func initParticles(w, h openvg.VGfloat) {
particles = make([]particle, nparticles)
for i := 0; i < nparticles; i++ {
particles[i].x = 0
particles[i].y = 0
particles[i].vx = openvg.VGfloat(rand.Intn(maxrand)%30) + 30/100
particles[i].vy = openvg.VGfloat(rand.Intn(maxrand)%20) + 40/100
particles[i].r = uint8(rand.Intn(255))
particles[i].g = uint8(rand.Intn(255))
particles[i].b = uint8(rand.Intn(255))
particles[i].radius = openvg.VGfloat(rand.Intn(maxrand)%20) + 20
if directionRTL {
particles[i].vx *= -0.01
particles[i].x = w
}
}
}
开发者ID:Ebiroll,项目名称:openvg,代码行数:19,代码来源:particles.go
示例17: dodeck
// dodeck sets up the graphics environment and kicks off the interaction
func dodeck(filename, searchterm string, pausetime time.Duration, slidenum, cw, ch int, gp float64) {
firstrun = 0
w, h := openvg.Init()
openvg.FillRGB(200, 200, 200, 1)
openvg.Rect(0, 0, openvg.VGfloat(w), openvg.VGfloat(h))
if cw > 0 {
w = cw
}
if ch > 0 {
h = ch
}
if pausetime == 0 {
interact(filename, searchterm, w, h, slidenum, gp)
} else {
loop(filename, w, h, slidenum, pausetime)
}
openvg.Finish()
}
开发者ID:Ebiroll,项目名称:openvg,代码行数:19,代码来源:xmlview.go
示例18: PlayVideo
func PlayVideo(w, h int) {
for {
openvg.Video(openvg.VGfloat(w-900), openvg.VGfloat(h-600), openvg.VGfloat(800), openvg.VGfloat(600), "siATM_video2.mpg.h264")
openvg.Video(openvg.VGfloat(w-900), openvg.VGfloat(h-600), openvg.VGfloat(800), openvg.VGfloat(600), "sketchers_15s.ogv.h264")
}
//openvg.Video(openvg.VGfloat(w-800),openvg.VGfloat(h-600),openvg.VGfloat(800),openvg.VGfloat(600),"test.h264")
//openvg.Video(openvg.VGfloat(w-800),openvg.VGfloat(h-600),openvg.VGfloat(800),openvg.VGfloat(600),"test.h264")
}
开发者ID:Ebiroll,项目名称:openvg,代码行数:11,代码来源:viwer.go
示例19: gradient
func gradient(width, height int) {
w := openvg.VGfloat(width)
h := openvg.VGfloat(height)
stops := []openvg.Offcolor{
{0.0, openvg.RGB{255, 255, 255}, 1.0},
{0.5, openvg.RGB{128, 128, 128}, 1.0},
{1.0, openvg.RGB{0, 0, 0}, 1.0},
}
x1 := w / 8
x2 := (w * 3) / 8
y1 := h / 3
y2 := (h * 2) / 3
cx := (w * 3) / 4
cy := (h / 2)
r := (x2 - x1)
fx := cx + (r / 4)
fy := cy + (r / 4)
openvg.Start(width, height)
openvg.BackgroundRGB(128, 128, 128, 1)
openvg.FillLinearGradient(x1, y1, x2, y2, stops)
openvg.Rect(x1, y1, x2-x1, y2-y1)
openvg.FillRadialGradient(cx, cy, fx, fy, r, stops)
openvg.Circle(cx, cy, r)
openvg.FillRGB(0, 0, 0, 0.3)
openvg.Circle(x1, y1, 10)
openvg.Circle(x2, y2, 10)
openvg.Circle(cx, cy, 10)
openvg.Circle(cx+r/2, cy, 10)
openvg.Circle(fx, fy, 10)
openvg.FillColor("black")
SansTypeface := "sans"
openvg.TextMid(x1, y1-20, "(x1, y1)", SansTypeface, 18)
openvg.TextMid(x2, y2+10, "(x2, y2)", SansTypeface, 18)
openvg.TextMid(cx, cy, "(cx, cy)", SansTypeface, 18)
openvg.TextMid(fx, fy, "(fx, fy)", SansTypeface, 18)
openvg.TextEnd(cx+(r/2)+20, cy, "r", SansTypeface, 18)
openvg.TextMid(x1+((x2-x1)/2), h/6, "Linear Gradient", SansTypeface, 36)
openvg.TextMid(cx, h/6, "Radial Gradient", SansTypeface, 36)
openvg.End()
}
开发者ID:Ebiroll,项目名称:openvg,代码行数:44,代码来源:shapedemo.go
示例20: textplay
// textplay exercises text functions
func textplay(w, h int) {
forlo := `For lo, the winter is past, the rain is over and gone. The flowers appear on the earth, the time for the singing of birds is come, and the voice of the turtle is heard in our land.`
// forsince := `For since by man came death, by man came also the resurrection of the dead, for as in Adam all die, even so in Christ shall all be made alive.`
openvg.Start(w, h)
var (
tw openvg.VGfloat = 300
begin openvg.VGfloat = 50
xincr openvg.VGfloat = 400
offset openvg.VGfloat = 100
)
for x, y := begin, openvg.VGfloat(h)-offset; x < openvg.VGfloat(w/2); x += xincr {
textwrap(x, y, tw, forlo, "sans", 12, 24, 0.25, "black")
textwrap(x, y-400, tw, forlo, "sans", 12, 24, 0.5, "black")
tw -= offset
}
openvg.End()
}
开发者ID:Ebiroll,项目名称:openvg,代码行数:20,代码来源:shapedemo.go
注:本文中的github.com/Ebiroll/openvg.VGfloat函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论