View Full Version : Another (very simple) forest maker

09-05-2010, 10:34 AM
Hi happy tree friends,

Had some boring time so I coded a little tool that does create random forests. It is called EcoForester (couldn‘t think of a more silly name). You can choose between different tree types (top down views, side view not implemented yet) and define some parameters for the random distribution. At start, the tool does create a random forest based on some default values. In the upper left you can access those values at a simple panel (sorry for the ugly design, just a quick hack). They are categorized into:

1. Threshold: the higher the number, the more trees you get. Default 12, lowest 4, maximum 25. This value defines a threshold against which a bitmap with perlin noise is tested. Therefore, the number does not directly correspond to the total number of trees.
2. Density: the higher the number, the larger the distance between single trees. Default 30, minimum 20, maximum 40.

1. Enables or disables the shadow. Enabled by default.
2. Color: sets the shadow color. Five different colors of grey, default a very dark grey (first color chip). The activated chip is slightly bigger than the other ones.
3. Angle: sets the rotation of the shadow. The arrow points to the direction of the shadow. To change it, click elsewhere on the grey circle (not: click and drag).
4. Distance: sets the distance (in pixels) of the shadow. Default 5, minimum 2, maximum 15.

1. Tree types to be used for your forest. Default: second from left. Click on a thumbnail to change the type. The activated type is marked by a red halo. If you want to use several types at the same time, just shift-click on another thumb. Again shift-click to deactivate that type. Every time you click on a type, a new forest is created.

1. Lock: locks the map for the random distribution of the trees. Disabled by default. If you want to use different trees with the same random distribution, you can lock the random positions by using this option.

Click to save a transparent png of your forest.

Distribution, Type: every change of a value does create a new forest.
Shadow: changing values does update the actual forest but not generate a new one.

At start the panel is shown at 90 % alpha. After that, it is blended out when rolling off the mouse and blended in when rolling over again. That way it is easier to look at the forest you get.

You need the Flash Player 10 to start the swf. The exe does work without any player, of course. Sorry, Windows only (though the swf should work on a Mac, too).

1. To get a random forest just start the tool: open the swf with your browser (Flash Player 10 needed) or double click on the exe.
2. Then click on the Logo “EcoForester” at the top right corner of the panel to save a transparent png at your local drive.
3. Now change the default type by clicking on the first tree thumb. The second one will be deactivated while the first one will be marked as active. At the same time, a new forest is calculated. The total number of trees depends on the treshold and density parameters (which you can change) as well as on a bitmap that is generated to get a random distribution (which you can‘t change). That map is not shown up. It is just used to get the positions for the trees. The appearance of every tree is randomized by using different sizes, different rotations and some extremely modest colorizing.
The upper left part of the forest is hidden by the panel.
4. Move the mouse outside of the panel. Now you can see the trees that were created behind the panel.
5. Our forest is not very dense. To change that, move the mouse again over the panel (upper left part of the screen) to show it up. Then click several times on the numerical stepper to the right of the Threshold option. You can also just put a number into the numerical field and press the ENTER key.
6. To get even more trees, lower the number in the Density field. That way the average distance between single trees is lowered which results in a higher total number of trees.
7. At present, the forest does consist of only one tree type which looks not very realistic. Hold the Shift key and click on the 6th and 9th thumb. Now 3 types are highlighted. After every click the forest is calculated anew using the different trees you did choose.
8. Unfortunately, the 6th tree type is much too dark. Deactivate it by shift-clicking it again. It will be unmarked. At the same time, a new forest is generated which does only consist of the two types left (1st and 9th type).
9. You want to add another type. But this time you don’t want to recalculate the positions of the trees. To keep the actual positions, click on the Lock option to lock the existing map.
10. Then shift-click on the 10th type to add another type to the forest.
11. Now save everything by clicking on the logo.

download: http://www.mediafire.com/?10ynyacvmktfx50

Two views of the tool with different parameters used:

28879 28880

Happy foresting!

09-05-2010, 11:34 AM
I can tell by your description you know more about programming than me and aren't having to fight to learn the basic commands for every new function you want to add. Hehe.

Looking forward to watching this progress. good stuff.

09-05-2010, 02:44 PM
I think one of the things that would make this incredibly useful is the ability to mask out areas where forest will not generate, or areas that you want it to generate. Random can be very useful at times, especially if you don't have specific plans, but often times someone might have precise areas marked out as "forest goes here".

that's one of the biggest selling points of the other forest generator we have going on.

09-05-2010, 03:05 PM
Hi happy tree friends,

*memories of gory videos watched in middle school ensue.* :P

based on the screenshots, Id say it looks very simple, which is a good thing :)

09-05-2010, 04:37 PM
looks like a good start - as coyote says - a way to "shape" your forest would be nice - especially if you could use a jpg, png, svg for the mask. And to set the size resolution would be nice too... oh and be able to add your own trees :) ... great work though - and thanks for sharing :)

09-09-2010, 01:53 AM
Seems pretty simple and has a nice output. Would like to be able to create my own tree shapes for it if possible.

I ran a sample test on this, the result is here. (http://www.cartographersguild.com/showthread.php?11846-Simple-forest-maker-battlemap-test&p=127365#post127365)

09-09-2010, 01:27 PM
Hi happy tree friends,

thanks for your comments. Sorry, I hadn't enough time to implement the features you asked for. However, a simple update is done - you can now load your own map (b/w png) in order to shape the forest. Unfortunately, Flash has an upper limit of approx 2800 px in one dimension and it becomes very slow with large bitmaps. Therefore, one map at one time shouldn't be larger than 2000 x 2000 px.

To get the shape you want to: create a png no larger than 2000 x 2000 px with a white background (no trees) and black areas (trees). More adventureous people can just leave the to-be-forested area transparent and paint everything that must not have trees on it white. At present, there is no preview for the whole map if it is larger than the apps' viewing window. Also, at present you can't drag the forest to get a better view. So you need to trust the tool ;)

Please be patient when saving - you will get a large png that does take some time to compute. The ui has changed a little bit: now at start you won't get a default forest. Instead, you can choose between generating a totally random forest or loading a map. In the first case, everything works as in the previous version with the exception that there is no map locking button anymore. In the second case, the map is active as long as you don't generate or load a new one. This is true even when you change the density param (didn't look at it more closely but I think changing the threshold does only affect a forest based on a random map, not a loaded one).

How to use:

Random Map:
1. Click at the button "Random" at the lower left of the panel. More on that in my first post

Custom map:
1. Click at the button "Load" besides the above mentioned "Random" button. A dialog will pop up where you can choose a png to load.
2. After a short time, a forest based on the black (or transparent) area of the map will be generated. It does consist of just one single tree type (the default one: second from left in the panel).
3. You can do the same with this forest as with a randomly generated one (again, look at the first post).
4. Play around with the different tree types: every time you change the settings, a new forest with the same tree positions but with other types is calculated. Changing types: click on a tree pict in the panel. If that tree was not active (marked with red halo), it will now be activated. To deselect it, shift-click on it (if it is the only active tree, you can't deselect it at all). To select multiple trees, just shift-click on them. If there are several types active and you click on one tree (active or not), it will be activated and all other trees will be deactivated. Whatever that does mean - just try it out.
5. The shadow options are self-explanatory (in a ui, this is almost never true but it saves me time describing the tool)
6. The density button changes the distance between single trees. That way you can get a very dense forest (which will result in a very fat png).
7. Click on the logo in the upper right to save the forest as a transparent png - please be patient, Flash is a little bit slow here (no, in fact I didn't optimize even one single line of code, sorry)

The slightly changed interface:


A map example (was: 1500 x 1500):


The resulting forest with different tree types (in the png, the bgd is transparent; this jpg is just to give an idea of the result):


download: http://www.mediafire.com/?u6z0jlz2b5i8j3j

Happy foresting

09-09-2010, 01:32 PM
Excellent tool easy to use and great output.

09-10-2010, 01:02 PM

another minor update.

Changes and bugs:

- ability to set the dimensions of a random map (min 200, max 2000 - the higher the number the terribly slower the app). If you don't set a number when generating a map, the default value of 200 x 200 is used (resulting in a small forest that does shamefully hide behind the panel). If you change the dimensions of the map in the text fields, the map isn't updated automatically. You need to generate a new one by clicking on the "Generate" button. The dimensions of a loaded map can't be set this way. In that case the text fields just show the actual width and height of the map.
- ability to load own tree brushes. Simply put a tile sheet (png with transparency) into the folder where you run the tool. The file name needs to be tree.png. Its dimensions should be 40px wide and up to 480px high. One tree must be 40 x 40px. If your sheet is 480 px high, you should have 12 trees. In fact, the tool doesn't care if the sheet is much higher. All trees will be displayed, even if you use 20 or so. But at present, the panel isn't resized. Therefore, in that case some tiles will be positioned to the right outside of the panel.
- large forests are even slower calculated then ever before. This is a feature, not a bug. Its kind of a protest against an ever faster running world that doesn't give us time to rest and think (sounds much better than the bug thingy).
- if the forest is very large, the density button nicely reflects that faster going world by adding / subtracting more than one number per click

Included in the download are two pngs: trees.png (default trees) and trees2.png. If you want to test custom brushes just save tree.png at a dry, not to dark place and change the name of trees2.png to trees.png. Then run the tool. You will get 7 instead of the usual 12 trees. Go ahead as usual. If you use the swf, you will need Flash Player 10

Download: http://www.mediafire.com/?fa9ha44jqob524h

Happy foresting

09-11-2010, 01:21 AM
Wow, excellent!

Easy to work around size limitations if your map is larger than 2000x2000 and/or you have multiple forests - you can make a separate mask for each section of forest, and run them through the generator separately. Import them into the main file, and place accordingly :)


09-12-2010, 12:07 PM

another small update

change log:
- added a probability function that sets the relative probability of the tree types. At start all tree types have the same probability, indicated by the Number 1 (just beneath the tree thumb). If you ctrl-click on a thumb, you can change the probability: either it is going up until the number 3 is reached or its going back to the default of 1. Suppose, you did choose two trees both with a probability of 1. In that case the chance to get the one or the other type is equal (1:1). If you set the probability of the first one to 2, the chances are 3:1 for this one. And the number 3 means a chance of 6:1. I didn't simply add up the numbers to calculate the chances in order to get a more dramatic change. Changing that num for non-active trees is possible, but then the forest doesn't get recalculated of course. Only the num is updated.

Example: probability 1 for all tree types


probability 1 and 3 respectively


- ui changes: the num stepper for the threshold and the density are gone. Instead you get sliders that do show min and max values. Also they react more correctly to changes even if the generated forest is very large.

download: http://www.mediafire.com/?8a6eij65khmr01r

The swf needs Flash Player 10
Again: please be patient when saving a large image. Flash is somewhat slow computing bitmaps on the fly (and I still didn't optimize the code, sorry)

Happy foresting