Show HN: A playable game of Tetris inside a PDF

I realized that the PDF engines of modern desktop browsers (PDFium and PDF.js) support JavaScript with enough I/O primitives to make a basic game like Tetris.

It was a bit tricky to find a union of features that work in both engines, but in the end it turns out that showing/hiding annotation "fields" works well to make monochrome pixels, and keyboard input can be achieved by typing in a text input box.

All in all it's quite janky but a nice reminder of how general purpose PDF scripting can be. The linked PDF is all ASCII so you can just open it in a text editor, or have a look at the source code here: https://github.com/ThomasRinsma/pdftris/blob/main/gengrid.py


Comments URL: https://news.ycombinator.com/item?id=42645218

Points: 85

# Comments: 19

https://th0mas.nl/downloads/pdftris.pdf

созданный 6mo | 9 янв. 2025 г., 16:30:11


Войдите, чтобы добавить комментарий

Другие сообщения в этой группе

Show HN: I made a JSFiddle-style playground to test and share prompts fast

I built this out of frustration as I lead the development of AI features at Yola.com.

Prompt testing should be simple and straightforward. All I wanted was a simple way to test prompts with vari

13 июл. 2025 г., 02:20:11 | Hacker news
Zig's New Async I/O
13 июл. 2025 г., 02:20:11 | Hacker news