Files
8bitMyGoUI/fx/fadedither.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

22 lines
585 B
Go

package fx
import (
"github.com/egoist/mygo/ui"
"git.zacharyzhang.com/ZacharyZhang-NY/8bitMyGoUI/pixel"
)
type FadeDitherOptions struct {
// Slot covers the content; zero means the darkest slot.
Slot pixel.Slot
}
// FadeDither covers content through Bayer levels, or uncovers it.
func FadeDither(c *ui.Context, covered bool, o FadeDitherOptions, content func()) *ui.Element {
k := pixel.K(c)
s := slotOr(o.Slot, dark(k))
e := ui.Column(c)
level := 2 * k.Toward(c, e, covered, 12, 8)
return cover(k, e, func(g pixel.Canvas) { g.Veil(0, 0, g.W, g.H, s, level) }, content)
}