Skip to content

Commit b75afa2

Browse files
mimecuvaloclaude
andauthored
docs(examples): add xkcd 2347 dependency physics example (tldraw#8362)
Adds an interactive recreation of the [xkcd "Dependency" comic (tldraw#2347)](https://xkcd.com/2347/) as a tldraw SDK example, inspired by [isohedral's p5.js version](https://editor.p5js.org/isohedral/full/vJa5RiZWs). The example builds a tower of geo shapes matching the comic's layout and simulates physics using Rapier 2D — blocks settle under gravity, and you can drag or delete blocks to watch the tower collapse. https://github.com/user-attachments/assets/4a32706c-8f72-4e9e-9eb6-b07cf0cdc052 ### Change type - [x] `other` ### Test plan 1. Run `yarn dev` and navigate to the "Gravity sim (xkcd 2347)" example under use-cases 2. Wait for blocks to settle after the initial physics warm-up 3. Drag a block out of the tower and watch surrounding blocks react 4. Delete a block and confirm the tower collapses realistically 5. Pull out the red "critical dependency" block and watch everything fall ### Release notes - Add xkcd 2347 "Dependency" physics example demonstrating Rapier 2D integration with tldraw shapes ### Code changes | Section | LOC change | | --------------- | ---------- | | Documentation | +406 / -0 | | Config/tooling | +9 / -0 | Made with [Cursor](https://cursor.com) --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent b95d5c7 commit b75afa2

4 files changed

Lines changed: 415 additions & 0 deletions

File tree

apps/examples/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
"test-coverage": "yarn run -T vitest run --coverage --passWithNoTests"
4141
},
4242
"dependencies": {
43+
"@dimforge/rapier2d-compat": "^0.19.3",
4344
"@playwright/test": "^1.58.2",
4445
"@tiptap/core": "^3.12.1",
4546
"@tiptap/extension-font-family": "^3.12.1",
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
title: Gravity sim (xkcd 2347)
3+
component: ./XkcdDependencyExample.tsx
4+
keywords: [physics, gravity, animation, fun, xkcd, rapier]
5+
priority: 10
6+
---
7+
8+
A recreation of the xkcd "Dependency" comic (#2347) using tldraw shapes and Rapier 2D physics.
9+
10+
---
11+
12+
The tower of blocks is held up by gravity from the start. Try pulling out a block and watch everything collapse — just like in the [original comic](https://xkcd.com/2347/).

0 commit comments

Comments
 (0)