ludus-scripts/koch.ld

31 lines
612 B
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

& 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°"
let length = 10
let angle = 0.25
fn koch! {
(0) -> fd! (length)
(n) -> {
koch! (dec (n))
lt! (angle)
koch! (dec (n))
rt! (angle)
koch! (dec (n))
rt! (angle)
koch! (dec (n))
lt! (angle)
koch! (dec (n))
}
}
& koch! (3)