diff --git a/screenplot.go b/screenplot.go index f73fddd8b66cd54f37275a00304486c6d1a5d8de..4aacfd67a05ad2e26b764f656a8c01e6118e8f34 100644 --- a/screenplot.go +++ b/screenplot.go @@ -4,27 +4,37 @@ package main import ( "fmt" - "github.com/gizak/termui/v3/drawille" + "image" + "image/color" + "image/draw" 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 + nrmlStyle := ui.NewStyle (ui.ColorBlack, ui.ColorClear) +// invisStyle := ui.NewStyle (ui.ColorClear, ui.ColorClear) 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) + thm.Block.Title = nrmlStyle + thm.Plot.Axes = ui.ColorBlack + + thm.Default = ui.NewStyle(ui.ColorBlack, ui.ColorClear) + thm.Block.Border = nrmlStyle + ui.Theme = thm - ptxt := widgets.NewParagraph() - ptxt.Text = "Hello World!" - ptxt.SetRect(0, 0, 25, 5) + ptxt := widgets.NewParagraph() + for i := 0; i < 24; i++ { + for j := 0; j < 800; j++ { + ptxt.Text += "." + } + ptxt.Text += " \n" + } + + ptxt.SetRect(0, 0, 80, 24) + ptxt.TextStyle = ui.NewStyle(ui.ColorWhite, ui.ColorWhite) p1 := widgets.NewPlot() p1.Title = "π" @@ -38,28 +48,35 @@ func scrnPlt(pi, stdErr []float32) error { } p1.Data = data } - breaker(thm) - p1.SetRect(5, 5, 80, 80) - p1.AxesColor = ui.ColorBlack - p1.LineColors = []ui.Color{ui.ColorRed} + p1.SetRect(2, 2, 80, 24) + p1.Block.TitleStyle = nrmlStyle + p1.AxesColor = ui.ColorBlack +// p1.LineColors = []ui.Color{ui.ColorBlack, ui.ColorBlack} + p1.SetRect (0, 0, 80, 24) 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) + p1.Border = false + + breaker(thm) + + m := image.NewRGBA(image.Rect(0, 0, 80, 24)) - cell := drawille.Cell{Color:7} - fmt.Println (cell) -// buf.Fill(cell, r) - p1.Block.Draw(buf) + // draw.Draw(m, m.Bounds(), &image.Uniform{color.White}, image.ZP, draw.Src) + draw.Draw(m, m.Bounds(), &image.Uniform{color.White}, image.ZP, draw.Src) + img := widgets.NewImage(m) + img.SetRect(0, 0, 100, 50) + + defer fmt.Println ("m bounds", m.Bounds()) if err := ui.Init(); err != nil { - return fmt.Errorf("failed to initialize termui: %w", err) + return err } + + defer ui.Close() - ui.Render(p1, ptxt) + ui.Render(img, ptxt, p1) for e := range ui.PollEvents() { if e.Type == ui.KeyboardEvent { break