Replace bundled static.gif with a live RGB-split glitch effect
Rebuilt the track-transition "static overlay" as a chromatic-aberration glitch on the *live* album art instead of a bundled, pre-baked animated GIF: two duplicate, differently-tinted copies of the actual art (via filter.Hue, confirmed real and working), each cropped to a shifting horizontal band, plus scanlines and viewfinder-style corner tick marks. Loosely modeled on SUB/WAVE's own web UI, which does something similar to its cover art on track change (found via its compiled CSS/JS: a .v3-cover-live class gating an RGB-split band glitch, sweeping scanlines, and corner tick marks). The exact keyframe timing past the first step wasn't visible in the minified output, so GLITCH_STATES is an original jitter sequence in the same spirit, not a reproduction of unseen code. This is the third design for this effect: sparse noise specks, then a version derived from a real "VHS glitch" stock-footage clip (dropped because recognizable footage content showed through at 32x32, and it compressed worse than procedural noise), now this. Since it needs no bundled asset, the app goes back to a single-file upload -- reverted the Deploy section accordingly. Verified: renders cleanly across all zoom-level/static-overlay combinations, payload stays well under the 460KB limit, and render.Sequence's lack of looping (confirmed in pixlet's own source) means the RGB-split jitter plays once per show_static window and settles to just scanlines/ticks over clean art for the remainder, not a constant distraction for the whole window.
This commit is contained in:
1 parent
8e101b997e
commit
2993e9e9a9
3 files changed
+148
-48
No files matched your search
+110
-14
@@ -11,7 +11,7 @@ load("http.star", "http")
|
||||
load("cache.star", "cache")
|
||||
load("time.star", "time")
|
||||
load("animation.star", "animation")
|
||||
load("images/static.gif", STATIC_ASSET = "file")
|
||||
load("filter.star", "filter")
|
||||
|
||||
DEFAULT_STATION_URL = ""
|
||||
NOWPLAYING_TTL = 20
|
||||
@@ -274,6 +274,14 @@ ART_SLOT = 32
|
||||
ART_ZOOM_DURATION = 200 # 10s round-trip (5s in, 5s out) at the default 50ms/tick
|
||||
|
||||
def _art_widget(art_bytes, zoom_scale, zoom_position, subsonic_id, show_static):
|
||||
cropped = _zoomed_art(art_bytes, zoom_scale, zoom_position, subsonic_id)
|
||||
|
||||
if not show_static:
|
||||
return cropped
|
||||
|
||||
return render.Stack(children = [cropped, _glitch_effect(cropped)])
|
||||
|
||||
def _zoomed_art(art_bytes, zoom_scale, zoom_position, subsonic_id):
|
||||
art = render.Image(src = art_bytes, width = ART_SIZE, height = ART_SIZE)
|
||||
|
||||
# Always route through animation.Transformation, even when zoom is off
|
||||
@@ -320,21 +328,109 @@ def _art_widget(art_bytes, zoom_scale, zoom_position, subsonic_id, show_static):
|
||||
),
|
||||
],
|
||||
)
|
||||
cropped = render.Box(width = ART_SLOT, height = ART_SLOT, child = zoom)
|
||||
return render.Box(width = ART_SLOT, height = ART_SLOT, child = zoom)
|
||||
|
||||
if not show_static:
|
||||
return cropped
|
||||
# Modeled on SUB/WAVE's own web UI, which applies a track-transition
|
||||
# effect to the cover art (found via its compiled CSS/JS, not written down
|
||||
# anywhere as a spec): an RGB-split/chromatic-aberration glitch -- two
|
||||
# duplicate, differently-tinted copies of the art, each cropped to a
|
||||
# shifting horizontal band -- plus scanlines and viewfinder-style corner
|
||||
# tick marks. Built here from scratch against the *live* art via
|
||||
# filter.Hue, not a bundled asset -- pixlet's `filter` module (confirmed
|
||||
# real and working, same as `animation.Origin`) can recolor an arbitrary
|
||||
# widget, including an already-zoomed render.Image, so the glitch bands
|
||||
# reflect whatever's actually on screen rather than a generic texture.
|
||||
# This replaced an earlier version built as a bundled static.gif overlay
|
||||
# (first sparse noise specks, briefly a VHS-footage-derived band) -- that
|
||||
# approach is still viable for projects without filter.star, but once a
|
||||
# live-recolor option exists it's a better match for what SUB/WAVE itself
|
||||
# does, and it means this app goes back to a single-file upload (no
|
||||
# bundled asset to zip alongside it).
|
||||
#
|
||||
# The exact keyframe sequence/timing SUB/WAVE's CSS uses past the first
|
||||
# keyframe isn't visible in its compiled output (no source maps), so
|
||||
# GLITCH_STATES below is an original sequence in the same spirit (shifting
|
||||
# inset bands, step-end/snap timing via a Sequence rather than eased
|
||||
# motion) rather than a reproduction of unseen code. Band proportions
|
||||
# (top/height as a fraction of ART_SLOT) are loosely modeled on the one
|
||||
# keyframe that was visible: roughly the top third and an overlapping
|
||||
# middle band, each about 30% of the frame's height.
|
||||
GLITCH_HOLD_TICKS = 5 # ~250ms per jitter state at the default 50ms/tick
|
||||
GLITCH_STATES = [
|
||||
# (top1, height1, shift1, hue1, top2, height2, shift2, hue2)
|
||||
(3, 9, -2, 150.0, 19, 8, 2, -60.0),
|
||||
(2, 8, 2, 150.0, 20, 9, -3, -60.0),
|
||||
(5, 7, -3, 150.0, 17, 10, 1, -60.0),
|
||||
(1, 10, 1, 150.0, 21, 7, -2, -60.0),
|
||||
]
|
||||
|
||||
# images/static.gif is a bundled, pre-baked animated GIF (sparse noise
|
||||
# specks over a transparent background) -- not something generated at
|
||||
# render time. pixlet's Starlark sandbox has no per-frame procedural
|
||||
# drawing hook; animated widgets work by either interpolating
|
||||
# animation.Transformation keyframes (no good way to get true random
|
||||
# noise out of that) or, as here, by playing back a real animated
|
||||
# image asset, which render.Image supports natively for GIFs. The GIF
|
||||
# loops independently of ART_ZOOM_DURATION at its own frame rate.
|
||||
static = render.Image(src = STATIC_ASSET.readall(), width = ART_SLOT, height = ART_SLOT)
|
||||
return render.Stack(children = [cropped, static])
|
||||
def _glitch_band(zoomed_art, top, height, shift_x, hue_change):
|
||||
tinted = filter.Hue(child = zoomed_art, change = hue_change)
|
||||
band = render.Padding(
|
||||
pad = (0, top, 0, max(0, ART_SLOT - top - height)),
|
||||
child = render.Box(width = ART_SLOT, height = height, child = tinted),
|
||||
)
|
||||
return render.Padding(pad = (max(0, shift_x), 0, max(0, -shift_x), 0), child = band)
|
||||
|
||||
def _glitch_jitter(zoomed_art):
|
||||
states = []
|
||||
for top1, h1, shift1, hue1, top2, h2, shift2, hue2 in GLITCH_STATES:
|
||||
state = render.Stack(children = [
|
||||
_glitch_band(zoomed_art, top1, h1, shift1, hue1),
|
||||
_glitch_band(zoomed_art, top2, h2, shift2, hue2),
|
||||
])
|
||||
|
||||
# Wrapping in a no-op Transformation just to pin this state's
|
||||
# FrameCount to GLITCH_HOLD_TICKS, so render.Sequence holds on it
|
||||
# for that many ticks before advancing to the next state --
|
||||
# Sequence has no other way to control how long a child plays.
|
||||
states.append(animation.Transformation(
|
||||
child = state,
|
||||
duration = GLITCH_HOLD_TICKS,
|
||||
keyframes = [
|
||||
animation.Keyframe(percentage = 0.0, transforms = []),
|
||||
animation.Keyframe(percentage = 1.0, transforms = []),
|
||||
],
|
||||
))
|
||||
return render.Sequence(children = states)
|
||||
|
||||
def _glitch_scanlines():
|
||||
# render.Sequence doesn't loop (it just stops painting once its total
|
||||
# frame count is exhausted -- confirmed in pixlet's own source), so
|
||||
# the RGB-split jitter above plays once per show_static window and
|
||||
# then goes quiet; these persist for the whole window as a constant
|
||||
# texture rather than a one-shot burst, closer to how SUB/WAVE's
|
||||
# scanlines sweep continuously while its live class is applied.
|
||||
lines = []
|
||||
for y in range(ART_SLOT):
|
||||
if y % 4 == 0:
|
||||
lines.append(render.Box(width = ART_SLOT, height = 1, color = "#00000080"))
|
||||
else:
|
||||
lines.append(render.Box(width = ART_SLOT, height = 1, color = "#00000000"))
|
||||
return render.Column(children = lines)
|
||||
|
||||
def _glitch_corner_ticks(color):
|
||||
def tick():
|
||||
return render.Stack(children = [
|
||||
render.Box(width = 5, height = 1, color = color),
|
||||
render.Box(width = 1, height = 5, color = color),
|
||||
])
|
||||
|
||||
return render.Column(
|
||||
main_align = "space_between",
|
||||
expanded = True,
|
||||
children = [
|
||||
render.Row(main_align = "space_between", expanded = True, children = [tick(), tick()]),
|
||||
render.Row(main_align = "space_between", expanded = True, children = [tick(), tick()]),
|
||||
],
|
||||
)
|
||||
|
||||
def _glitch_effect(zoomed_art):
|
||||
return render.Stack(children = [
|
||||
_glitch_jitter(zoomed_art),
|
||||
_glitch_scanlines(),
|
||||
_glitch_corner_ticks("#33ff99"),
|
||||
])
|
||||
|
||||
def _message_screen(lines, colors):
|
||||
return render.Column(
|
||||
|
||||