@@ 455,20 455,20 @@ func run(w *app.Window) error {
}
lowestFreq := freqs[0]
for i, pipe := range players {
+ offset := op.Offset(f32.Point{X: float32(math.Round(float64(width * float32(i))))}).Push(gtx.Ops)
+ rect := rect
+ proportion := 1 / (pipe.freq / lowestFreq)
+ heightF := float64(gtx.Constraints.Max.Y) * proportion
+ height := int(math.Round(heightF))
+ gap := gtx.Constraints.Max.Y - height
+ rect.Min.Y = gap
+
+ lightFill := pipe.col
+ lightFill.A = 50
+ paint.FillShape(gtx.Ops, lightFill, rect.Op())
+
if pipe.playing {
op.InvalidateOp{}.Add(gtx.Ops)
- offset := op.Offset(f32.Point{X: float32(math.Round(float64(width * float32(i))))}).Push(gtx.Ops)
- rect := rect
- proportion := 1 / (pipe.freq / lowestFreq)
- heightF := float64(gtx.Constraints.Max.Y) * proportion
- height := int(math.Round(heightF))
- gap := gtx.Constraints.Max.Y - height
- rect.Min.Y = gap
-
- lightFill := pipe.col
- lightFill.A = 100
- paint.FillShape(gtx.Ops, lightFill, rect.Op())
-
duration := float64(gtx.Now.Sub(pipe.since).Milliseconds()) / 2000
if duration > 1 {
duration = 1
@@ 481,8 481,8 @@ func run(w *app.Window) error {
rect.Min.Y = gap
paint.FillShape(gtx.Ops, pipe.col, rect.Op())
- offset.Pop()
}
+ offset.Pop()
}
}
// This editor is needed for JS to properly deliver key events