New best story on Hacker News: Show HN: Tetris in a PDF

Show HN: Tetris in a PDF
967 by ThomasRinsma | 175 comments on Hacker News.
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://ift.tt/zSAXsyC

Comments

Popular posts from this blog

एक्सपर्ट व्यू: कैसे पता चलेगा कि आपके फोन में पेगासस है, पांच सवाल -जवाब से समझिए इस वायरस के बारे में

एक महीने में 1.29 करोड़ ग्राहक छोड़ गए जियो का साथ, बीएसएनएल को मिला फायदा

पिछले 5 महीने में 25 सरकारी वेबसाइट्स को हैकर्स ने बनाया शिकार: रविशंकर प्रसाद