Skip to content

Every little fish swimming around is a visitor on this page right now, and one of them is you ( ´ ▽ ` )ノ If they get in the way of reading, feel free to turn them off.

Rube Goldberg Clock

util

A clock built the hard way.

The same idea as the Rube Goldberg Form.

NameDescription
SVGGraphics format usable in the DOM, great for complex shapes and animation; combined with Vue v-bind it enables data-driven effects
SVG MaskSVG masking that controls which areas of an element are visible, enabling complex shape cutting and masking
JS AnimationJavaScript-driven animation for more complex, precise control; popular libraries include GSAP and anime.js
Physics SimulationSimulates real-world physics such as gravity, collisions, and velocity
CSS AnimationImplemented with CSS transition and animation
<template>
<div class="w-full flex justify-center p-6">
<util-rube-goldberg-clock />
</div>
</template>
<script setup lang="ts">
import UtilRubeGoldbergClock from '../util-rube-goldberg-clock.vue'
</script>

The pan is the clock weight. Once the ball lands in it, the seconds pendulum holds the escape wheel and lets the pan sink one notch per second; the last notch drops exactly on the minute and presses the trip lever that releases every cocked rod.

The lap has eight switches, and each one takes the other branch every minute. The front branch keeps going the same way round, while the back branch mostly runs backwards or goes up and down.

Every part's position is computed only from how many milliseconds of the current minute have passed, so nothing drifts, even after the tab has been in the background.

interface Props {
/** 主色,用在球與「現在」。@default 'light-dark(#f43f5e, #fb7185)' */
color?: string;
/** 時間倍率,預覽用。2 表示快一倍。@default 1 */
timeScale?: number;
/** 起始時間,格式 'HH:MM:SS',預覽用;不給就用現在 */
startAt?: string;
}
const emit = defineEmits<{
/** 整分時彈簧桿換好數字,time 是剛開始的那一分鐘 */
arrive: [time: Date];
}>()