Fortran-FOSS-Programmers / ford

Automatically generates FORtran Documentation from comments within the code.
https://forddocs.readthedocs.io
GNU General Public License v3.0
402 stars 131 forks source link

Option coloured_edges is broken #625

Closed mscfd closed 5 months ago

mscfd commented 5 months ago

The option coloured_edges is broken. This is due to a wrong formatting of the rgb values. Here is the fixed code with {:02X} formatting in graphs.py:

        def rainbowcolour(depth, maxd):
            if not self.data.coloured_edges:
                return "#000000"
            (r, g, b) = colorsys.hsv_to_rgb(float(depth) / maxd, 1.0, 1.0)
            rgb = [int(255 * r), int(255 * g), int(255 * b)]
            return '#{:02X}{:02X}{:02X}'.format(*rgb)
mscfd commented 5 months ago

After some playing with this option, I noted that some graphs tend to be rather red. This happens if there are some nesting levels with just one node. To still obtain colourful edges I added nesting level to the h-value as follows:

            colour_h = (float(depth) / maxd - float(nesting-1.0)/7.0) % 1.0
            (r, g, b) = colorsys.hsv_to_rgb(colour_h, 1.0, 1.0)
            rgb = [int(255 * r), int(255 * g), int(255 * b)]
            return '#{:02X}{:02X}{:02X}'.format(*rgb)

See commit 5505d26. This might or might not be useful for large graphs.