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.
24 lines
578 B
Go
24 lines
578 B
Go
package feedback
|
|
|
|
import (
|
|
"github.com/egoist/mygo/ui"
|
|
|
|
"git.zacharyzhang.com/ZacharyZhang-NY/8bitMyGoUI/pixel"
|
|
)
|
|
|
|
type ShakeOptions struct {
|
|
// Cue shakes the child each time it changes.
|
|
Cue int
|
|
}
|
|
|
|
// shakes are the child's offsets in dots, a step each.
|
|
var shakes = [...]int{2, -2, 2, -2, 1, -1, 0}
|
|
|
|
// Shake jolts its child side to side briefly.
|
|
func Shake(c *ui.Context, o ShakeOptions, content func()) *ui.Element {
|
|
k := pixel.K(c)
|
|
e := ui.Box(c)
|
|
dx := shakes[k.Shot(c, e, o.Cue, 20, len(shakes)-1)]
|
|
return e.Padding(0, k.D(2-dx), 0, k.D(2+dx)).Children(content)
|
|
}
|