This commit is contained in:
5684185+vsariola@users.noreply.github.com
2026-01-01 19:59:23 +02:00
parent 179ebb7cc3
commit fcb9a06249
5 changed files with 44 additions and 19 deletions

View File

@ -2,6 +2,7 @@ package gioui
import (
"math"
"strconv"
"gioui.org/layout"
"gioui.org/unit"
@ -21,7 +22,6 @@ type (
Theme *Theme
Model *tracker.ScopeModel
State *OscilloscopeState
Style *PlotStyle
}
)
@ -40,7 +40,6 @@ func Scope(th *Theme, m *tracker.ScopeModel, st *OscilloscopeState) Oscilloscope
Theme: th,
Model: m,
State: st,
Style: &th.Oscilloscope,
}
}
@ -80,12 +79,12 @@ func (s *Oscilloscope) Layout(gtx C) D {
a := max(int(math.Ceil(float64(r.a*float32(l)))), 0)
b := min(int(math.Floor(float64(r.b*float32(l)))), l)
for i := a; i <= b; i++ {
yield(float32(i)/float32(l), "")
yield(float32(i)/float32(l), strconv.Itoa(i))
}
}
yticks := func(r plotRange, yield func(pos float32, label string)) {
yield(-1, "1")
yield(1, "-1")
yield(-1, "")
yield(1, "")
}
return s.State.plot.Layout(gtx, data, xticks, yticks, cx, 2)