Files
8bitMyGoUI/fx/flash.go
T
ZacharyZhang-NY 8be66c09f2 Add fx components 291-320 and the home scene; Kit.Shot, Kit.Toward
Palette cycling, sky, sun and moon, clouds, starfield, rain, snow,
petals, leaves, fireflies, waterfall, ocean, campfire, lava, aurora,
lightning, mountains and a season scene; scanlines, vignette, screen
shake, flash, dither fades, iris wipes, dissolves, mosaics, glitches,
sparkles, explosions and confetti. Home opens on a live scene in the
palette's season and a strip of all eight palettes.

pixel adds Canvas.Cycled, Sprite.At, SpriteOf, Kit.Toward and
Kit.Shot, which spends a cue under Reduce Motion so it never replays;
display exports Reduce. Gallery grids and the sidebar are one Tab
stop each.
2026-10-12 04:05:25 -04:00

32 lines
671 B
Go

package fx
import (
"github.com/egoist/mygo/ui"
"git.zacharyzhang.com/ZacharyZhang-NY/8bitMyGoUI/pixel"
)
type FlashOptions struct {
// Cue flashes each time it changes.
Cue int
// Slot fills the flash; zero means Lit.
Slot pixel.Slot
}
// Flash fills content with a slot one step, then half.
func Flash(c *ui.Context, o FlashOptions, content func()) *ui.Element {
k := pixel.K(c)
s := slotOr(o.Slot, pixel.Lit)
e := ui.Column(c)
// Reduce Motion never flashes.
step := k.Shot(c, e, o.Cue, 10, 2)
return cover(k, e, func(g pixel.Canvas) {
switch step {
case 0:
g.Rect(0, 0, g.W, g.H, s)
case 1:
g.Veil(0, 0, g.W, g.H, s, 8)
}
}, content)
}