ludus-scripts/koch_tri.ld

32 lines
458 B
Plaintext

& koch triangles!
let angle = inv (3)
let half = div (_, 2)
fn koch! {
(0, len) -> fd! (len)
(n, len) -> {
let newlen = div (len, 3)
let next = dec (n)
koch! (next, newlen)
left! (half (angle))
koch! (next, newlen)
right! (angle)
koch! (next, newlen)
left! (half (angle))
koch! (next, newlen)
}
}
& just give ourselves some runway
penup! ()
left! (0.25)
forward! (350)
right! (0.5)
pendown! ()
& make the triangles!
koch! (6, 800)