03Object 03 · Displays & signs
Flip-Dot
The flip-disc sign from buses and stations. Every disc swings over, hits its stop, bounces and latches, so each message arrives as a clattering wave. One sign, or a board of them.
- Version
- 0.1.0
- Size
- 28.9 KB gzipped
- Access
- With a Pass
- Needs
- flip-dot.mjs + flip-dot.css
- Tests
- 36 tests · 13 states
Use it
A readout that is an object: a departures board, a live clock or scoreboard, a venue marquee, a status sign, or a hero the visitor writes on. Lines can be aligned, painted and rewritten one at a time; the message stays plain text for assistive technology; only the discs move.
Copy the flip-dot folder from its package next to your page, link its stylesheet and construct it on an element. Every option has a default; the lab’s Code tab writes the same example at any settings, and for React, Vue, Svelte or a custom element (Using a framework).
<link rel="stylesheet" href="flip-dot/flip-dot.css">
<div id="flip-dot" style="width: min(92vw, 1100px)"></div>
<script type="module">
import FlipDot from './flip-dot/flip-dot.mjs';
const flipDot = new FlipDot(document.getElementById('flip-dot'), {
text: 'NOW BOARDING',
mode: 'static',
font: 'auto',
});
// flipDot.update({ … }); change any option in place
// flipDot.destroy(); and take it away again
</script>Options
| Option | Type | Default | What it does |
|---|---|---|---|
| text | text | 'NOW BOARDING' | A | starts a second line. Letters, digits and . , : ; ! ? - + / ( ) & # % = < > @ * £ $ ° → ← |
| mode | static · marquee · clock · draw | 'static' | Static holds the message; marquee scrolls it; clock shows the time; draw lets the pointer write on the sign. |
| font | auto · large · small | 'auto' | Large is a bold 7×11, small a 5×7. Auto takes the large one when the message fits. |
| align | centre · left · right | 'centre' | Align |
| align2 | same · centre · left · right | 'same' | A board sets each line on its own: a destination left, a platform right. |
| cols | number, 16 to 160 | 96 | Columns |
| rows | number, 7 to 40 | 16 | Rows |
| disc | fluorescent · white · amber · signal | 'fluorescent' | Disc colour |
| disc2 | same · fluorescent · white · amber · signal | 'same' | The board’s fitting: the rows of the second line and after carry discs of another colour. |
| finish | graphite · ink · steel · brass | 'graphite' | Housing |
| glass | boolean | true | A faint veil and a reflection band placed by the lamp. |
| mount | none · hanging · wall | 'none' | Hanging from two drop rods, or bolted to the wall on flat brackets. The object grows by the mount. |
| wave | sweep · diagonal · centre · scatter | 'sweep' | The order the discs flip in when the message changes. |
| waveSpeed | number, 20 to 400 | 90 | Wave speed (columns/s) |
| bounce | number, 0 to 0.6 | 0.35 | How far a disc rebounds off its stop. 0 latches dead; 0.6 is a tired old sign. |
| light | number, 0 to 345 | 315 | 0 is from above, clockwise. |
| marqueeSpeed | number, 3 to 20 | 8 | A disc takes about a tenth of a second to turn. Past ten columns a second the letters are still turning when the next step comes, as on a real sign. |
| persistence | number, 0.5 to 10 | 2.5 | In draw mode, how long a stroke stays before its discs flip back. |
| intro | boolean | true | The sign starts dark and writes its message the first time it comes into view. |
| sound | boolean | false | Synthesised, no audio file. Plays only after you have touched the page. |
Methods
new FlipDot(element, options)- Builds it inside the element with these options.
update(opts = {})- Change options in place.
setText(text)- Show a new message, the departures-board way.
setLine(index, text, style = null)- Rewrite one line of the board: only its rows flip, with the wave, while the other lines hold (or finish their own wave).
setFrame(bits, label = '')- Show a raw bitmap (see normaliseBits for the shapes it takes).
replay()- Clear the sign with the wave, then write the message again.
pause()- Hold and release a marquee (give the page a control for it).
play()statemessagedestroy()- Stops it and cleans up after it.
Events it fires, which bubble from the element: flipdot:mode.
States
- At restEvery disc latched against its stop; the loop is asleep and requests no frames.
- Writing inThe first time the sign comes into view it starts dark and writes its message with the wave.
- Changing messageOnly the discs that differ flip, in a sweep, diagonal, ring or scatter that starts at the first change; each lands, rebounds and latches.
- MarqueeHolds the start of the message, then scrolls it a column at a time; stops while the pointer is over it or when paused.
- ClockHH:MM from the local time; the colon flips every second and the digits change with the wave. The accessible name updates once a minute, silently.
- DrawThe pointer inverts the discs it passes; each flips back after the configured time, in the order it was written.
- A board, one line at a timesetLine(i, text) rewrites one line with a wave confined to its rows; the other lines hold, or finish their own wave. Each line (and each tab-separated column) can carry its own alignment, face and disc paint.
- Glass coverOn by default: a 2.2 % veil and a reflection band with a firm edge and a soft tail on the lamp side, broken up by low-frequency unevenness, faded in under the bezel lip.
- MountedHanging from two drop rods (ceiling flange, rod, clevis, tab, bolt) or bolted to the wall on four flat brackets with their shadows; all per pixel from the same lamp. The object grows by its mount in percentage padding.
- RebuildingA resize, a colour, a lamp or a mount change is baked in 8 ms slices between frames (no task over 50 ms); the old picture stays up until the new one swaps in whole. A high-density first paint is a half-resolution draft, sharpened a moment later.
- Mode taken oversetFrame() on a marquee or clock turns it static and dispatches a bubbling flipdot:mode event; the preview writes it back to the lab, so the Mode control stays true.
- Off screen or hiddenThe loop pauses and the wave's clock stops; a returning tab cannot launch a disc with a long frame.
- Reduced motionThe message on the first paint, every change an instant swap, no frames requested; a marquee becomes pages of whole words.
How it works
Made of: Latching disc physics, Scheduled wave, Banded line waves, Per line and column layout, Ray cast sprite atlas, Baked motion blur, Progressive sliced baking, Glass reflection layer, Lamp lit mount, Dirty cell redraw, Bitmap type, Sleeping loop, Synthesised clatter.
Original. Taken from the physical flip-disc sign, not from a catalogue reference, so references is honestly empty. Both bitmap faces were drawn for this piece; Canvas 2D only, every surface (discs, housing, glass, mount) shaded per pixel from one lamp, so no image or font ships. Presets: Now boarding, Platform 2, Night bus, Station clock, Write on it.
Blocks built with it
- 03.1Departures BoardA departures board of flip-dot lines under an enamel fascia.
- 03.2ScoreboardA match centre round a flip-dot scoreboard.
- 03.3Venue MarqueeA club’s site on the night, under a brass flip-dot marquee.
- 06.4Specimen CaseA bento of glass-topped compartments in a machined case, each holding one real Tactile object running small (the Odometer, the Flip-Dot, the Detent Dial, the Vessel) with an engraved label card under the glass.