This commit is contained in:
Priec
2026-06-01 23:40:17 +02:00
parent 99f255fc29
commit 462a53853f
12 changed files with 4403 additions and 238 deletions

View File

@@ -1,4 +1,4 @@
.PHONY: help serve size validate tidy ascii clean
.PHONY: help serve size validate tidy video video-list video-frames video-bundle clean
help: ## Show this help
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | \
@@ -31,11 +31,36 @@ validate: ## Quick HTML sanity check (counts opening vs closing tags)
tidy: ## Run html-tidy on every .html
@for f in *.html; do echo "--- $$f ---"; tidy -e -q $$f || true; done
ascii: ## Regenerate the body-rain ASCII art (needs chafa)
@mkdir -p static/ascii
chafa -f symbols -c none -s 240x60 --symbols ascii --animate off \
static/img/og-image-bg.svg > static/ascii/rain.txt
@echo "Regenerated static/ascii/rain.txt (from static/img/og-image-bg.svg)"
video: ## Convert a video from video/<name>.mp4 into ASCII bundle. Usage: make video NAME=nature1
@test -n "$(NAME)" || { echo "Usage: make video NAME=<name> (without .mp4)"; exit 1; }
@test -f "video/$(NAME).mp4" || { echo "video/$(NAME).mp4 not found. Available:"; $(MAKE) video-list; exit 1; }
@echo "==> Processing video/$(NAME).mp4"
@$(MAKE) video-frames NAME=$(NAME) --no-print-directory
@$(MAKE) video-bundle NAME=$(NAME) --no-print-directory
@echo "==> Done. static/js/mountain.js is now the ASCII version of $(NAME)."
video-list: ## List available videos in video/
@ls -1 video/*.mp4 2>/dev/null | sed 's|video/||; s|\.mp4$$||' || echo " (no videos found)"
video-frames: ## Extract PNG frames from video/<NAME>.mp4 and chafa each to ASCII
@test -n "$(NAME)" || { echo "NAME is required"; exit 1; }
@mkdir -p build/$(NAME)
@command -v ffmpeg >/dev/null 2>&1 || \
{ echo "ffmpeg not found. Run via: nix develop -c make video-frames NAME=$(NAME)"; exit 1; }
@command -v chafa >/dev/null 2>&1 || \
{ echo "chafa not found. Run via: nix develop -c make video-frames NAME=$(NAME)"; exit 1; }
@echo " extracting frames at 12 fps from video/$(NAME).mp4"
@ffmpeg -y -loglevel error -i video/$(NAME).mp4 -vf "fps=12,scale=320:-1" build/$(NAME)/frame-%03d.png
@echo " chafa: 80x24 ascii per frame"
@for f in build/$(NAME)/frame-*.png; do \
chafa -f symbols -c none -s 80x24 --symbols ascii --animate off "$$f" > "$${f%.png}.txt"; \
done
@echo " rendered $$(($$(ls build/$(NAME)/frame-*.png | wc -l))) PNG + ASCII frames in build/$(NAME)/"
video-bundle: ## Bundle ASCII frames from build/<NAME>/ into static/js/mountain.js
@test -n "$(NAME)" || { echo "NAME is required"; exit 1; }
@python3 tools/build_mountain_js.py build/$(NAME) static/js/mountain.js
@echo " bundled static/js/mountain.js (regenerated from build/$(NAME)/)"
clean: ## Remove build artefacts
@rm -rf bin/ node_modules/ dist/