Snap animated paths to MyGo's path-cache grid; removes cross-test snapshot flake
This commit is contained in:
5 files changed
+10
-1
No files matched your search
@@ -37,6 +37,7 @@ testdata/snapshots/ <os>/<name>-<light|dark>.png
|
||||
- Focus: `internal.Ring(e, k.Focus, radius)` for the 2 DIP ring with 2 DIP gap.
|
||||
- State marks (checked, selected, progress) use `OnAccent` on `Accent`, or `AccentText`, never `Accent` alone on dark surfaces (2.44:1).
|
||||
- Ornament color only for dividers, corners, panel titles. No gradients, glow, glass or texture.
|
||||
- Animated paths: pass coordinates through `internal.Snap(p, v)`. MyGo caches path masks by quarter-pixel keys (ui/path.go); unsnapped motion reuses near-miss masks and breaks snapshots.
|
||||
- Durations: `mujica.Motion(c, theme.StateDuration)`; popups use `theme.PopupDuration`.
|
||||
- Disabled blocks input before handling it (`Disabled(true)`); MyGo dims disabled elements, do not add opacity.
|
||||
- Copy shown by a component comes from `msg(c, key)`; business copy comes from the caller.
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
package internal
|
||||
|
||||
import (
|
||||
"math"
|
||||
|
||||
"github.com/egoist/mygo/ui"
|
||||
|
||||
"mujicaui/theme"
|
||||
@@ -33,3 +35,9 @@ func Diamond(cx, cy, s float32) *ui.Path {
|
||||
p.Close()
|
||||
return &p
|
||||
}
|
||||
|
||||
// Snap rounds v to MyGo's quarter-device-pixel path cache grid.
|
||||
func Snap(p *ui.Painter, v float32) float32 {
|
||||
g := 4 * p.Scale()
|
||||
return float32(math.Round(float64(v*g))) / g
|
||||
}
|
||||
+1
-1
@@ -48,7 +48,7 @@ func Spinner(c *ui.Context, opts SpinnerOptions) *ui.Element {
|
||||
x := cx + rad*float32(math.Cos(a))
|
||||
y := cy + rad*float32(math.Sin(a))
|
||||
alpha := 1 - float32(i)*0.22
|
||||
p.FillPath(internal.Diamond(x, y, r.W*0.3), color.Alpha(alpha))
|
||||
p.FillPath(internal.Diamond(internal.Snap(p, x), internal.Snap(p, y), internal.Snap(p, r.W*0.3)), color.Alpha(alpha))
|
||||
}
|
||||
})
|
||||
if opts.ShowLabel {
|
||||
|
||||
BIN
Binary file not shown.
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
BIN
Binary file not shown.
|
Before Width: | Height: | Size: 9.7 KiB After Width: | Height: | Size: 9.7 KiB |
Reference in new issue
Block a user