nowfound

Life & fun · January 9, 2025

TI

Tetris in 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…

Visit th0mas.nlAlternativestop 1% of January 2025

In plain words

Tetris in a PDF is a playable implementation of Tetris built entirely within a PDF file using JavaScript supported by modern browser PDF engines. It works by using annotation fields to create monochrome pixels and a text input box for keyboard controls. The game is fully viewable as ASCII text in any text editor, demonstrating how PDF scripting can support interactive applications despite technical limitations across different PDF engines.

written from the facts on this page · September 2026

From the sources

In the maker’s words, at launch

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

More life & fun this month

the category →
  • TL

    Life & fun · 9d ago · louisabraham.github.io

  • Photosynthesis fires two of your iPhone

    Life & fun · 28d ago · photosynthesis.camera

  • SoloUno310

    Take control of hair pulling, nail biting & skin picking

    Life & fun · 28d ago · solouno.io

  • Scroll through all 43,252,003,274,489,856,000 reachable Rubik's Cube permutations.

    Life & fun · 26d ago · everycube.alen.is

  • The Interactive 3D Encyclopedia

    Life & fun · 21d ago · expeditione.fun

  • Hi HN, I built Eigendrum, a web tool that solves the 2D wave equation for arbitrary shapes so you can hear what they sound like as drums. How it works: * Solves -∇²u = λu using finite element analysis (Kφ = λMφ) on a triangle mesh. * Validated to <0.1% error against closed-form solutions for circles (Bessel zeros) and rectangles. * Sound model factors in strike location, Rayleigh damping, and mallet width. * Includes Kac drums I & II to demonstrate identical sound spectra from different geometries. * No frameworks, build steps, or dependencies. Repo and tests:…

    Life & fun · 26d ago · baselashraf81.github.io

Launched alongside, January 2025

the whole month →