Example #1
0
// 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()
	openvg.Start(w, h)
	openvg.FillColor("white")
	openvg.Rect(0, 0, gwidth, gheight)
	filenames := flag.Args()
	if len(filenames) == 0 {
		doplot(beginx, beginy, "")
	} else {
		plotgrid(beginx, beginy, filenames)
	}
	openvg.SaveEnd("vgplot.raw")
	bufio.NewReader(os.Stdin).ReadByte()
	openvg.Finish()
}
Example #2
0
func main() {
	width, height := openvg.Init() // OpenGL, etc initialization

	w2 := float64(width / 2)
	h2 := float64(height / 2)
	w := float64(width)

	openvg.Start(width, height)                               // Start the picture
	openvg.BackgroundColor("black")                           // Black background
	openvg.FillRGB(44, 77, 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.SaveEnd("hello.raw")                               // End the picture
	bufio.NewReader(os.Stdin).ReadBytes('\n')                 // Pause until [RETURN]
	openvg.Finish()                                           // Graphics cleanup
}
Example #3
0
func main() {
	width, height := openvg.Init() // OpenGL, etc initialization

	w2 := float64(width / 2)
	h2 := float64(height / 2)
	w := float64(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
	bufio.NewReader(os.Stdin).ReadBytes('\n')                 // Pause until [RETURN]
	openvg.Finish()                                           // Graphics cleanup
}
Example #4
0
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 := float64(width)
	fh := float64(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 := rand.Float64()

		x := rand.Float64() * fw
		y := rand.Float64() * fh
		radius := rand.Float64() * 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.SaveEnd("rand.raw")

	bufio.NewReader(os.Stdin).ReadBytes('\n')
	openvg.Finish()
}