Skip to content
Snippets Groups Projects
Commit 898210c7 authored by Andrew E. Torda's avatar Andrew E. Torda
Browse files

Just removed the experimental stuff for drawing to screen, or at least

put it in its own branch for playing with later.
parent 7f3f2bad
No related branches found
No related tags found
No related merge requests found
......@@ -166,10 +166,5 @@ func main() {
fmt.Fprintln(os.Stderr, err)
os.Exit(exitFailure)
}
if err := scrnPlt(pi, stdErr); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(exitFailure)
}
os.Exit(exitSuccess)
}
// 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
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment