Tilt the phone to light a live card

Three cards made of HTML, drawn through foil, hologram and lenticular shaders. Press "Use the phone's tilt" and tilt the phone: the cards lean and their surfaces change with the angle. Without a sensor, move the pointer or drag a finger across the panel. The buttons on the cards work while they lean. The third card has two faces and shows one or the other by angle.

Canvas Bank •••• •••• •••• 0042 A. Lovelace 12/29
Admit one Row 12, seat 4
Grace Hopper Speaker, hall B
Access code 4821 Lean the other way for the name

The lean follows the pointer. With no input for a moment it moves in a circle.

Show the code tilt → custom properties → shader and hit box
  1. The markup. Three ordinary blocks. fx names the shader.
  2. The page script. One call connects the tilt sensor and the pointer to --fx-x and --fx-y. The rest handles the button and the badge's faces.
  3. Reading the sensor. requestPermission() where it exists, then deviceorientation events measured from the first angle.
  4. The lean. A perspective matrix from the two numbers. The library uses it for the picture and for hit testing.
  5. The foil shader.
  6. The functions the three shaders share.
  7. Marking the hologram patch.
  8. The hologram shader.
  9. Two faces, interleaved in CSS.
  10. The lenses over them.
  11. Inside the fx library: the upload and the draw.

How it works

Live checks

Each check builds its own fixture in a corner of the window. The cards above aren't touched.

ResultExperimentDetail

Findings

From Chromium 157 with software rendering and no orientation sensor. The rows above say what your browser does.