padY returns a draw.Canvas that is padded vertically so that glyphs will no be clipped.
(p *Plot, c draw.Canvas)
| 311 | // padY returns a draw.Canvas that is padded vertically |
| 312 | // so that glyphs will no be clipped. |
| 313 | func padY(p *Plot, c draw.Canvas) draw.Canvas { |
| 314 | glyphs := p.GlyphBoxes(p) |
| 315 | b := bottomMost(&c, glyphs) |
| 316 | yAxis := verticalAxis{p.Y} |
| 317 | glyphs = append(glyphs, yAxis.GlyphBoxes(p)...) |
| 318 | t := topMost(&c, glyphs) |
| 319 | |
| 320 | miny := c.Min.Y - b.Min.Y |
| 321 | maxy := c.Max.Y - (t.Min.Y + t.Size().Y) |
| 322 | by := vg.Length(b.Y) |
| 323 | ty := vg.Length(t.Y) |
| 324 | n := (by*maxy - ty*miny) / (by - ty) |
| 325 | m := ((by-1)*maxy - ty*miny + miny) / (by - ty) |
| 326 | return draw.Canvas{ |
| 327 | Canvas: vg.Canvas(c), |
| 328 | Rectangle: vg.Rectangle{ |
| 329 | Min: vg.Point{Y: n, X: c.Min.X}, |
| 330 | Max: vg.Point{Y: m, X: c.Max.X}, |
| 331 | }, |
| 332 | } |
| 333 | } |
| 334 | |
| 335 | // topMost returns the top-most GlyphBox. |
| 336 | func topMost(c *draw.Canvas, boxes []GlyphBox) GlyphBox { |
no test coverage detected