Lindenmayer systems
vsekar.me
vsekar.me
Dwitter is a cool social network where JavaScript programmers can share demos, fractals, art algorithms and interactive code viewed on <canvas>.
dwitter looks pretty cool. like twitter if it was designed for creativity and beauty instead of trolling
i did a golfed emoji ifs the other day in python but it's 288 characters, not 140 or even 280: http://canonical.org/~kragen/sw/dev3/hilbert.py
i feel like the three levels of representation needed to draw l-systems on a raster display (strings, turtle commands, and cartesian coordinates) sort of disfavor golfing. i managed to get an ascii-art ifs down to 259 strokes by using complex numbers instead of vectors: http://canonical.org/~kragen/sw/dev3/cifs.py
Lindenmayer Systems - https://news.ycombinator.com/item?id=38024405 - Oct 2023 (34 comments)
Evolving Lindenmayer Systems - https://news.ycombinator.com/item?id=20588039 - Aug 2019 (15 comments)
Lindenmayer systems - https://news.ycombinator.com/item?id=16002532 - Dec 2017 (9 comments)
Four L-system fractals in LaTeX - https://news.ycombinator.com/item?id=9716780 - June 2015 (5 comments)
If I don't dive into functions etc I got far enough with a loop iterating on ops, but it was getting tedious adding more functionality while following abop. Might sit and give another try, some day.
{
a: '-bff+affa+ffb-',
b: '+aff-bffb-ffa+',
c: ['a', {p: .1}, 'b', {p: .9}],
}if you aren't pleasantly surprised, maybe try a different parser generator
i'd love to see your examples!
this is barnsley's fern https://en.wikipedia.org/wiki/Iterated_function_system#Const...
you can clearly generate barnsley's fern with an l-system but i've never seen it done
otherwise this seems like a nice explanation of l-systems
— ⁂ —
i'm a bit dubious about the implementation strategy because even though i'm not a rustacean this looks like accidentally quadratic code to me
sequence.remove(insert_index);
sequence.insert_str(insert_index, rule);
https://web.mit.edu/rust-lang_v1.25/arch/amd64_ubuntu1404/sh... says:> Inserts a string slice into this String at a byte position. This is an O(n) operation as it requires copying every element in the buffer.
you can probably draw an l-system graphic of more than a million drawing commands on your screen, let alone a laser cutter or something (in http://canonical.org/~kragen/sw/laserboot/cut-6/ for example i laser-cut a sierpiński triangle with an l-system implemented in postscript) so the problem size starts to get into the range where being accidentally quadratic matters
if i'm not just mistaken, which is possible since i haven't tested it, but i thought it was a likely enough problem to be worth mentioning
— ⁂ —
also where the article says
> The function above can also be written recursively but for larger iterations, you would run out of stack depth way before running out of heap memory.
it is exactly backwards, at least with the straightforward recursive approach; 40 generations would require 40 stack frames occupying perhaps 4096 or 8192 bytes of stack, but for the non-barnsley non-fern given as the first example, produces something more than 18 × 3⁴⁰ = 218837978263024718418 bytes of output, which is sufficiently larger than 8192 that the heap runs out first
(you can of course maintain an explicit stack and write an iterative loop)
— ⁂ —
i hope these corrections and other comments are helpful and not discouraging. keep creating beauty! keep hacking!
> This program implements some of the L-Systems discussed in "Lecture Notes in Biomathematics" by Przemyslaw Prusinkiewcz and James Hanan
he merely introduces it as 'example' with no notes on its provenance
i haven't seen the lecture notes, and i don't remember if this l-system is in abop, which is from the year before (and cited on bourke's page)