From 7f3f2badf802048dcca3a5af4a9e666f706f5d0b Mon Sep 17 00:00:00 2001 From: "Andrew E. Torda" <torda@zbh.uni-hamburg.de> Date: Sun, 2 May 2021 11:29:33 +0200 Subject: [PATCH] Broken. Cannot set backgrround on plots. --- screenplot.go | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 screenplot.go diff --git a/screenplot.go b/screenplot.go new file mode 100644 index 0000000..f73fddd --- /dev/null +++ b/screenplot.go @@ -0,0 +1,69 @@ +// For fun.. Plot to the screen + +package main + +import ( + "fmt" + "github.com/gizak/termui/v3/drawille" + ui "github.com/gizak/termui/v3" + "github.com/gizak/termui/v3/widgets" + "image" +) + +func breaker(x interface{}) {} +func scrnPlt(pi, stdErr []float32) error { + ui.Theme.Plot.Axes = ui.ColorBlack + thm := ui.Theme + thm.Default = ui.NewStyle(ui.ColorBlack, ui.ColorWhite, ui.ModifierReverse) + thm.Default.Fg = ui.ColorBlack + thm.Default.Bg = ui.ColorWhite + thm.Plot.Lines = []ui.Color{ui.ColorBlack} + thm.Paragraph.Text = ui.NewStyle(ui.ColorBlack, ui.ColorWhite) + ui.Theme = thm + ptxt := widgets.NewParagraph() + + ptxt.Text = "Hello World!" + ptxt.SetRect(0, 0, 25, 5) + + p1 := widgets.NewPlot() + + p1.Title = "π" + { + data := make([][]float64, 2) + data[0] = make([]float64, len(pi)) + data[1] = make([]float64, len(pi)) + for i := range pi { + data[0][i] = float64(i + 1) + data[1][i] = float64(pi[i]) + } + p1.Data = data + } + breaker(thm) + p1.SetRect(5, 5, 80, 80) + p1.AxesColor = ui.ColorBlack + p1.LineColors = []ui.Color{ui.ColorRed} + + p1.Marker = widgets.MarkerBraille + p1.PlotType = widgets.ScatterPlot + // next: syntax OK, just doesn't work + r := image.Rectangle(image.Rect(0, 0, 100, 100)) + buf := ui.NewBuffer(r) + + cell := drawille.Cell{Color:7} + fmt.Println (cell) +// buf.Fill(cell, r) + p1.Block.Draw(buf) + + if err := ui.Init(); err != nil { + return fmt.Errorf("failed to initialize termui: %w", err) + } + defer ui.Close() + + ui.Render(p1, ptxt) + for e := range ui.PollEvents() { + if e.Type == ui.KeyboardEvent { + break + } + } + return nil +} -- GitLab