Global vs Rolling Shutter Simulator¶
Specification¶
The full specification below is extracted from Chapter 14: Raspberry Pi 5 Hardware: Storage, Camera, and Cooling.
Type: microsim
**sim-id:** global-vs-rolling-shutter-simulator<br/>
**Library:** p5.js<br/>
**Status:** Specified
Learning objective: Students will *analyze* (Bloom L4: Analyze) how a rolling shutter camera's row-by-row capture produces a skewed image of a fast-moving object compared to a global shutter camera's single-instant capture.
Canvas: 700x460px, responsive — split into two side-by-side "captured frame" panels (stacked below 560px wide) labeled "Rolling Shutter" and "Global Shutter," recomputed as fractions of `width`/`height` inside `windowResized()`.
Layout: a simple moving object (a striped vertical bar, drawn with `rect()`) crosses a scene at a controllable speed. Each panel shows what that panel's camera type "captured" as a still frame: the global shutter panel always shows an undistorted straight bar; the rolling shutter panel shows the bar progressively skewed based on the current speed setting, simulating the row-by-row readout delay.
Controls: a `createSlider()` labeled "Object Speed" (range 1-10, default 3); a `createButton()` labeled "Capture Frame" that freezes both panels showing the current simulated result; a `createButton()` labeled "Resume" that restarts the moving object.
Interaction: as "Object Speed" increases, the rolling shutter panel's captured skew visibly increases while the global shutter panel remains unaffected, letting students directly compare the two side effects of the same motion. After clicking "Capture Frame," hovering either panel shows a one-sentence tooltip naming which shutter type produced that result and why.
Implementation: p5.js. Model the rolling shutter skew by offsetting each horizontal row of the drawn bar by an amount proportional to (row index) times (current speed) times a small readout-delay constant, drawn with many thin horizontal `rect()` slices rather than one solid shape. The global shutter panel draws the same bar with zero offset regardless of speed. Keep both panels' object position synchronized from a single shared position variable so the comparison stays fair.