Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option coloured_edges is broken #625

Closed
mscfd opened this issue Feb 23, 2024 · 1 comment
Closed

Option coloured_edges is broken #625

mscfd opened this issue Feb 23, 2024 · 1 comment

Comments

@mscfd
Copy link

mscfd commented Feb 23, 2024

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 pushed a commit to mscfd/ford that referenced this issue Feb 27, 2024
mscfd pushed a commit to mscfd/ford that referenced this issue Feb 27, 2024
without nesting level to shift colours, more complex graphs with some columns with just one node tend to be dominated by
red (hsv=1,0,0)

also see issue Fortran-FOSS-Programmers#625
@mscfd
Copy link
Author

mscfd commented Feb 27, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant