Page structure drawn in depth

Six ideas from the element catalogue, built. Each canvas draws structural elements (<section>, <nav>, <hr>, <header>, <details>, <aside>) in a position the page layout doesn't have: on the faces of a cube, along a curve, at different depths, folded, pulled out towards the reader, and hanging from a string. The elements stay in the document, and the buttons, links and checkboxes inside them are pressed where they are drawn. Drag the cube and the ribbon sideways, and scroll inside the two framed pages.

Sections on a cube

Four <section> elements, one on each side face. Drag a face sideways, press a link in the <nav> under the cube, or press Tab through the controls: focus that moves into a hidden section turns it to the front.

Overview

This face is a section with a heading. The button is a real button, drawn here.

Plan

Sizes

Shelf depth

350 px

Contact

The API is described in the tutorial.

While the cube rests, the front face is one flat draw. While it turns, the two visible faces are drawn in 26 vertical strips each, and the face that is most towards the reader takes input at its flat place.

Show the code
  1. A <nav> and four drawable sections.
  2. Draw the visible faces in strips while the cube turns, and flat when it rests.
  3. The strips.
  4. Turn on a link, on focus and on a drag.
  5. Styles.

Navigation on a ribbon

A <nav> with eight links to pages of this site, drawn along a moving curve. Drag sideways to pull the ribbon through. Tap a link to follow it, or long-press it for the browser's link menu.

Each link is drawn in strips 4 px wide, and each strip is turned to the angle of the curve at its place. The link's hit region is its whole box, turned to the angle at its middle.

Show the code
  1. Each link is drawable. The <nav> isn't drawn.
  2. Measure the curve, draw the band, then each link in strips.
  3. A drag pulls the ribbon. A tap is left to the link.
  4. Styles.

Slices between hr elements

One <article> with three <hr> elements. The paint handler reads where each <hr> is, cuts the article's picture there, and draws the four slices at different depths. Drag sideways to look from another side.

Release notes

Version 4 draws its sidebar in a canvas. The four parts of this article are divided by three rules.


The first rule ends here. This button is in the second slice.


The third slice holds a link to the accordion page and a checkbox.


The last slice. Nothing in the markup says which slice is near and which is far.

The article is one element and has one hit region, and the four slices are drawn with four transforms. On each pointerdown, before the browser picks the element for the tap, the page moves the region to the slice under the pointer.

Show the code
  1. One drawable article.
  2. Cut at each <hr> and draw the slices, far ones first.
  3. Move the hit region to the slice under the pointer.
  4. A draw with no alpha, outside a paint event.
  5. Styles.

Drawer cabinet from details

Four <details> elements with one name. Each <summary> is a drawer front. Tap one: the drawer comes out towards you and its content is the inside of the drawer. The controls inside work.

Receipts
Cables

USB-C cables kept

A range input, drawn squashed.

Keys

Shed, bike lock, spare front door.

Labels

Typed text is submitted with the form.

The open drawer is one element drawn in two parts: its body as ten rows that get wider towards the reader, and its summary under the body, larger. A closing drawer's body is drawn from a snapshot taken while it was open.

Show the code
  1. Four <details name> elements in a form.
  2. Draw the fronts, then the drawer that is out.
  3. Move the hit region to the part under the pointer.
  4. Styles.

Aside as a margin note on a string

Scroll inside the frame. Each <aside> hangs from a pin beside the paragraph it follows in the markup. A change in scroll speed swings it and stretches its string. Press a note to push it.

A canal lock raises a boat by filling a chamber with water from the higher side. Nothing is pumped.

The gates meet at an angle that points upstream, so the weight of the water holds them shut.

A paddle in each gate lets water through. The crew winds it open with a handle called a windlass.

When the levels are equal the gate opens with a push on its long beam.

A flight is a run of locks close together. The longest in Britain has 30.

Going down, the order is reversed: the chamber is emptied into the lower side.

Each use of a lock moves one chamber of water downhill, so summits need reservoirs.

This is the last paragraph.

The aside is drawn turned about its pin with one drawElementImage() call under a rotation, so its hit region turns with it and the checkbox can be pressed while it swings.

Show the code
  1. Paragraphs and asides, each drawable, in a scroller.
  2. Draw the paragraphs in view, then each aside on its string. The scroll pushes them.
  3. Styles.

How it works

Each canvas holds the real elements as descendants marked drawable. A paint handler draws them with drawElementImage() under a transform, or in clipped pieces under several transforms. The call also moves the element's hit region to where it was drawn. Four techniques are used more than once:

Show the code
  1. The paint loop shared by the six demos.
  2. Move a hit region without drawing.
  3. Run before the tap is handled.
  4. Each demo starts when its section comes near the screen.
  5. A lost context stops every demo.
  6. The elements are then shown as plain HTML.
  7. Styles for the plain HTML.

Live checks

The checks wait for a tap. Each one builds its own small canvas in a corner of the window, and none of them touches the demos above.

Findings

Measured in headless Chromium 157 on 2026-11-21, at 412 px wide with emulated touch, and at 1000 px wide with a mouse and a keyboard.