ludus-scripts/koch.ld

31 lines
612 B
Plaintext
Raw Normal View History

2024-06-14 17:52:54 +00:00
& Example Ludus implementation of the Dragon curve.
& https://en.m.wikipedia.org/wiki/L-system#Example_4:_Koch_curve
& A variant of the Koch curve which uses only right angles.
& variables : F
& constants : +
& start : F
& rules : (F -> F+FFF+F)
& Here, F means "draw forward", + means "turn left 90°", and means "turn right 90°"
2024-06-11 21:37:04 +00:00
let length = 10
let angle = 0.25
2024-06-11 21:37:04 +00:00
fn koch! {
(0) -> fd! (length)
(n) -> {
koch! (dec (n))
lt! (angle)
2024-06-11 21:37:04 +00:00
koch! (dec (n))
rt! (angle)
2024-06-11 21:37:04 +00:00
koch! (dec (n))
rt! (angle)
2024-06-11 21:37:04 +00:00
koch! (dec (n))
lt! (angle)
2024-06-11 21:37:04 +00:00
koch! (dec (n))
}
}
& koch! (3)