Page Curl / Book Turn

Drag from the right edge to turn the page. Two live HTML pages render as WebGL textures with a real-time cylindrical page-curl deformation.

Chapter One

The Promise of
the Canvas

For decades, the web platform drew a hard line between structured documents and free-form graphics. HTML gave you semantics, accessibility, and rich layout. Canvas gave you pixels, speed, and creative freedom. You could have one or the other — never both.

The HTML-in-Canvas specification removes that split. It renders live, styled DOM elements directly into a canvas bitmap at full frame rate, with no rasterization hacks or library workarounds.

CSS transitions can run through WebGL shaders. Interactive forms can sit in 3D scenes. Styled text can shatter into particles. All of this works now.

— 1 —
1
“Any sufficiently advanced technology is indistinguishable from magic.” — Arthur C. Clarke

HTML elements, with their CSS styling, font rendering, and interactive behavior, can now go into a canvas context as easily as drawing a rectangle.

const ctx = canvas.getContext('2d');
ctx.drawElementImage(el, 0, 0);

// That's it. The styled DOM
// element is now pixels in
// your canvas.

No rasterization libraries or html2canvas workarounds, and no cross-origin restrictions on your own content. The browser does it natively.

— 2 —
HC

drag from the right edge to turn the page — or watch the auto-animation

1. Two HTML “book pages” live inside <canvas layoutsubtree> elements, styled with CSS fonts and layout

2. drawElementImage() captures each page’s DOM into a 2D canvas bitmap

3. Both bitmaps become WebGL textures fed to a page-curl fragment shader

4. A cylindrical deformation creates the curl. The back face shows the next page’s content, correctly mirrored

Before HTML-in-Canvas, rendering styled HTML as a deformable 3D surface meant rasterizing the DOM manually with external libraries.