...
1
2
3
4
5 package plotter
6
7 import (
8 "image/color"
9
10 "gonum.org/v1/plot"
11 "gonum.org/v1/plot/vg"
12 "gonum.org/v1/plot/vg/draw"
13 )
14
15
16
17
18 type GlyphBoxes struct {
19 draw.LineStyle
20 }
21
22 func NewGlyphBoxes() *GlyphBoxes {
23 g := new(GlyphBoxes)
24 g.Color = color.RGBA{R: 255, A: 255}
25 g.Width = vg.Points(0.25)
26 return g
27 }
28
29 func (g GlyphBoxes) Plot(c draw.Canvas, plt *plot.Plot) {
30 for _, b := range plt.GlyphBoxes(plt) {
31 x := c.X(b.X) + b.Rectangle.Min.X
32 y := c.Y(b.Y) + b.Rectangle.Min.Y
33 c.StrokeLines(g.LineStyle, []vg.Point{
34 {X: x, Y: y},
35 {X: x + b.Rectangle.Size().X, Y: y},
36 {X: x + b.Rectangle.Size().X, Y: y + b.Rectangle.Size().Y},
37 {X: x, Y: y + b.Rectangle.Size().Y},
38 {X: x, Y: y},
39 })
40 }
41 }
42
View as plain text