← Back to Work

WinDuo

The iPhone Duo Fold Effect on Windows, With No Hinge Sensor
Role & Team
Creator & Sole Author
Timeline
Sep 2026
Stack
Python, PyQt6, OpenCV, GLSL
Verification
118 tests, no camera or lid required

Overview

Apple's iPhone Duo blurs and dims its screen as it folds shut, tracking the hinge the whole way down. Mac Duo ported that effect to MacBooks days later, reading the lid angle sensor Apple has shipped since the 2019 16-inch MacBook Pro. Almost no other laptop has that sensor, including every Windows machine. WinDuo is the same effect for those, measuring the lid's rotation from the webcam instead of a sensor that doesn't exist.

It ships as a single 84 MB executable with a tray icon, or as a Python package for anyone who wants to run it from source. Both are free for personal use under a license I wrote to require that: PolyForm Noncommercial 1.0.0.

Measuring a Hinge With No Sensor

A laptop's hinge is a single axis, and the webcam sits on the far side of it. Rotating the lid rotates the camera by the same amount around that axis, with no panning and no roll. Pitch alone slides the whole camera image vertically, at roughly 15 pixels per degree, so the entire measurement reduces to one number per frame: how far the image moved since the last one.

WinDuo finds that shift with phase correlation on a pair of downscaled grayscale frames, in under a millisecond. Adding per-frame shifts across a whole lid movement would drift, so nothing tries to track an absolute angle. Whenever the lid holds still for a moment, that position becomes the new zero, and the fold effect runs on movement away from it. That also means the effect works with the laptop flat on a desk, on a lap, or tilted at any angle, and it removes the timeout setting Mac Duo needs to end the effect when the lid stops partway: here a stopped lid just becomes the new rest, so the effect eases back to flat on its own.

Converting pixels to degrees needs one known angle, which a camera alone can't supply. A twenty-second calibration wizard asks for it once: drag a silhouette to match the normal viewing position, repeat roughly halfway closed, then close the lid the rest of the way. Windows' own lid switch gives a free, exact zero at that last step.

Rendering the Fold

The visual effect runs as a GLSL shader over a transparent, click-through overlay window: perspective warp as the screen leans back, a blur that grows toward the far edge, and dimming from the hinge upward. The overlay has to stay out of its own screen capture, which surfaces a real Windows quirk: DXGI Desktop Duplication, the API used to grab the screen content the overlay warps, will happily capture the overlay window itself under independent flip presentation, producing a black frame that is the overlay capturing its own black background. Excluding the overlay from capture explicitly fixes it.

A second capture bug showed up only during calibration: the wizard forced a 1/128s exposure to keep motion blur out of the angle estimate, which on some webcams under normal indoor light produced frames that were black rather than merely dark. Exposure is now adaptive instead of fixed.

What It Won't Do

The camera indicator light stays on the whole time WinDuo runs, because it has to be watching before the lid starts moving; each frame is compared against the last and discarded, and nothing is recorded or leaves the machine. Another app taking the camera, a video call, will stop WinDuo from reading the lid, and it says so in the tray rather than failing silently. Picking the whole laptop up can trigger the effect too, since rotating the machine looks like closing the lid to anything measuring the frame as a whole; a dark room costs accuracy the same way, since the short exposure needed to avoid motion blur is a noisier image with less light behind it.

Attribution and Verification

Mac Duo is Apache 2.0 licensed, and its geometry, shader, and effect state machine are ported here rather than reinvented; the required attribution is preserved in the repo's NOTICE file, and Apache 2.0's own terms permit relicensing a derivative under different terms as long as that notice stays intact. The webcam angle estimator is the new part, since the sensor Mac Duo reads is exactly what's missing on Windows.

118 tests run in CI and need no camera, screen, or physical lid, covering the angle estimator, the effect state machine, and the calibration math directly. The GitHub Actions release build had to be trimmed down separately: an early build pulled in all of PyQt6 and OpenCV's unused video codecs and came out at 151 MB; scoping the PyInstaller collection to only the Qt modules actually imported, and dropping OpenCV's ffmpeg decoder before packaging, brought the release executable to 83.7 MB.