Dungeondraft colorables

The goal: colorable default assets

It seems not allowed to derive the default assets so I cannot share the pack itself. I'll update if DungeonDraft team allows me to.

In DungeonDraft, you have assets. In the default pack, some are colorables. Others are not. But you might would like to color them anyway. So here's a description of how I exported the default assets from DungeonDraft (note that you can then download these assets) and imported them back into a colorable pack.

This is our goal: making the default assets colorable as you wish

A script to export assets

So, I made a script in PHP that will help us reaching our goal: making assets from a pack colorable. First, this script will parse the pack content, then extract the PNG images from this pack (it will tho need some manual actions for that, see below), and then it analyses the exported PNG images to compile a new colorable pack. Last, it will let you pack it using DD's way of packing assets, and you will be able to use these colorables anywhere.

Environment

This script works best on Linux. For Windows, you'll probably have to adapt some stuff, like paths.

This script is provided "as is". No guarantee or whatsoever. Plus, I may alter the script anytime to fit my needs, and so, screens may no longer match the script, or even, the process describe here won't work.

The script will require PHP interpreter (Linux: sudo apt install php-cli as you don't need anything web related), the PHP-GD library (Linux: sudo apt install php-gd) and DungeonDraft.

Export the objects

When you extract the pack, the most important file is convert-assets.php.

The base-map file is an empty map that we will use to export assets. The gen-map is an intermediate file generated by the script.

Run the script with php -f convert-assets.php /path/to/packname. For instance, php -f convert-assets.php /opt/Dungeondraft/Dungeondraft.pck. It will create a directory with the packname (here, Dungeondraft) and put everything in there. Let it run.

At some point, the script generate a map containing a bunch of assets in a dedicated level and it will open DungeonDraft with this map
You now have to manyally export this map as a PNG, because no API allows to do so

Don't worry about overlapping assets: script will deal with it, it's normal so far

When exporting (ctrl+e), turn off the "Grid" and "Lighting" and ensure the exported level is "ExportLevel"

It's important to turn grid off, as it would mess with the exported image and so mess with the script. Turning shadow off is important too, otherwise the shadow will be embeded with the colorable object

Pick any name for the exported image, but put it in the scriptdirectory/packname directory.
Then close DungeonDraft, and the script should continue its work

If the script looks stuck not finding the exported image, check that you have exported it in the proper directory

The script will isolate some of the assets from the PNG image you exported, and loop
So you will get another map to export like before, and so on (note that assets will change between these maps)
Along the exports, you will slightly see that the assets gets a bit more "spaced"
In case an export fails or DungeonDraft crashes, no worry, just close DD (if not crashed), and continue the export

You may also stop the script anytime, and re-run it later on at your will: the script will continue from where you stopped it

Turning assets to colorables

Once all assets have been isolated properly, the script will run for a while, scanning every image and making it colorable. The script works by picking each image, looking for its content, trying to cluster colors in bunch, and apply a "red tone" to each cluster. Then, one image is saved for every of these red cluster, and put into the folder to pack.

All this part is automatic, so let script run. It may take few minutes.
At this point, you will have a directory containing the files for a DD pack. You just need to add a preview image

Packing the result

Open DungeonDraft and pack the generated directory like a usual DD pack

Using a generated colorable pack

Select the pack in a map
And use the tag "packname" to filter on your assets. Since I generated a colorable from default "Dungeondraft" pack, the tag is "Dungeondraft"
Have fun with the colors!

In the script's directory, inside the "packname" directory ("Dungeondraft" for this example) you will also find a "assets-png" directory containing each asset in a dedicated image. This may also be a useful resource for you to have.

As a bonus, a simple alteration of the assets before packaging allows to create flat "colorable shadows" or assets: simply replace each (R,G,B,A) pixel with a (255,0,0,A) value.