#import "@preview/cetz:0.4.2" // Compile with: // typst compile --package-path "../../../lib/typst/" svg.typ --format svg // You'll need to recompile typst with a higher recursion limit. #set page( fill: none, width: auto, height: auto, margin: 0mm, ); #let cetz_snake(depth, b, t) = { import cetz.draw: * if depth == 0 { content((0, 0), math.inline(math.integral)) group({ translate(x: 0.15, y: -0.15) b }) group({ translate(x: 0.15, y: 0.15) t }) } else { let bot = group({ translate(x: 0.15, y: -0.15) cetz_snake(depth - 1, b, content((0, 0), text("1", size: 3mm))) }) let top = group({ translate(x: 0.15, y: 0.15) cetz_snake(depth - 1, content((0, 0), text("0", size: 3mm)), t) }) cetz_snake(depth - 1, bot, top) } } #{ import cetz.draw: * // any bigger than 7 overflows the stack. // any bigger than 5 exceeds typst's recursion limit. // You'll have to increase those limits and recompile to // build this document. let depth = 7 let b = content((0, 0), text("0", size: 3mm)) let t = content((0, 0), text("1", size: 3mm)) cetz.canvas(cetz_snake(depth, b, t)) };