Rotozoom video
A video frame repeats as an SVG pattern that spins, drifts and zooms, in the style of a 1990s demoscene rotozoomer.
What you are seeing
The whole window is filled with repeating square tiles of the Big Buck Bunny trailer. The tiled surface turns, drifts and zooms in and out while the film plays, so characters repeat diagonally across the screen at changing sizes. A credit line runs across the top and play and stop buttons sit at the bottom.
How it works
A hidden video is drawn to a small canvas, cropped to a square.
Each frame becomes the image inside one SVG pattern tile, and one rectangle fills the window with that pattern.
A single patternTransform rotates, scales and moves all of the tiles at once.
The motion is computed from the video's current time, so pausing the video holds the pattern.
History
Published on March 28, 2011. It used archive footage and a tracker music file from the 1993 demo, and its script drew on an earlier experiment shared by permission. None of those are reused here.
Source
/videopatterns/videopattern.html
<!DOCTYPE html>
<html lang="en">
<head>
<title>SVG video rotozoom</title>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<meta name="description" content="A video frame used as a repeating SVG pattern, spun and zoomed with patternTransform in the style of a 1990s demoscene rotozoomer."/>
<!--
Rebuilt in 2026 from the idea of the 2011 demo by Erik Dahlström. This
script is new code. The 2011 version credited an earlier experiment used
by permission, so that code is not reused here.
This file is released under CC0.
-->
<style>
* { box-sizing: border-box; }
html, body { height: 100%; }
body { background-color: #000; color: #c9c9ff; margin: 0; overflow: hidden; font: 13px/1.4 ui-monospace, Menlo, Consolas, monospace; }
a { color: #c9c9ff; }
#container, #container svg { position: absolute; inset: 0; display: block; width: 100%; height: 100%; }
#info { position: absolute; top: 0; left: 0; right: 0; padding: 6px 10px; text-align: center; background: rgba(0, 0, 0, .62); }
#media { position: absolute; width: 1px; height: 1px; overflow: hidden; opacity: 0; pointer-events: none; }
#bar { position: absolute; left: 0; right: 0; bottom: 0; display: flex; gap: 10px; align-items: center; padding: 8px 12px; background: rgba(0, 0, 0, .72); }
button { font: inherit; color: #fff; background: #2d2d66; border: 1px solid #8c8cf0; border-radius: 5px; padding: 7px 14px; cursor: pointer; }
button:focus-visible { outline: 3px solid #ffd24a; outline-offset: 1px; }
#time { margin-left: auto; white-space: nowrap; }
@media (max-width: 520px) { #info { font-size: 11px; } #time { display: none; } }
</style>
</head>
<body>
<div id="container"></div>
<div id="info">Rotozoom: a video as a spinning SVG pattern. Big Buck Bunny, (c) 2008 Blender Foundation, <a href="https://creativecommons.org/licenses/by/3.0/" target="_blank" rel="noopener">CC BY 3.0</a>, <a href="https://peach.blender.org/" target="_blank" rel="noopener">peach.blender.org</a></div>
<div id="bar">
<button id="toggle" type="button">Play with sound</button>
<button id="stop" type="button">Stop</button>
<span id="time" aria-live="off">0:00</span>
</div>
<div id="media">
<video id="video" width="480" height="320" preload="auto" playsinline="playsinline" aria-hidden="true">
<source src="../res/2.0/videos/bigbuckbunny_trailer_480p.webm" type="video/webm"/>
<source src="../res/2.0/videos/bigbuckbunny_trailer_480p.mp4" type="video/mp4"/>
</video>
<canvas id="canvas" width="256" height="256"></canvas>
</div>
<script>
(function () {
var SVGNS = 'http://www.w3.org/2000/svg';
var TILE = 270;
var container = document.getElementById('container');
var video = document.getElementById('video');
var canvas = document.getElementById('canvas');
var toggleButton = document.getElementById('toggle');
var stopButton = document.getElementById('stop');
var timeLabel = document.getElementById('time');
var ctx = canvas.getContext('2d');
var calm = window.matchMedia && window.matchMedia('(prefers-reduced-motion: reduce)').matches;
function make(name, attrs, parent) {
var el = document.createElementNS(SVGNS, name);
Object.keys(attrs).forEach(function (k) { el.setAttribute(k, attrs[k]); });
if (parent) { parent.appendChild(el); }
return el;
}
var svg = make('svg', { role: 'img', 'aria-label': 'A tiled frame of the Big Buck Bunny trailer that turns and zooms' }, container);
make('title', {}, svg).textContent = 'Video rotozoom';
make('desc', {}, svg).textContent = 'One video frame is repeated as a pattern across the window. The whole pattern rotates, drifts and zooms in and out while the trailer plays.';
var defs = make('defs', {}, svg);
var texturePattern = make('pattern', { id: 'texture', patternUnits: 'userSpaceOnUse', width: TILE, height: TILE }, defs);
var textureImage = make('image', { id: 'textureImage', width: TILE, height: TILE, preserveAspectRatio: 'none', href: 'bbb-texture.jpg' }, texturePattern);
make('rect', { width: '100%', height: '100%', fill: 'url(#texture)' }, svg);
var lastFrameTime = -1;
var running = false;
// Copies the centre square of the current frame into the pattern tile.
// It is decoded off screen first, because Firefox never shows an SVG
// image whose source is replaced again before it has finished loading.
var loader = new Image();
var decoding = false;
loader.onload = function () {
if (running) { textureImage.setAttribute('href', loader.src); }
decoding = false;
};
loader.onerror = function () { decoding = false; };
function copyFrame() {
if (decoding || video.readyState < 2 || video.currentTime === lastFrameTime || !video.videoWidth) { return; }
lastFrameTime = video.currentTime;
var side = Math.min(video.videoWidth, video.videoHeight);
ctx.drawImage(video, (video.videoWidth - side) / 2, (video.videoHeight - side) / 2, side, side, 0, 0, 256, 256);
decoding = true;
loader.src = canvas.toDataURL('image/jpeg', 0.72);
}
// Motion comes from the media clock, so pausing the video holds it.
function place(seconds) {
var w = window.innerWidth, h = window.innerHeight;
var pace = calm ? 0.2 : 1;
var t = seconds * pace;
var zoom = 1.45 + 1.05 * Math.sin(t * 0.61 + 0.7);
var turn = 38 * t + 24 * Math.sin(t * 0.27);
var x = w / 2 + 190 * Math.cos(t * 0.43);
var y = h / 2 + 150 * Math.sin(t * 0.37);
texturePattern.setAttribute('patternTransform',
'translate(' + x.toFixed(2) + ' ' + y.toFixed(2) + ') rotate(' + turn.toFixed(2) + ') scale(' + zoom.toFixed(3) + ')');
}
function clock(s) {
var whole = Math.floor(s);
return Math.floor(whole / 60) + ':' + ('0' + (whole % 60)).slice(-2);
}
function frame() {
if (!running) { return; }
copyFrame();
place(video.currentTime);
timeLabel.textContent = clock(video.currentTime);
requestAnimationFrame(frame);
}
function start() {
var result = video.play();
if (result && result.catch) { result.catch(function () {}); }
}
function toggle() {
if (video.paused || video.ended) { start(); } else { video.pause(); }
}
function stop() {
video.pause();
video.currentTime = 0;
lastFrameTime = -1;
textureImage.setAttribute('href', 'bbb-texture.jpg');
place(0);
timeLabel.textContent = clock(0);
toggleButton.textContent = 'Play with sound';
}
video.addEventListener('play', function () {
toggleButton.textContent = 'Pause';
if (!running) {
running = true;
requestAnimationFrame(frame);
}
});
video.addEventListener('pause', function () {
running = false;
if (!video.ended && video.currentTime > 0) { toggleButton.textContent = 'Resume'; }
});
video.addEventListener('ended', function () {
running = false;
toggleButton.textContent = 'Play again';
});
toggleButton.addEventListener('click', toggle);
stopButton.addEventListener('click', stop);
document.getElementById('container').addEventListener('click', toggle);
document.addEventListener('keydown', function (e) {
if (e.key === ' ' && e.target.tagName !== 'BUTTON') {
e.preventDefault();
toggle();
} else if ((e.key === 's' || e.key === 'S') && !e.ctrlKey && !e.metaKey) {
stop();
}
});
window.addEventListener('resize', function () { place(video.currentTime); });
place(0);
})();
</script>
</body>
</html>