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.
This commit is contained in:
56 files changed
+3324
-101
No files matched your search
+41
@@ -0,0 +1,41 @@
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user