Combining animation.Scale with animation.Translate to center the zoom (two commits back) visually fixed the top-left crop bias, but introduced a worse problem: pixlet periodically re-rasterizes the whole image with a visible "pop" roughly every 0.7-1s, confirmed with both WebP and GIF output and independent of zoom amplitude -- a property of pixlet's animation engine when Scale and Translate are combined, not something fixable from this app's math. Scale alone, with no Translate, has none of this popping (confirmed via isolated testing). Reverted _art_widget to Scale-only (as it was before centering), and restored ZOOM_LEVELS["strong"] to 1.7 (the strong-zoom black border only applied to the Translate-based centering, not plain Scale). This brings back the original top-left crop bias as a known, accepted cosmetic trade-off -- better than a periodic visible pop. Updated the README and dev/calibration_test.star to match and documented the full history for anyone who wants to revisit centering later.
58 lines
2.5 KiB
Python
58 lines
2.5 KiB
Python
"""
|
|
Dev tool, not part of the deployed app: renders dev/calibration.png through
|
|
the exact same zoom logic as _art_widget in subwave_nowplaying.star, so you
|
|
can visually check how much margin gets cropped at rest and at full zoom.
|
|
|
|
calibration.png is a 360x360 grid: concentric 10%-wide color rings (magenta
|
|
outermost, then yellow, then cyan) plus four corner markers (red TL, green
|
|
TR, blue BL, white BR) and a center crosshair.
|
|
|
|
Usage:
|
|
pixlet render dev/calibration_test.star -o calib.gif
|
|
pixlet render dev/calibration_test.star zoom_scale=1.0 -o calib_rest.gif # rest only
|
|
|
|
Keep ART_SIZE/ART_SLOT/the zoom math below in sync with the real
|
|
_art_widget if that ever changes.
|
|
|
|
Note: a centered (Scale + Translate) version of this zoom was tried and
|
|
visually fixed the top-left crop bias below, but combining Scale with
|
|
Translate causes pixlet to periodically re-rasterize the whole image with
|
|
a visible "pop" -- confirmed with both WebP and GIF output, independent of
|
|
zoom amplitude, so it's pixlet's animation engine, not app-level math. This
|
|
tool (and the real app) stick to Scale alone -- a real but minor crop-bias
|
|
cosmetic issue, instead of the pop a centered zoom introduces. If you want
|
|
to re-investigate centering, add animation.Translate back in here first
|
|
and compare frame-to-frame pixel deltas (see git history around the
|
|
"Center the album art zoom" / "Revert jerky zoom fix" commits) before
|
|
touching the real app.
|
|
"""
|
|
|
|
load("render.star", "render")
|
|
load("animation.star", "animation")
|
|
load("calibration.png", CALIB = "file")
|
|
|
|
ART_SIZE = 36
|
|
ART_SLOT = 32
|
|
ART_ZOOM_DURATION = 200
|
|
|
|
def _art_widget(art_bytes, zoom_scale):
|
|
art = render.Image(src = art_bytes, width = ART_SIZE, height = ART_SIZE)
|
|
top_scale = max(zoom_scale, 1.0)
|
|
zoom = animation.Transformation(
|
|
child = art,
|
|
duration = ART_ZOOM_DURATION,
|
|
keyframes = [
|
|
animation.Keyframe(percentage = 0.0, transforms = [animation.Scale(1.0, 1.0)]),
|
|
animation.Keyframe(percentage = 0.5, transforms = [animation.Scale(top_scale, top_scale)], curve = "ease_in_out"),
|
|
animation.Keyframe(percentage = 1.0, transforms = [animation.Scale(1.0, 1.0)], curve = "ease_in_out"),
|
|
],
|
|
)
|
|
return render.Box(width = ART_SLOT, height = ART_SLOT, child = zoom)
|
|
|
|
def main(config):
|
|
zoom_scale = float(config.get("zoom_scale", "1.4"))
|
|
return render.Root(child = render.Row(children = [
|
|
_art_widget(CALIB.readall(), zoom_scale),
|
|
render.Box(width = 32, height = 32, color = "#111111"),
|
|
]))
|