MCPcopy Index your code
hub / github.com/gonum/plot / DrawGlyphBoxes

Method DrawGlyphBoxes

plot.go:197–253  ·  view source on GitHub ↗

DrawGlyphBoxes draws red outlines around the plot's GlyphBoxes. This is intended for debugging.

(c draw.Canvas)

Source from the content-addressed store, hash-verified

195// DrawGlyphBoxes draws red outlines around the plot's
196// GlyphBoxes. This is intended for debugging.
197func (p *Plot) DrawGlyphBoxes(c draw.Canvas) {
198 dac := p.DataCanvas(c)
199 sty := draw.LineStyle{
200 Color: color.RGBA{R: 255, A: 255},
201 Width: vg.Points(0.5),
202 }
203
204 drawBox := func(c draw.Canvas, b GlyphBox) {
205 x := c.X(b.X) + b.Rectangle.Min.X
206 y := c.Y(b.Y) + b.Rectangle.Min.Y
207 c.StrokeLines(sty, []vg.Point{
208 {X: x, Y: y},
209 {X: x + b.Rectangle.Size().X, Y: y},
210 {X: x + b.Rectangle.Size().X, Y: y + b.Rectangle.Size().Y},
211 {X: x, Y: y + b.Rectangle.Size().Y},
212 {X: x, Y: y},
213 })
214 }
215
216 var title vg.Length
217 if p.Title.Text != "" {
218 rect := p.Title.TextStyle.Rectangle(p.Title.Text)
219 title += rect.Size().Y
220 title += p.Title.Padding
221 box := GlyphBox{
222 Rectangle: rect.Add(vg.Point{
223 X: c.Center().X,
224 Y: c.Max.Y,
225 }),
226 }
227 drawBox(c, box)
228 }
229
230 for _, b := range p.GlyphBoxes(p) {
231 drawBox(dac, b)
232 }
233
234 p.X.sanitizeRange()
235 p.Y.sanitizeRange()
236
237 x := horizontalAxis{p.X}
238 y := verticalAxis{p.Y}
239
240 ywidth := y.size()
241 xheight := x.size()
242
243 cx := padX(p, draw.Crop(c, ywidth, 0, 0, 0))
244 for _, b := range x.GlyphBoxes(p) {
245 drawBox(cx, b)
246 }
247
248 cy := padY(p, draw.Crop(c, 0, 0, xheight, 0))
249 cy.Max.Y -= title
250 for _, b := range y.GlyphBoxes(p) {
251 drawBox(cy, b)
252 }
253}
254

Callers 1

TestDrawGlyphBoxesFunction · 0.80

Calls 15

DataCanvasMethod · 0.95
GlyphBoxesMethod · 0.95
sizeMethod · 0.95
sizeMethod · 0.95
GlyphBoxesMethod · 0.95
GlyphBoxesMethod · 0.95
PointsFunction · 0.92
CropFunction · 0.92
padXFunction · 0.85
padYFunction · 0.85
StrokeLinesMethod · 0.80
CenterMethod · 0.80

Tested by 1

TestDrawGlyphBoxesFunction · 0.64