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) }
func init() { width, height = openvg.Init() flag.Float64Var(&size, "s", float64(width)*.05, "bubble size") flag.IntVar(&niter, "n", width/6, "number of iterations") flag.Float64Var(&opacity, "o", 0.5, "opacity") flag.Parse() rand.Seed(int64(time.Now().Nanosecond()) % 1e9) }
// main initializes the system and shows the picture. // Exit and clean up when you hit [RETURN]. func main() { rseed() openvg.SaveTerm() nargs := len(os.Args) w, h := openvg.Init() openvg.RawTerm() progname := os.Args[0] n := 5 if nargs > 2 { n, _ = strconv.Atoi(os.Args[2]) } if nargs > 1 { switch os.Args[1] { case "help": usage(progname) os.Exit(1) case "advert": advert(w, h) case "image": imagetable(w, h) case "text": tb(w, h) case "textplay": textplay(w, h) case "astro": planets(w, h, "You are here") case "fontsize": fontrange(w, h) case "raspi": raspi(w, h, "The Raspberry Pi") case "loop": loop(w, h) case "demo": demo(w, h, n) case "rand": rshapes(w, h, n) case "test": testpattern(w, h, "hello, world") case "rotate": rotext(w, h, n, "Raspi") case "gradient": gradient(w, h) default: refcard(w, h) } } else { refcard(w, h) } WaitEnd() }
// 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() }
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() }
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 }
// 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() }
func main() { setOptions() rand.Seed(time.Now().Unix()) w, h := openvg.Init() width, height := openvg.VGfloat(w), openvg.VGfloat(h) initParticles(width, height) openvg.Start(w, h) i := 0 for { draw(width, height) time.Sleep(2 * time.Millisecond) //fmt.Printf(".") i++ if alternate && i == nswitch { // switch launch direction every nswitch draws directionRTL = !directionRTL i = 0 } } }
func main() { var loop = flag.Bool("loop", false, "Loop the show") var resize = flag.Bool("resize", false, `Resize image to fit the screen.`) var bgcolor = flag.String("bg", "black", `Background color (named color or rgb(r,g,b)).`) var delay = flag.Duration("delay", 2*time.Second, "Delay between pictures") flag.Usage = func() { fmt.Fprintf(os.Stderr, "usage: %s [ flags ] images...\n", os.Args[0]) flag.PrintDefaults() os.Exit(1) } flag.Parse() w, h := openvg.Init() images := []image.Image{} imgcount := 0 for _, imgfile := range flag.Args() { fmt.Fprintf(os.Stderr, "loading %q ", imgfile) img, err := getimage(imgfile, w, h, *resize) if err != nil { fmt.Fprintln(os.Stderr, err) continue } images = append(images, img) imgcount++ fmt.Fprintln(os.Stderr, "ok") } for { for _, img := range images { ib := img.Bounds() imw, imh := ib.Max.X-ib.Min.X, ib.Max.Y-ib.Min.Y openvg.Start(w, h) openvg.BackgroundColor(*bgcolor) x, y := openvg.VGfloat(w)/2-openvg.VGfloat(imw)/2, openvg.VGfloat(h)/2-openvg.VGfloat(imh)/2 openvg.Img(x, y, img) openvg.End() time.Sleep(*delay) } if !*loop { break } } }
// main plots data from specified files or standard input in a // grid where plotc specifies the number of columns. func main() { w, h := openvg.Init() i := 1 filenames := flag.Args() for i <= 1000 { openvg.Start(w, h) openvg.FillColor("white") openvg.Rect(0, 0, gwidth, gheight) if len(filenames) == 0 { doplot(beginx, beginy, "") } else { plotgrid(beginx, beginy, filenames) } openvg.End() i = i + 1 } bufio.NewReader(os.Stdin).ReadByte() openvg.Finish() }
func main() { width, height := openvg.Init() // OpenGL, etc initialization w2 := openvg.VGfloat(width / 2) h2 := openvg.VGfloat(height / 2) w := openvg.VGfloat(width) stops := []openvg.Offcolor{ {0.0, openvg.RGB{44, 100, 232}, 1.0}, // blue-ish {0.5, openvg.RGB{22, 50, 151}, 1.0}, // darker blue {1.0, openvg.RGB{88, 200, 255}, 1.0}, // lighter blue } openvg.Start(width, height) // Start the picture openvg.BackgroundColor("black") // Black background openvg.FillRadialGradient(w2, 0, w2, w2, w*.5, stops) // 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.SaveEnd("hvg.raw") // End the picture openvg.End() bufio.NewReader(os.Stdin).ReadBytes('\n') // Pause until [RETURN] openvg.Finish() // Graphics cleanup }
func main() { var nr = flag.Int("n", 500, "number of objects") var message = flag.String("m", "Go/OpenVG", "message") var bgcolor = flag.String("bg", "white", "background color") var fgcolor = flag.String("fg", "maroon", "text color") flag.Parse() rseed() width, height := openvg.Init() fw := openvg.VGfloat(width) fh := openvg.VGfloat(height) openvg.Start(width, height) openvg.BackgroundColor(*bgcolor) for i := 0; i < *nr; i++ { red := uint8(rand.Intn(255)) green := uint8(rand.Intn(255)) blue := uint8(rand.Intn(255)) alpha := randf() x := randf() * fw y := randf() * fh radius := randf() * fw / 10 openvg.FillRGB(red, green, blue, alpha) openvg.Circle(x, y, radius) } openvg.FillColor(*fgcolor) openvg.TextMid(fw/2, fh/2, *message, "sans", width/25) openvg.End() bufio.NewReader(os.Stdin).ReadBytes('\n') openvg.Finish() }
func main() { var resize = flag.Bool("resize", false, "Resize image to fit the screen.") var bgcolor = flag.String("bg", "black", "Background color (named color or rgb(r,g,b)).") var fgcolor = flag.String("fg", "white", "text color (named color or rgb(r,g,b)).") var title = flag.String("t", "", "text annotation") var fontsize = flag.Float64("fp", 2.0, "fontsize %") var px = flag.Float64("px", 50, "x position %") var py = flag.Float64("py", 50, "y position %") var texty = flag.Float64("ty", 0, "text y %") var exit_code int defer func() { os.Exit(exit_code) }() flag.Usage = func() { fmt.Fprintf(os.Stderr, `usage: %s [ flags ] image-path Set specified image as an overlay screen via OpenVG lib. Default is to put this image to the center. `, os.Args[0]) flag.PrintDefaults() exit_code = 1 return } flag.Parse() if flag.NArg() != 1 { fmt.Fprintf(os.Stderr, "Exactly one image-path argument must be specified.\n") flag.Usage() exit_code = 2 return } openvg.SaveTerm() w, h := openvg.Init() openvg.RawTerm() defer openvg.Finish() defer openvg.RestoreTerm() img, err := getimage(flag.Args()[0], w, h, *resize) if err != nil { exit_code = 3 return } ib := img.Bounds() imw, imh := ib.Max.X-ib.Min.X, ib.Max.Y-ib.Min.Y sig_chan := make(chan os.Signal, 1) signal.Notify(sig_chan, os.Interrupt, os.Kill, syscall.SIGHUP, syscall.SIGTERM, syscall.SIGALRM) openvg.Start(w, h) openvg.BackgroundColor(*bgcolor) var x, y openvg.VGfloat if *px < 0 || *px > 100 { x = openvg.VGfloat(w)/2 - openvg.VGfloat(imw)/2 } else { x = openvg.VGfloat(w)*openvg.VGfloat(*px/100) - openvg.VGfloat(imw)/2 } if *py < 0 || *py > 100 { y = openvg.VGfloat(h)/2 - openvg.VGfloat(imh)/2 } else { y = openvg.VGfloat(h)*openvg.VGfloat(*py/100) - openvg.VGfloat(imh)/2 } openvg.Img(x, y, img) if len(*title) > 0 { var typ openvg.VGfloat fs := openvg.VGfloat(*fontsize/100.0) * openvg.VGfloat(w) if *texty == 0 { typ = y - fs*1.5 } else { typ = openvg.VGfloat(h) * openvg.VGfloat(*texty/100) } openvg.FillColor(*fgcolor) openvg.TextMid(x+openvg.VGfloat(imw)/2, typ, *title, "sans", int(fs)) } openvg.End() _ = <-sig_chan }
func main() { flag.StringVar(&mincolor, "mincolor", "maroon", "minute color") flag.StringVar(&facecolor, "facecolor", "white", "face color") flag.StringVar(&hrcolor, "hourcolor", "gray", "hour color") flag.StringVar(&secolor, "secolor", "maroon", "second color") flag.StringVar(&digitcolor, "digitcolor", "black", "digit color") flag.StringVar(&dotcolor, "dotcolor", "silver", "dotcolor") flag.StringVar(&framecolor, "framecolor", "gray", "frame color") flag.StringVar(¢ercolor, "centercolor", "black", "center color") flag.StringVar(&handstyle, "handstyle", "combo", "handstyle (combo, arrow, or round)") flag.BoolVar(&showdigits, "showdigits", true, "show digits") flag.BoolVar(&showdots, "showdots", true, "show dots") flag.BoolVar(&secline, "secline", false, "show second hand") flag.Parse() width, height := openvg.Init() cx := openvg.VGfloat(width / 2) cy := openvg.VGfloat(height / 2) facesize := openvg.VGfloat(cy * 0.5) textsize := facesize / 10.0 framesize := facesize * 2.5 hourstroke := textsize minstroke := hourstroke * .6 // set up the ticker and signal handler ticker := time.NewTicker(1 * time.Second) sigint := make(chan os.Signal, 1) signal.Notify(sigint, os.Interrupt) // main loop: for each second, draw the clock components openvg.Start(width, height) for { select { case <-ticker.C: // get the current time hr, min, sec := time.Now().Clock() // compute element coordinates hx, hy, mx, my, sx, sy := timecoord(cx, cy, facesize, hr, min, sec) // frame and clock face frame(cx, cy, framesize, facesize, textsize, framecolor, facecolor) face(cx, cy, facesize, int(textsize*1.5)) // hour and minute hands switch handstyle { case "round", "r": roundhand(cx, cy, mx, my, minstroke, mincolor) roundhand(cx, cy, hx, hy, hourstroke, hrcolor) case "arrow", "a": arrowhand(cx, cy, mx, my, facesize*0.9, minangles[min], 0, mincolor) arrowhand(cx, cy, hx, hy, facesize*0.6, hourangles[hr%12], min, hrcolor) case "combo", "c": combohand(cx, cy, mx, my, facesize*0.9, minstroke/2, minangles[min], 0, mincolor) combohand(cx, cy, hx, hy, facesize*0.6, minstroke/2, hourangles[hr%12], min, hrcolor) default: combohand(cx, cy, mx, my, facesize*0.9, minstroke/2, minangles[min], 0, mincolor) combohand(cx, cy, hx, hy, facesize*0.6, minstroke/2, hourangles[hr%12], min, hrcolor) } // second indicator secondhand(cx, cy, sx, sy, textsize) // center dot centerdot(cx, cy, textsize) // make the picture openvg.End() case <-sigint: openvg.Finish() return } } }
func main() { var ( filename = flag.String("f", "svgcolors.txt", "input file") fontname = flag.String("font", "sans", "fontname") neg = flag.Bool("neg", false, "negative") showrgb = flag.Bool("rgb", false, "show RGB") showcode = flag.Bool("showcode", true, "show colors and codes") circsw = flag.Bool("circle", true, "circle swatch") outline = flag.Bool("outline", false, "outline swatch") fontsize = flag.Int("fs", 12, "fontsize") rowsize = flag.Int("r", 32, "rowsize") colw = flag.Float64("c", 340, "column size") swatch = flag.Float64("s", 16, "swatch size") gutter = flag.Float64("g", 12, "gutter") err error tcolor, line string ) flag.Parse() f, oerr := os.Open(*filename) if oerr != nil { fmt.Fprintf(os.Stderr, "%v\n", oerr) return } width, height := openvg.Init() openvg.Start(width, height) fw := openvg.VGfloat(width) fh := openvg.VGfloat(height) if *neg { openvg.FillColor("black") openvg.Rect(0, 0, fw, fh) tcolor = "white" } else { openvg.FillColor("white") openvg.Rect(0, 0, fw, fh) tcolor = "black" } top := fh - 32.0 left := openvg.VGfloat(32.0) cw := openvg.VGfloat(*colw) sw := openvg.VGfloat(*swatch) g := openvg.VGfloat(*gutter) in := bufio.NewReader(f) for x, y, nr := left, top, 0; err == nil; nr++ { line, err = in.ReadString('\n') fields := strings.Split(strings.TrimSpace(line), "\t") if nr%*rowsize == 0 && nr > 0 { x += cw y = top } if len(fields) == 3 { var red, green, blue uint8 fmt.Sscanf(fields[2], "%d,%d,%d", &red, &green, &blue) openvg.FillRGB(red, green, blue, 1) if *outline { openvg.StrokeColor("black") openvg.StrokeWidth(1) } if *circsw { openvg.Circle(x+sw/2, y+sw/2, sw) } else { openvg.Rect(x, y, sw, sw) } openvg.StrokeWidth(0) openvg.FillColor(tcolor) openvg.Text(x+sw+openvg.VGfloat(*fontsize/2), y, fields[0], *fontname, *fontsize) var label string if *showcode { if *showrgb { label = fields[1] } else { label = fields[2] } openvg.FillColor("gray") openvg.TextEnd(x+cw-(sw+g), y, label, *fontname, *fontsize) } } y -= (sw + g) } openvg.End() bufio.NewReader(os.Stdin).ReadBytes('\n') openvg.Finish() }
func main() { var sreenHeight, cx, cy, cw, ch int message := "Hej Sandra tack forden mysiga kramen ..... <3 <3 Puss puss" w, h := openvg.Init() sreenHeight = h var speed openvg.VGfloat = 4.0 var x openvg.VGfloat = 0 //midy = (h / 2) fontsize := w / 50 cx = 0 ch = fontsize * 2 cw = w //cy = midy - (ch / 2) cy = h - 80 var jsonData SLData var lastmill = makeTimestamp() response, err := http.Get("http://localhost:8000") if err == nil { defer response.Body.Close() contents, err := ioutil.ReadAll(response.Body) if err != nil { fmt.Printf("Error reading http data, %s", err) } else { fmt.Printf("Got: %s\n", string(contents)) if err := json.Unmarshal(contents, &jsonData); err != nil { panic(err) } fmt.Println(jsonData) } } openvg.Start(w, h) openvg.End() go PlayVideo(w, h) for { openvg.Start(w, h) //fmt.Println("W,H",w,h) 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 { var mill = makeTimestamp() var delta = (mill - lastmill) / 5 //fmt.Println("delta ", delta) //speed x = openvg.VGfloat(delta) imgw, imgh := 0, 0 openvg.Background(0, 0, 0) //SLHeight = 60 var imgPosY = openvg.VGfloat(sreenHeight - 120) openvg.Image(8, imgPosY, imgw, imgh, "DA4FID.png") var TAB1 = openvg.VGfloat(4 * w / 20) //var TAB2 = openvg.VGfloat(8*w/20) rx1, rw1, rh1 := openvg.VGfloat(cx), openvg.VGfloat(cw), openvg.VGfloat(ch) ty := 0 rix := 0 // - (120 + int(rh1)) ty = sreenHeight - 140 var trainIx = 0 for ty = ty - 20; ty > 0 && trainIx < len(jsonData.ResponseData.Trains); ty -= ch { tempy := openvg.VGfloat(ty) //ry := openvg.VGfloat(ty) if rix%2 == 0 { openvg.FillRGB(255, 255, 255, .2) //openvg.Rect(rx1, tempy, rw1, rh1) tempy = tempy + 6.0 } else { openvg.FillRGB(255, 255, 255, .4) openvg.Rect(rx1, tempy, rw1/3, rh1) tempy = tempy + 6.0 } openvg.FillRGB(255, 255, 255, 1) //openvg.Text(rx1, tempy, jsonData.ResponseData.Trains[trainIx].LineNumber , "sans", fontsize) //drawTypeOfTransport(rx1+55,tempy+4,rw1,ch-20,jsonData.ResponseData.Trains[trainIx].TransportMode) openvg.Text(rx1, tempy, jsonData.ResponseData.Trains[trainIx].DisplayTime, "sans", fontsize) var dest = jsonData.ResponseData.Trains[trainIx].Destination dest = replaceAO(dest) openvg.Text(rx1+TAB1, tempy, dest, "sans", fontsize) //openvg.Translate(x, ry+openvg.VGfloat(fontsize/2)) //openvg.Background(255,255,0) trainIx = trainIx + 1 rix = rix + 1 } imgw = 20 imgh = 20 //openvg.Image(8, 100 , imgw, imgh, "no_smoking.png") // openvg.Start(w, h) //openvg.Background(255, 255, 255) openvg.FillRGB(100, 0, 0, 1) openvg.Rect(rx, ry, rw, rh) //openvg.ClipRect(cx, cy, cw, ch) //openvg.Translate(x, ry+openvg.VGfloat(fontsize/2)) openvg.FillRGB(255, 255, 255, 1) var pxp openvg.VGfloat = openvg.VGfloat(w) - openvg.VGfloat(x) var pyp openvg.VGfloat = openvg.VGfloat(h) - openvg.VGfloat(58) openvg.Text(pxp, pyp, message, "sans", fontsize) //openvg.ClipEnd() openvg.End() } //openvg.SaveEnd("dump.raw") //time.Sleep(60*time.Second); } bufio.NewReader(os.Stdin).ReadBytes('\n') bufio.NewReader(os.Stdin).ReadBytes('\n') openvg.Finish() os.Exit(0) }
func main() { var sreenHeight, cx, cy, cw, ch, midy int message := "Scrolling texts could be useful if the information does not fit on screen" w, h := openvg.Init() sreenHeight = h 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) var jsonData SLData for { response, err := http.Get("http://localhost:8000") if err == nil { defer response.Body.Close() contents, err := ioutil.ReadAll(response.Body) if err != nil { fmt.Printf("Error reading http data, %s", err) } else { fmt.Printf("Got: %s\n", string(contents)) if err := json.Unmarshal(contents, &jsonData); err != nil { panic(err) } fmt.Println(jsonData) } } openvg.Start(w, h) imgw, imgh := 0, 0 openvg.Background(255, 255, 255) //SLHeight = 60 var imgPosY = openvg.VGfloat(sreenHeight - 70) openvg.Image(4, imgPosY, imgw, imgh, "SL.jpg") var TAB1 = openvg.VGfloat(4 * w / 20) var TAB2 = openvg.VGfloat(8 * w / 20) rx1, rw1, rh1 := openvg.VGfloat(cx), openvg.VGfloat(cw), openvg.VGfloat(ch) ty := 0 rix := 0 // Buses for ty = sreenHeight - (80 + int(rh1)); ty > 0 && rix < len(jsonData.ResponseData.Buses); ty -= ch { tempy := openvg.VGfloat(ty) //ry := openvg.VGfloat(ty) if rix%2 == 0 { openvg.FillRGB(0, 0, 0, .2) //openvg.Rect(rx1, tempy, rw1, rh1) openvg.FillRGB(0, 0, 0, 1) tempy = tempy + 6.0 } else { openvg.FillRGB(0, 0, 0, .4) openvg.Rect(rx1, tempy, rw1, rh1) tempy = tempy + 6.0 openvg.FillRGB(0, 0, 0, 1) } openvg.Text(rx1, tempy, jsonData.ResponseData.Buses[rix].LineNumber, "sans", fontsize) drawTypeOfTransport(rx1+60, tempy+2, rw1, ch-20, jsonData.ResponseData.Buses[rix].TransportMode) openvg.Text(rx1+100, tempy, jsonData.ResponseData.Buses[rix].StopPointDesignation, "sans", fontsize) openvg.Text(rx1+TAB1, tempy, jsonData.ResponseData.Buses[rix].DisplayTime, "sans", fontsize) var dest = jsonData.ResponseData.Buses[rix].Destination dest = replaceAO(dest) openvg.Text(rx1+TAB2, tempy, dest, "sans", fontsize) //openvg.Translate(x, ry+openvg.VGfloat(fontsize/2)) //openvg.Background(255,255,0) rix = rix + 1 } var trainIx = 0 for ty = ty - 20; ty > 0 && trainIx < len(jsonData.ResponseData.Trains); ty -= ch { tempy := openvg.VGfloat(ty) //ry := openvg.VGfloat(ty) if rix%2 == 0 { openvg.FillRGB(0, 0, 0, .2) //openvg.Rect(rx1, tempy, rw1, rh1) openvg.FillRGB(0, 0, 0, 1) tempy = tempy + 6.0 } else { openvg.FillRGB(0, 0, 0, .4) openvg.Rect(rx1, tempy, rw1, rh1) tempy = tempy + 6.0 openvg.FillRGB(0, 0, 0, 1) } openvg.Text(rx1, tempy, jsonData.ResponseData.Trains[trainIx].LineNumber, "sans", fontsize) drawTypeOfTransport(rx1+55, tempy+4, rw1, ch-20, jsonData.ResponseData.Trains[trainIx].TransportMode) openvg.Text(rx1+TAB1, tempy, jsonData.ResponseData.Trains[trainIx].DisplayTime, "sans", fontsize) var dest = jsonData.ResponseData.Trains[trainIx].Destination dest = replaceAO(dest) openvg.Text(rx1+TAB2, tempy, dest, "sans", fontsize) //openvg.Translate(x, ry+openvg.VGfloat(fontsize/2)) //openvg.Background(255,255,0) trainIx = trainIx + 1 rix = rix + 1 } //openvg.End() openvg.SaveEnd("dump.raw") time.Sleep(60 * time.Second) } bufio.NewReader(os.Stdin).ReadBytes('\n') 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) }
func main() { var cy, ch, midy int var message []string message = []string{" Black", "cats", "skitter", "and", "ghouls", "patter", "Happy", "Halloween"} w, h := openvg.Init() //var speed openvg.VGfloat = 0.5 var x openvg.VGfloat = 0 var vw, vh openvg.VGfloat var midxx openvg.VGfloat = openvg.VGfloat(w / 2) midy = (h / 2) fontsize := w / 8 //cx = 0 ch = fontsize * 2 //cw = w cy = midy - (ch / 2) var redness uint8 var index int //rx , rw, rh := openvg.VGfloat(cx) , openvg.VGfloat(cw), openvg.VGfloat(ch) ry := openvg.VGfloat(cy) // scroll the text, only in the clipping rectangle index = 0 for { for redness = 255; redness > 16; redness -= 2 { ch = fontsize * 2 //cw = w cy = midy - (ch / 2) openvg.Start(w, h) openvg.Background(redness, 0, 0) 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) var fsiz int fsiz = int(255 - redness) openvg.TextMid(midxx, 0, message[index], "shf", fsiz) openvg.ClipEnd() openvg.End() } index = (index + 1) % 8 if index == 0 { vw = openvg.VGfloat(w) - 200 vh = openvg.VGfloat(h) - 200 openvg.Video(100.0, 100.0, vw, vh, "test.h264") } if index == 0 { var test, oix int var xpos [40]float32 var ypos [40]float32 var rotate [40]float32 var spdx [40]float32 var spdy [40]float32 // Init positions for test = 0; test < 40; test++ { var rot = rand.Float32() var rax = rand.Float32() rax = float32(w) * rax var ray = rand.Float32() ray = float32(h) * ray spdx[test] = float32(test) * rand.Float32() spdy[test] = float32(test) * rand.Float32() ypos[test] = ray xpos[test] = rax rot = 0 rotate[test] = rot } // Move around for oix = 0; oix < 100; oix++ { openvg.Start(w, h) openvg.Background(0, 0, 0) openvg.FillColor("red") for test = 0; test < 40; test++ { var rot = rand.Float32() var rax = rand.Float32()*float32(4.0) - float32(2.0) var ray = float32(4.0)*rand.Float32() - float32(2.0) spdy[test] += ray spdx[test] += rax xpos[test] = xpos[test] + spdx[test] ypos[test] = ypos[test] + spdy[test] rotate[test] = rotate[test] + float32(rot*4-2) openvg.Rotate(openvg.VGfloat(rotate[test])) openvg.Translate(openvg.VGfloat(xpos[test]), openvg.VGfloat(ypos[test])) openvg.TextMid(0, 0, "Happy Halloween", "shf", 30) openvg.Translate(-openvg.VGfloat(xpos[test]), -openvg.VGfloat(ypos[test])) openvg.Rotate(-openvg.VGfloat(rotate[test])) } openvg.End() } } } bufio.NewReader(os.Stdin).ReadBytes('\n') openvg.Finish() os.Exit(0) }