Improvements for the L-system extension

Discussion about writing code for Inkscape.
Ailurus
Posts: 115
Joined: Fri Oct 22, 2010 9:53 am
Location: The Netherlands
Contact:

Improvements for the L-system extension

Postby Ailurus » Sun Jul 29, 2012 7:45 am

Hi,

I added some options to the L-system extension (and changed some other settings). The same things can be done as before, but also a lot more. Main additions:

  • Scale the lines (length) with every iteration. I chose to use the same syntax as Fractint uses (or so I read). The "@" symbol indicates a scaling change. You can either type a number (e.g. "@4" to make the lines 4 times longer each step), the inverse of a number (e.g. "@I3", resulting in a scaling factor of 1/3 -- very useful for the Koch Snowflake fractal), the square root of a number (e.g. "@Q5") or the inverse of a square root (e.g. "@IQ2"). This last one is used in the Pythagoras Tree fractal.
  • Next, I added a "Colors" field. In this field you can insert the hexadecimal (e.g. "#FF8800") color codes, separated by ";" (like the separation of the Rules). With the "#" symbol in the Axiom or Rules field, you can indicate that the color should change. Moreover, you can also choose to use a semi-random color. It works as follows: "R(#770000,20)". This will result in a shade of red, with a maximum difference of 20% in lightness/darkness with respect to the chosen color, "#770000".
  • Besides a field for the line width, there is also a symbol to change the line width every iteration (it just decreases by 1 for now). This symbol is "&".

Some examples:




To really show the steps, I made a short video -- but since this is actually my first "video tutorial", it's not quite optimal... But I can always redo it, right :D. Link: YouTube

The only drawback (in my opinion) is that this extension becomes even more difficult to understand -- but with some examples and a better tutorial, it shouldn't be that hard to get everything out of it!

User avatar
brynn
Posts: 10309
Joined: Wed Sep 26, 2007 4:34 pm
Location: western USA
Contact:

Re: Improvements for the L-system extension

Postby brynn » Sun Jul 29, 2012 8:49 am

That looks great!
You know what I think would make the L-System extension more fun for Inkscape users who don't really understand the L-System? Currently, all I can do is try random letters and + or - in the Rules field, until something is drawn. The info on the Help tab is really very sketchy. I've found a couple of resources which give some examples of Rules--I think from a wiki or something. (I have it saved, but don't remember at the moment, where it came from). If those could be included -- like how fonts are displayed, it says the name of the font, and then some letters showing how the font looks. If there could be a few known or common examples, with an example of what it looks like, I think it would be a lot more fun. Well, even just to have some Rules that are known to draw something, lol, even without knowing what they look like ahead of time, would be nice.

I did set out, a while ago, to make some examples, that I would share in a tutorial. I spent several hours, and came up with only 2 or 3 equations. So any tutorial from me will probably be a long time coming, lol. But anyway, if this new extension (or improvements to the old one) will include examples, that would be great!

Ailurus
Posts: 115
Joined: Fri Oct 22, 2010 9:53 am
Location: The Netherlands
Contact:

Re: Improvements for the L-system extension

Postby Ailurus » Tue Jul 31, 2012 7:05 am

Hi Brynn, thanks for your feedback!

brynn wrote:If there could be a few known or common examples, with an example of what it looks like, I think it would be a lot more fun.

About two years ago we briefly discussed this as well :D, recently I created this topic to probe whether other users would like this idea.

brynn wrote:I did set out, a while ago, to make some examples, that I would share in a tutorial.

In about three weeks I'll finally have some more time again, so then I'll make a L-system tutorial for Inkscape (the pictures are there already, but compiling it into a nice document takes some time).

jazzynico
Posts: 3
Joined: Sun Jul 10, 2011 5:11 pm

Re: Improvements for the L-system extension

Postby jazzynico » Tue Jul 31, 2012 11:07 pm

Hi Ailurus,

It looks very interesting indeed.
Would you be willing to share your extension files so that we could test it and discuss the possibility to include it in the next Inkscape version?

User avatar
brynn
Posts: 10309
Joined: Wed Sep 26, 2007 4:34 pm
Location: western USA
Contact:

Re: Improvements for the L-system extension

Postby brynn » Wed Aug 01, 2012 8:49 am

Image Congrats, Ailurus! I hope we see this in a stable version someday.

Ailurus
Posts: 115
Joined: Fri Oct 22, 2010 9:53 am
Location: The Netherlands
Contact:

Re: Improvements for the L-system extension

Postby Ailurus » Wed Aug 01, 2012 9:17 am

jazzynico wrote:Would you be willing to share your extension files so that we could test it and discuss the possibility to include it in the next Inkscape version?

Of course, but please note:

  • I'm not quite familiar with (open source) licenses, so I don't know whether I should add anything in the headers of the two files (.py and .inx)
  • Some changes are still rather "static" at the moment. For instance, currently it is only possible to scale with an integer between 1 and 9 (so no float or anything above 9). But of course you can use the operators (also rather static for now).
  • I started adding comments in Dutch, just for myself to keep track of the changes. I think I changed them all to English now, but if you happen to stumble upon something unreadable :lol:, be sure to mention this.

For more info and TODOs, see the comments in the .py file.

Any questions? Please don't hesitate to ask. I really hope that more people will use the L-system extension, with a little imagination and creative thinking, amazing art can be made! :D

Hmm, it's apparently not possible to include .py and .inx files as attachments. I could put them on my own web space, but then I'd like to be sure about possible license issues :).

Edit: I created a ZIP archive of the folder containing the two files. Please make sure that you first backup the old files before replacing them with these two!
Attachments
LindenmayerExtension.zip
(5.78 KiB) Downloaded 401 times


Return to “Programming”