1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
|
// Copyright ©2015 The Gonum Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package plotter
import (
"image/color"
"gonum.org/v1/plot"
"gonum.org/v1/plot/vg"
"gonum.org/v1/plot/vg/draw"
)
// GlyphBoxes implements the Plotter interface, drawing
// all of the glyph boxes of the plot. This is intended for
// debugging.
type GlyphBoxes struct {
draw.LineStyle
}
func NewGlyphBoxes() *GlyphBoxes {
g := new(GlyphBoxes)
g.Color = color.RGBA{R: 255, A: 255}
g.Width = vg.Points(0.25)
return g
}
func (g GlyphBoxes) Plot(c draw.Canvas, plt *plot.Plot) {
for _, b := range plt.GlyphBoxes(plt) {
x := c.X(b.X) + b.Rectangle.Min.X
y := c.Y(b.Y) + b.Rectangle.Min.Y
c.StrokeLines(g.LineStyle, []vg.Point{
{x, y},
{x + b.Rectangle.Size().X, y},
{x + b.Rectangle.Size().X, y + b.Rectangle.Size().Y},
{x, y + b.Rectangle.Size().Y},
{x, y},
})
}
}
|