Draw draws the plot to image. Plotters are drawn in the order in which they were added to the plot.
()
| 62 | // Plotters are drawn in the order in which they were |
| 63 | // added to the plot. |
| 64 | func (pt *Plot) Draw() { |
| 65 | pt.drawConfig() |
| 66 | pc := pt.Paint |
| 67 | ptw := float32(pt.Size.X) |
| 68 | pth := float32(pt.Size.X) |
| 69 | |
| 70 | ptb := image.Rectangle{Max: pt.Size} |
| 71 | pc.PushBounds(ptb) |
| 72 | |
| 73 | if pt.Background != nil { |
| 74 | pc.BlitBox(math32.Vector2{}, math32.Vector2FromPoint(pt.Size), pt.Background) |
| 75 | } |
| 76 | |
| 77 | if pt.Title.Text != "" { |
| 78 | pt.Title.Config(pt) |
| 79 | pos := pt.Title.PosX(ptw) |
| 80 | pad := pt.Title.Style.Padding.Dots |
| 81 | pos.Y = pad |
| 82 | pt.Title.Draw(pt, pos) |
| 83 | th := pt.Title.PaintText.BBox.Size().Y + 2*pad |
| 84 | pth -= th |
| 85 | ptb.Min.Y += int(math32.Ceil(th)) |
| 86 | } |
| 87 | |
| 88 | pt.X.SanitizeRange() |
| 89 | pt.Y.SanitizeRange() |
| 90 | |
| 91 | ywidth, tickWidth, tpad, bpad := pt.Y.sizeY(pt) |
| 92 | xheight, lpad, rpad := pt.X.sizeX(pt, float32(pt.Size.X-int(ywidth))) |
| 93 | |
| 94 | tb := ptb |
| 95 | tb.Min.X += ywidth |
| 96 | pc.PushBounds(tb) |
| 97 | pt.X.drawX(pt, lpad, rpad) |
| 98 | pc.PopBounds() |
| 99 | |
| 100 | tb = ptb |
| 101 | tb.Max.Y -= xheight |
| 102 | pc.PushBounds(tb) |
| 103 | pt.Y.drawY(pt, tickWidth, tpad, bpad) |
| 104 | pc.PopBounds() |
| 105 | |
| 106 | tb = ptb |
| 107 | tb.Min.X += ywidth + lpad |
| 108 | tb.Max.X -= rpad |
| 109 | tb.Max.Y -= xheight + bpad |
| 110 | tb.Min.Y += tpad |
| 111 | pt.PlotBox.SetFromRect(tb) |
| 112 | |
| 113 | // don't cut off lines |
| 114 | tb.Min.X -= 2 |
| 115 | tb.Min.Y -= 2 |
| 116 | tb.Max.X += 2 |
| 117 | tb.Max.Y += 2 |
| 118 | pc.PushBounds(tb) |
| 119 | |
| 120 | for _, plt := range pt.Plotters { |
| 121 | plt.Plot(pt) |
no test coverage detected