diff --git a/AGENTS.md b/AGENTS.md index 5f4eda3..27aa41b 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -37,6 +37,7 @@ testdata/snapshots/ /-.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. diff --git a/internal/paint.go b/internal/paint.go index 7e7f951..f1cd9f4 100644 --- a/internal/paint.go +++ b/internal/paint.go @@ -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 +} diff --git a/spinner.go b/spinner.go index 75ee900..990ba09 100644 --- a/spinner.go +++ b/spinner.go @@ -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 { diff --git a/testdata/snapshots/darwin/button-dark.png b/testdata/snapshots/darwin/button-dark.png index fd0d7f4..2653916 100644 Binary files a/testdata/snapshots/darwin/button-dark.png and b/testdata/snapshots/darwin/button-dark.png differ diff --git a/testdata/snapshots/darwin/button-light.png b/testdata/snapshots/darwin/button-light.png index 5629ae4..b85d2e5 100644 Binary files a/testdata/snapshots/darwin/button-light.png and b/testdata/snapshots/darwin/button-light.png differ