From 7d83b8ad3756a35e94ae7fa89f2485a361936edd Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Mon, 20 Aug 2018 09:12:32 -0400 Subject: [PATCH] Re-added the graph drawing in the histogram example. --- zz_histogram.go | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/zz_histogram.go b/zz_histogram.go index a783dbd..9a6a93b 100644 --- a/zz_histogram.go +++ b/zz_histogram.go @@ -11,9 +11,10 @@ import ( "github.com/andlabs/ui" ) -var colorButton *ui.ColorButton - -var datapoints [10]*ui.Spinbox +var ( + datapoints [10]*ui.Spinbox + colorButton *ui.ColorButton +) // some metrics const ( @@ -119,27 +120,27 @@ func (areaHandler) Draw(a *ui.Area, p *ui.AreaDrawParams) { m.Translate(xoffLeft, yoffTop); p.Context.Transform(m) -/* // now get the color for the graph itself and set up the brush - uiColorButtonColor(colorButton, &graphR, &graphG, &graphB, &graphA); - brush.Type = ui.Solid; - brush.R = graphR; - brush.G = graphG; - brush.B = graphB; + graphR, graphG, graphB, graphA := colorButton.Color() + brush.Type = ui.Solid + brush.R = graphR + brush.G = graphG + brush.B = graphB // we set brush.A below to different values for the fill and stroke // now create the fill for the graph below the graph line - path = constructGraph(graphWidth, graphHeight, 1); - brush.A = graphA / 2; + path = constructGraph(graphWidth, graphHeight, true) + brush.A = graphA / 2 p.Context.Fill(path, brush) path.Free() // now draw the histogram line - path = constructGraph(graphWidth, graphHeight, 0); - brush.A = graphA; + path = constructGraph(graphWidth, graphHeight, false) + brush.A = graphA p.Context.Stroke(path, brush, sp) path.Free() +/* // now draw the point being hovered over if (currentPoint != -1) { double xs[10], ys[10];