Files
ZacharyZhang-NYandClaude Opus 5.5 03e1f91706 Upgrade MyGo to v0.5.5
Elements are now pass-scoped value handles: tests that read bounds
after a frame bind a ui.Handle. pixel tells frames apart by the build
pass's root, since the Tester clock no longer moves on its own.

Fix the regressions the upgrade brought:
- Clipboard reads in input handlers go through c.Services().
- MyGo notes an overlay's opener after building it, so AutoFocus
  inside lost it; pixel.AutoFocus focuses through a Handle, and
  archtest bans the raw call. Dialogs hand the focus back again.
- Elements around a press stay hovered: Tooltip tells a press-given
  focus by focus arriving under the pointer.
- The web host moves the Tester clock with real time, at most 500 ms
  a call, and gives components the real clock.

The gallery's source index also accepts CRLF checkouts.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-17 01:31:08 -04:00

41 lines
973 B
Go

package fx
import (
"github.com/egoist/mygo/ui"
"git.zacharyzhang.com/ZacharyZhang-NY/8bitMyGoUI/pixel"
)
type VignetteOptions struct {
// Slot darkens the edges; zero means the darkest slot.
Slot pixel.Slot
}
// Vignette dithers a slot inward from edges; corners go solid.
func Vignette(c *ui.Context, o VignetteOptions, content func()) ui.Element {
k := pixel.K(c)
s := slotOr(o.Slot, dark(k))
return cover(k, ui.Column(c), func(g pixel.Canvas) { vignette(g, s) }, content)
}
// vignette's level grows with the elliptic distance out.
func vignette(g pixel.Canvas, s pixel.Slot) {
level := func(x, y int) int {
ex := float64(2*x+1-g.W) / float64(g.W)
ey := float64(2*y+1-g.H) / float64(g.H)
return min(16, max(0, int((ex*ex+ey*ey-0.6)*16/1.2)))
}
for y := range g.H {
for x := 0; x < g.W; {
l, end := level(x, y), x+1
for end < g.W && level(end, y) == l {
end++
}
if l > 0 {
g.Veil(x, y, end-x, 1, s, l)
}
x = end
}
}
}