Exemple #1
0
func (s *Schedule) ExprPNG(t miniprofiler.Timer, w io.Writer, width, height int, unit string, res []*expr.Result) error {
	ch, err := s.ExprGraph(t, unit, res)
	if err != nil {
		return err
	}
	g := image.NewRGBA(image.Rectangle{Min: image.ZP, Max: image.Pt(width, height)})
	sgr := imgg.AddTo(g, 0, 0, width, height, white, nil, nil)
	ch.Plot(sgr)
	return png.Encode(w, g)
}
Exemple #2
0
func (im *ImageWriter) Write(c *Chart) {
	os.MkdirAll("data", os.ModePerm)

	fp, err := os.Create(path.Join("data", c.name+".png"))
	if err != nil {
		panic(err)
	}
	defer fp.Close()

	img := image.NewRGBA(image.Rect(0, 0, 1024, 768))
	bg := image.NewUniform(color.RGBA{0xff, 0xff, 0xff, 0xff})
	draw.Draw(img, img.Bounds(), bg, image.ZP, draw.Src)

	//row, col := d.Cnt/d.N, d.Cnt%d.N
	igr := imgg.AddTo(img, 0, 0, 1024, 768, color.RGBA{0xff, 0xff, 0xff, 0xff}, nil, nil)
	c.c.Plot(igr)
	png.Encode(fp, img)
}