Building Text Containers in Canvas
summary
Shows how text and shape stay as separate elements but link via containerId/boundTextId, uses hitbox testing to pick targets, and renders typing with an off-DOM textarea then a custom word-wrap algorithm for Canvas because Canvas has no multiline support. Compares DOM sizing, hybrid and pure-canvas.measureText approaches, finds canvas measurement plus caching and per-character caching gives 85–95% faster runs, and explains binary-search breakpoints and why pure canvas lets rendering work in Node and in Excalidraw.
AI-written summary · about
chapters (17)
- 0:00Introduction and event context
- 1:06Speaker introduction and Excal Draw
- 3:17What is a text container
- 4:23Requirements for text containers
- 6:09JSON structure for canvas elements
- 7:13UI for attaching text to containers
- 10:28Hitbox testing for container selection
- 14:50Linking text and container elements
- 16:12Replicating actions to text elements
- 19:27Keeping text inside container bounds
- 21:36Canvas text wrapping challenges
- 24:50Measuring text dimensions in canvas
- 27:15DOM measurement approach
- 28:40Hybrid measurement approach
- 31:51Pure canvas measurement approach
- 34:18Performance optimizations
- 36:45Key takeaways and conclusion
