本文整理汇总了Golang中github.com/ajstarks/openvg.VGfloat函数的典型用法代码示例。如果您正苦于以下问题:Golang VGfloat函数的具体用法?Golang VGfloat怎么用?Golang VGfloat使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了VGfloat函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: 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()
}
示例2: 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()
}
示例3: 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 = 15.0
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)
}
示例4: rain
// rain shows raindrops
func (d *dimen) rain(color string) {
dd := dimen{x: 0, y: 0, width: d.width / 6, height: d.height / 6}
for i := 0; i < 20; i++ {
dd.x = d.x + d.width*openvg.VGfloat(rand.Float64())
dd.y = d.y + d.height*openvg.VGfloat(rand.Float64())
dd.drop(color)
}
}
示例5: snow
// snow shows the snow icon
func (d *dimen) snow(color string) {
df := dimen{x: 0, y: 0, width: d.width / 6, height: d.height / 6}
for i := 0; i < 20; i++ {
df.x = d.x + d.width*openvg.VGfloat(rand.Float64())
df.y = d.y + d.height*openvg.VGfloat(rand.Float64())
df.flake(color)
}
}
示例6: main
// show the current time, weather and headlines
func main() {
var (
section = flag.String("h", "u.s.", "headline type (arts, health, sports, science, technology, u.s., world, hn)")
location = flag.String("loc", "40.6213,-74.4395", "lat,long for weather")
bgcolor = flag.String("bg", "slateblue", "background color")
textcolor = flag.String("tc", "white", "text color")
width = flag.Int("width", 0, "screen width")
height = flag.Int("height", 0, "screen height")
smartcolor = flag.Bool("sc", false, "smart colors")
thumb = flag.Bool("tn", false, "show thumbnails")
)
flag.Parse()
// initial display
dw, dh := openvg.Init()
if *width > 0 && *height > 0 {
dw, dh = *width, *height
}
openvg.Start(dw, dh)
canvas := display{
width: openvg.VGfloat(dw),
height: openvg.VGfloat(dh),
bgcolor: *bgcolor,
textcolor: *textcolor,
}
canvas.countdown()
openvg.End()
canvas.clock(*smartcolor)
canvas.weather(*location)
canvas.headlines(*section, *thumb)
// update on specific intervals, shutdown on interrupt
dateticker := time.NewTicker(1 * time.Minute)
weatherticker := time.NewTicker(5 * time.Minute)
headticker := time.NewTicker(10 * time.Minute)
sigint := make(chan os.Signal, 1)
signal.Notify(sigint, os.Interrupt)
for {
select {
case <-dateticker.C:
canvas.clock(*smartcolor)
case <-weatherticker.C:
canvas.weather(*location)
case <-headticker.C:
canvas.headlines(*section, *thumb)
case <-sigint:
openvg.Finish()
os.Exit(0)
}
}
}
示例7: 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()
}
示例8: 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)
}
示例9: 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()
}
示例10: 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()
}
示例11: 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)
}
示例12: 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()
}
示例13: 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()
}
示例14: 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)
}
}
示例15: flake
// flake shows the snowflake icon
func (d *dimen) flake(color string) {
x, y, w, h := d.x, d.y, d.width, d.height
cx := x + (w / 2)
cy := y + (h / 2)
r := w * 0.30
openvg.StrokeColor(color)
openvg.StrokeWidth(w / 20)
for t := 0.0; t < 2*math.Pi; t += math.Pi / 4 {
c := openvg.VGfloat(math.Cos(t))
s := openvg.VGfloat(math.Sin(t))
x1 := (r * c) + cx
y1 := (r * s) + cy
openvg.Line(cx, cy, x1, y1)
}
openvg.StrokeWidth(0)
}