Add media components 346-365; input.SlideBase, guarded Pad

An audio player with transport, scrubber and volume; an equalizer and
a visualizer; a playlist; a cassette, cartridge and record that turn
while they play and hold where they stop; piano keys, a step sequencer
and a tracker you can type into; a waveform, a 16:9 video frame, an
image compare, a gallery, a filmstrip, a record button and an FM tuner.

input exports SlideBase, the undrawn rail its sliders share; the
gallery treats exported Bases as building blocks, not components.
pixel's micro font gains '#' for notes like C#4. pixel.Pad and the
slide rail read input only while their base is enabled, so Inert or a
fresh Disabled stops a drag or a key already sent. AGENTS records why
a drawn container keeps the DISABLED description: MyGo paints a
disabled subtree at half opacity.
This commit is contained in:
ZacharyZhang-NY committed 2026-10-12 06:17:12 -04:00
1 parent 455f5f2a05
commit 0e21870b64
39 files changed
+3066 -10

No files matched your search

+66
View File
@@ -0,0 +1,66 @@
package media
import (
"fmt"
"math"
"strings"
"github.com/egoist/mygo/ui"
"git.zacharyzhang.com/ZacharyZhang-NY/8bitMyGoUI/pixel"
)
type CassetteOptions struct {
// Title is written on the label in the micro font.
Title string
Playing bool
// Progress, 0 to 1, is tape on the right reel.
Progress float64
}
// Cassette turns its reels while playing; tape winds right.
func Cassette(c *ui.Context, text string, o CassetteOptions) *ui.Element {
k := pixel.K(c)
if !(o.Progress >= 0 && o.Progress <= 1) {
panic(fmt.Sprintf("media: Cassette Progress %v outside 0–1", o.Progress))
}
title := strings.ToUpper(o.Title)
if !pixel.MicroOK(title) || pixel.MicroWidth(title) > 52 {
panic(fmt.Sprintf("media: Cassette Title %q does not fit the label", o.Title))
}
e := art(c, k, text, 64, 40)
frame := turned(c, k, e, o.Playing, 8) % 2
return e.Draw(func(p *ui.Painter, r ui.Rect) {
g := k.Canvas(p, r)
body, line := dark(k)
g.Frame(0, 0, 64, 40, pixel.Raised, pixel.Face)
g.Rect(4, 3, 56, 26, pixel.Lit)
g.Micro(7, 5, title, pixel.Ink, 1)
g.Rect(4, 11, 56, 2, pixel.Accent)
g.Rect(14, 14, 36, 13, body)
// Packs trade tape as it plays.
wound := int(math.Round(o.Progress * 3))
for i, cx := range []int{23, 40} {
pack := 3 + wound
if i == 0 {
pack = 6 - wound
}
g.Disc(cx, 20, pack, line)
g.Disc(cx, 20, 2, pixel.Lit)
for _, d := range [2][4][2]int{{{1, 0}, {-1, 0}, {0, 1}, {0, -1}}, {{1, 1}, {-1, -1}, {1, -1}, {-1, 1}}}[frame] {
g.Dot(cx+d[0], 20+d[1], body)
}
}
// The head opening, with its pins.
for y := range 8 {
g.HLine(18-y/2, 32+y, 28+y, pixel.Shade)
}
for _, x := range []int{21, 30, 33, 42} {
g.Rect(x, 35, 2, 2, body)
}
for _, x := range []int{4, 59} {
g.HLine(x-1, 34, 3, pixel.Shade)
g.VLine(x, 33, 3, pixel.Shade)
}
})
}