Page 1 of 1
Scrolling Text
Posted: Wed May 07, 2014 2:03 pm
by Embedder
Hello,
i installed and tested openvg library on my rasmberry pi board. Examples are a good starting point for learning but i still can't figure out how to make a text move-scroll. in fact i want to make a newsticker in the bottom of the screen.
Can anybody give me a starting point for that.
Thanks
Re: Scrolling Text
Posted: Wed May 07, 2014 5:43 pm
by Embedder
i found this method for scrolling a string horizontally:
void Scroll(char const *str)
{
while (*str++)
{
puts(stdin,getsInLen(), MAX_SCROLL_CHAR);
}
}
i will use openvg Text() function instead of puts.
Any thoughts ?
Re: Scrolling Text
Posted: Sun May 11, 2014 7:01 pm
by ajstarks
Code: Select all
// text crawl
package main
import (
"bufio"
"github.com/ajstarks/openvg"
"os"
"time"
)
func main() {
width, height := openvg.Init()
x := openvg.VGfloat(width) * 0.10
h2 := openvg.VGfloat(height / 2)
w := openvg.VGfloat(width)
fs := width/20
s := "These are the times that try men's souls"
openvg.Start(width, height)
openvg.BackgroundColor("black")
for i := 0; i < len(s); i++ {
openvg.FillRGB(44, 100, 232, 1)
openvg.Rect(0, h2/2, w, h2)
openvg.FillColor("white")
openvg.Text(x, h2, s[i:], "serif", fs)
time.Sleep(150*time.Millisecond)
openvg.End()
}
openvg.FillRGB(44, 100, 232, 1)
openvg.Rect(0, h2/2, w, h2)
openvg.End()
bufio.NewReader(os.Stdin).ReadBytes('\n')
openvg.Finish()
}
Re: Scrolling Text
Posted: Mon May 12, 2014 3:32 pm
by Embedder
Thanks i will try that !