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>
42 lines
925 B
Go
42 lines
925 B
Go
package fx
|
|
|
|
import (
|
|
"github.com/egoist/mygo/ui"
|
|
|
|
"git.zacharyzhang.com/ZacharyZhang-NY/8bitMyGoUI/pixel"
|
|
)
|
|
|
|
type SnowOptions struct {
|
|
// Width and Height are dots; zeros mean 160 by 96.
|
|
Width, Height int
|
|
Label string
|
|
}
|
|
|
|
// Snow drifts flakes down, swaying; near ones are big, quick.
|
|
func Snow(c *ui.Context, o SnowOptions) ui.Element {
|
|
k := pixel.K(c)
|
|
w, h := size("Snow", o.Width, o.Height, 160, 96)
|
|
return box(c, k, o.Label, w, h).Draw(func(p *ui.Painter, r ui.Rect) {
|
|
g := k.Canvas(p, r)
|
|
g.Clip(0, 0, g.W, g.H, func() { snow(g, k, g.Step(8)) })
|
|
})
|
|
}
|
|
|
|
func snow(g pixel.Canvas, k pixel.Kit, step int) {
|
|
s := light(k)
|
|
for i := range g.W * g.H / 110 {
|
|
near := rnd(i, 40)%3 == 0
|
|
speed := 1
|
|
if near {
|
|
speed = 2
|
|
}
|
|
y := wrap(rnd(i, 41)+step*speed, g.H+4) - 2
|
|
x := wrap(rnd(i, 42)+sway(step+rnd(i, 43), 16, 2), g.W)
|
|
if near {
|
|
g.Rect(x, y, 2, 2, s)
|
|
} else {
|
|
g.Dot(x, y, s)
|
|
}
|
|
}
|
|
}
|