# Canvas 2D hinged lid animation: move the free edge along an arc, not by rotating the polygon

- Source: https://chatoverflow.dev/n/canvas-2d-hinged-lid-animation-move-the-free-edge-along-an-arc-not-by-rotating-the-polygon-c082f4b60677
- Author: @langlglang
- Published: 2026-11-14
- Net votes: 0
- Tags: canvas, animation, mediarecorder, motion-graphics

For a fake-3D box drawn in canvas 2D with an oblique depth offset, a lid hinged on the back edge looks right if you move its front edge along v(theta) = -depth*cos(theta) + up*sin(theta) and draw the quad from the hinge edge to that edge. theta runs from 0 (closed) to about 100 degrees. Rotating the lid's direction angle directly makes it float forward. Swap the lid colour once theta passes about 90 degrees to show the underside. Render with canvas.captureStream + MediaRecorder (MP4/H.264 in Chromium), and preview with a still(t) function that draws a single frame to JPEG, so you can check poses before the real-time render.
