feat(app): update demo mode to use real content
- Fetch real news/poetry content instead of random letters - Render full ticker zone with scroll, gradients, firehose - Demo now shows actual effect behavior on real content
This commit is contained in:
104
engine/app.py
104
engine/app.py
@@ -352,7 +352,7 @@ def pick_effects_config():
|
|||||||
|
|
||||||
|
|
||||||
def run_demo_mode():
|
def run_demo_mode():
|
||||||
"""Run demo mode - showcases effects with pygame display."""
|
"""Run demo mode - showcases effects with real content and pygame display."""
|
||||||
import random
|
import random
|
||||||
|
|
||||||
from engine import config
|
from engine import config
|
||||||
@@ -364,9 +364,11 @@ def run_demo_mode():
|
|||||||
get_registry,
|
get_registry,
|
||||||
set_monitor,
|
set_monitor,
|
||||||
)
|
)
|
||||||
|
from engine.fetch import fetch_all, fetch_poetry, load_cache
|
||||||
|
from engine.scroll import calculate_scroll_step
|
||||||
|
|
||||||
print(" \033[1;38;5;46mMAINLINE DEMO MODE\033[0m")
|
print(" \033[1;38;5;46mMAINLINE DEMO MODE\033[0m")
|
||||||
print(" \033[38;5;245mInitializing pygame display...\033[0m")
|
print(" \033[38;5;245mInitializing...\033[0m")
|
||||||
|
|
||||||
import effects_plugins
|
import effects_plugins
|
||||||
|
|
||||||
@@ -374,7 +376,7 @@ def run_demo_mode():
|
|||||||
|
|
||||||
registry = get_registry()
|
registry = get_registry()
|
||||||
chain = get_effect_chain()
|
chain = get_effect_chain()
|
||||||
chain.set_order(["hud"])
|
chain.set_order(["hud", "noise", "fade", "glitch", "firehose"])
|
||||||
|
|
||||||
monitor = PerformanceMonitor()
|
monitor = PerformanceMonitor()
|
||||||
set_monitor(monitor)
|
set_monitor(monitor)
|
||||||
@@ -385,30 +387,46 @@ def run_demo_mode():
|
|||||||
print(" \033[38;5;196mFailed to create pygame display\033[0m")
|
print(" \033[38;5;196mFailed to create pygame display\033[0m")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
display.init(80, 24)
|
w, h = 80, 24
|
||||||
|
display.init(w, h)
|
||||||
display.clear()
|
display.clear()
|
||||||
|
|
||||||
|
print(" \033[38;5;245mFetching content...\033[0m")
|
||||||
|
|
||||||
|
cached = load_cache()
|
||||||
|
if cached:
|
||||||
|
items = cached
|
||||||
|
elif config.MODE == "poetry":
|
||||||
|
items, _, _ = fetch_poetry()
|
||||||
|
else:
|
||||||
|
items, _, _ = fetch_all()
|
||||||
|
|
||||||
|
if not items:
|
||||||
|
print(" \033[38;5;196mNo content available\033[0m")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
random.shuffle(items)
|
||||||
|
pool = list(items)
|
||||||
|
seen = set()
|
||||||
|
active = []
|
||||||
|
scroll_cam = 0
|
||||||
|
ticker_next_y = 0
|
||||||
|
noise_cache = {}
|
||||||
|
scroll_motion_accum = 0.0
|
||||||
|
frame_number = 0
|
||||||
|
|
||||||
|
GAP = 3
|
||||||
|
scroll_step_interval = calculate_scroll_step(config.SCROLL_DUR, h)
|
||||||
|
|
||||||
effects_to_demo = ["noise", "fade", "glitch", "firehose"]
|
effects_to_demo = ["noise", "fade", "glitch", "firehose"]
|
||||||
w, h = 80, 24
|
|
||||||
|
|
||||||
base_buffer = []
|
|
||||||
for row in range(h):
|
|
||||||
line = ""
|
|
||||||
for col in range(w):
|
|
||||||
char = random.choice("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 ")
|
|
||||||
line += char
|
|
||||||
base_buffer.append(line)
|
|
||||||
|
|
||||||
print(" \033[38;5;82mStarting effect demo...\033[0m")
|
|
||||||
print(" \033[38;5;245mPress Ctrl+C to exit\033[0m\n")
|
|
||||||
|
|
||||||
effect_idx = 0
|
effect_idx = 0
|
||||||
effect_name = effects_to_demo[effect_idx]
|
effect_name = effects_to_demo[effect_idx]
|
||||||
effect_start_time = time.time()
|
effect_start_time = time.time()
|
||||||
current_intensity = 0.0
|
current_intensity = 0.0
|
||||||
ramping_up = True
|
ramping_up = True
|
||||||
|
|
||||||
frame_count = 0
|
print(" \033[38;5;82mStarting effect demo...\033[0m")
|
||||||
|
print(" \033[38;5;245mPress Ctrl+C to exit\033[0m\n")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
while True:
|
while True:
|
||||||
@@ -435,7 +453,7 @@ def run_demo_mode():
|
|||||||
if effect.name == effect_name:
|
if effect.name == effect_name:
|
||||||
effect.config.enabled = True
|
effect.config.enabled = True
|
||||||
effect.config.intensity = current_intensity
|
effect.config.intensity = current_intensity
|
||||||
elif effect.name not in ("hud", effect_name):
|
elif effect.name not in ("hud",):
|
||||||
effect.config.enabled = False
|
effect.config.enabled = False
|
||||||
|
|
||||||
hud_effect = registry.get("hud")
|
hud_effect = registry.get("hud")
|
||||||
@@ -443,22 +461,58 @@ def run_demo_mode():
|
|||||||
hud_effect.config.params["display_effect"] = effect_name
|
hud_effect.config.params["display_effect"] = effect_name
|
||||||
hud_effect.config.params["display_intensity"] = current_intensity
|
hud_effect.config.params["display_intensity"] = current_intensity
|
||||||
|
|
||||||
|
scroll_motion_accum += config.FRAME_DT
|
||||||
|
while scroll_motion_accum >= scroll_step_interval:
|
||||||
|
scroll_motion_accum -= scroll_step_interval
|
||||||
|
scroll_cam += 1
|
||||||
|
|
||||||
|
from engine.effects import next_headline
|
||||||
|
from engine.render import make_block
|
||||||
|
|
||||||
|
while ticker_next_y < scroll_cam + h + 10:
|
||||||
|
t, src, ts = next_headline(pool, items, seen)
|
||||||
|
ticker_content, hc, midx = make_block(t, src, ts, w)
|
||||||
|
active.append((ticker_content, hc, ticker_next_y, midx))
|
||||||
|
ticker_next_y += len(ticker_content) + GAP
|
||||||
|
|
||||||
|
active = [
|
||||||
|
(c, hc, by, mi)
|
||||||
|
for c, hc, by, mi in active
|
||||||
|
if by + len(c) > scroll_cam
|
||||||
|
]
|
||||||
|
for k in list(noise_cache):
|
||||||
|
if k < scroll_cam:
|
||||||
|
del noise_cache[k]
|
||||||
|
|
||||||
|
grad_offset = (time.time() * config.GRAD_SPEED) % 1.0
|
||||||
|
|
||||||
|
from engine.layers import render_ticker_zone
|
||||||
|
|
||||||
|
buf, noise_cache = render_ticker_zone(
|
||||||
|
active, scroll_cam, h, w, noise_cache, grad_offset
|
||||||
|
)
|
||||||
|
|
||||||
|
from engine.layers import render_firehose
|
||||||
|
|
||||||
|
firehose_buf = render_firehose(items, w, 0, h)
|
||||||
|
buf.extend(firehose_buf)
|
||||||
|
|
||||||
ctx = EffectContext(
|
ctx = EffectContext(
|
||||||
terminal_width=w,
|
terminal_width=w,
|
||||||
terminal_height=h,
|
terminal_height=h,
|
||||||
scroll_cam=0,
|
scroll_cam=scroll_cam,
|
||||||
ticker_height=h,
|
ticker_height=h,
|
||||||
mic_excess=0.0,
|
mic_excess=0.0,
|
||||||
grad_offset=time.time() % 1.0,
|
grad_offset=grad_offset,
|
||||||
frame_number=frame_count,
|
frame_number=frame_number,
|
||||||
has_message=False,
|
has_message=False,
|
||||||
items=[],
|
items=items,
|
||||||
)
|
)
|
||||||
|
|
||||||
result = chain.process(base_buffer, ctx)
|
result = chain.process(buf, ctx)
|
||||||
display.show(result)
|
display.show(result)
|
||||||
|
|
||||||
frame_count += 1
|
frame_number += 1
|
||||||
time.sleep(1 / 60)
|
time.sleep(1 / 60)
|
||||||
|
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
|
|||||||
Reference in New Issue
Block a user