Turning orb
A picture wrapped onto a large shaded sphere on canvas, starting as a black disc, with a statement and a 'currently' note in the bottom corners.
Part of the style
Bulging Orb Index
6 parts that belong together, with their tokens, type and rules.
https://kitbash.me/components/bulging-orb-index/orb/figma.html?palette=3e7bb8a906fdc182
Use the Figma MCP server (https://mcp.figma.com/mcp). Download https://kitbash.me/components/bulging-orb-index/orb/figma.html?palette=3e7bb8a906fdc182 and pass that whole HTML document to the html_to_figma tool, so the part "Turning orb" lands as editable layers in my open Figma file. Fonts come from Google Fonts: if a face is missing in Figma, pick the closest one.
Code
<style>
/* Goes after the pack's base.css */
:root {
--ink: #fff2ea;
--paper: #0a0806;
--ink-soft: #665e56;
--tile-grey: #2b2722;
--tile-dark: #ac9d93;
--pop: #7c6352;
--pop-soft: #6d645e;
--tile-sky: #7c6352;
}
</style>
<section class="orb">
<div class="orb__stage">
<canvas class="orb__canvas" data-picture="assets/orb-tulips.jpg" role="img" aria-label="A field of tulips wrapped onto a slowly turning sphere"></canvas>
</div>
<p class="orb__statement"><strong>Puddle & Pip</strong> is a small studio for brands that wobble, packaging that talks back and characters with opinions.</p>
<p class="orb__now"><strong>Currently creating:</strong><br>A soda that fizzes in three kinds of weather</p>
</section>
<style>
.orb {
position: relative;
padding: 64px var(--edge) 84px;
}
.orb__stage {
width: min(100%, calc(39vw + 186px), 640px);
aspect-ratio: 1;
margin: 0 auto;
}
.orb__canvas {
width: 100%;
height: 100%;
border-radius: var(--radius-round);
}
.orb__statement,
.orb__now {
position: absolute;
bottom: var(--edge);
margin: 0;
max-width: 17rem;
font-size: var(--text-m);
line-height: 1.15;
}
.orb__statement {
left: var(--edge);
}
.orb__now {
right: var(--edge);
text-align: right;
}
@media (max-width: 40rem) {
.orb {
display: grid;
gap: var(--space-m);
padding-bottom: var(--edge);
}
.orb__statement,
.orb__now {
position: static;
max-width: none;
font-size: var(--text-l);
}
.orb__now {
text-align: left;
}
}
</style>
<script>
(() => {
const still = matchMedia('(prefers-reduced-motion: reduce)');
const N = 360; /* the sphere is computed at this size, then scaled to the canvas */
const TW = 512;
const TH = 256;
function run(canvas) {
const context = canvas.getContext('2d');
const buffer = document.createElement('canvas');
buffer.width = N;
buffer.height = N;
const bctx = buffer.getContext('2d');
const out = bctx.createImageData(N, N);
let texture = null;
let fallback = null;
let frame = 0;
let start = performance.now();
const turn = parseFloat(getComputedStyle(canvas).getPropertyValue('--orb-turn')) || 26;
const tilt = 0.38;
const ct = Math.cos(tilt);
const st = Math.sin(tilt);
const picture = new Image();
picture.onload = () => {
const t = document.createElement('canvas');
t.width = TW;
t.height = TH;
const tctx = t.getContext('2d');
tctx.drawImage(picture, 0, 0, TW, TH);
try {
texture = tctx.getImageData(0, 0, TW, TH).data;
} catch (error) {
fallback = picture;
}
start = performance.now();
draw(start);
};
picture.src = canvas.dataset.picture;
function sphere(seconds, mix) {
const data = out.data;
const spin = seconds / turn;
for (let j = 0; j < N; j++) {
const y = (2 * j + 1) / N - 1;
for (let i = 0; i < N; i++) {
const x = (2 * i + 1) / N - 1;
const r2 = x * x + y * y;
const o = (j * N + i) * 4;
if (r2 > 1) { data[o + 3] = 0; continue; }
const z = Math.sqrt(1 - r2);
const yy = y * ct - z * st;
const zz = y * st + z * ct;
let u = Math.atan2(x, zz) / (2 * Math.PI) + 0.5 + spin;
u -= Math.floor(u);
u = u < 0.5 ? u * 2 : 2 - u * 2; /* mirrored, so the seam never shows */
const v = Math.asin(Math.max(-1, Math.min(1, yy))) / Math.PI + 0.5;
const tx = Math.min(TW - 1, (u * TW) | 0);
const ty = Math.min(TH - 1, (v * TH) | 0);
const t = (ty * TW + tx) * 4;
const light = 0.38 + 0.62 * z;
const hx = x + 0.38;
const hy = y + 0.42;
const spec = Math.max(0, 1 - Math.sqrt(hx * hx + hy * hy) / 0.32);
const shine = spec * spec * 200;
data[o] = Math.min(255, texture[t] * light * mix + shine * mix);
data[o + 1] = Math.min(255, texture[t + 1] * light * mix + shine * mix);
data[o + 2] = Math.min(255, texture[t + 2] * light * mix + shine * mix);
data[o + 3] = 255;
}
}
bctx.putImageData(out, 0, 0);
}
function draw(now) {
const w = canvas.clientWidth;
const h = canvas.clientHeight;
context.clearRect(0, 0, w, h);
const elapsed = now - start;
const mix = still.matches ? 1 : Math.max(0, Math.min(1, (elapsed - 500) / 700));
if (texture) {
sphere(still.matches ? 0 : elapsed / 1000, mix);
context.imageSmoothingQuality = 'high';
context.drawImage(buffer, 0, 0, w, h);
} else {
context.save();
context.beginPath();
context.arc(w / 2, h / 2, Math.min(w, h) / 2, 0, Math.PI * 2);
context.fillStyle = getComputedStyle(canvas).getPropertyValue('--ink').trim() || '#000';
context.fill();
if (fallback) {
context.clip();
context.globalAlpha = mix;
context.drawImage(fallback, 0, 0, w, h);
}
context.restore();
}
}
const fit = () => {
const density = Math.min(2, devicePixelRatio || 1);
canvas.width = canvas.clientWidth * density;
canvas.height = canvas.clientHeight * density;
context.setTransform(density, 0, 0, density, 0, 0);
draw(performance.now());
};
const tick = (now) => {
draw(now);
frame = requestAnimationFrame(tick);
};
new ResizeObserver(fit).observe(canvas);
new IntersectionObserver(([entry]) => {
cancelAnimationFrame(frame);
if (entry.isIntersecting && !still.matches) frame = requestAnimationFrame(tick);
}).observe(canvas);
}
document.querySelectorAll('.orb__canvas').forEach(run);
})();
</script>