support 3digit hex color codes like #f00 or #090
Please support the 3-digit variant of defining colors within graphviz like HTML/CSS supports this for ages(beginning?)
In most cases it is sufficient to just use 1 digit from 0-f for red, green, blue. It is much easier to read and easy to type and modify. I always prefer writing that in HTML/CSS and use it since the last century..
I think it should not be too hard to add this. During parsing graph sources just expand the 3-digit hexcode to the 6 digit hexcode by duplicating each of the 3 digits.
Example: #09c
converts to #0099cc
The short color codes are much easier to scan in code by human as there is no mental effort needed to split the group of double digits into r-g-b parts. If I am interested in the green part in a source code with 3digit rgb codes I just look at the center digit while in 6-digit codes the eye/brain scans between left-right border, splits the parts, do the rounding if for example the green part in the example is more like 2(22) or 3(33) ("20"->2 or more "2f"->3)
Steps to reproduce
Create a dot file lets name it simplecolor.dot:
digraph {
n [color="#c00" fillcolor="#fc0" style=filled]
}
dot -Tsvg simplecolor.dot >simplecolor.svg
Warning: `#fc0` is not a known color.
Warning: `#c00` is not a known color.
Expected Behaviour
Same output as the long version
digraph {
n [color="#cc0000" fillcolor="#ffcc00" style=filled]
}
Actual Behaviour
Short hexcode colors are not accepted currently.
OS Version
not relevant
Graphviz Version
run $ dot -V 2.43.0
Additional info
From https://www.w3.org/TR/CSS2/syndata.html#value-def-color
The format of an RGB value in hexadecimal notation is a '#' immediately followed by either three or six hexadecimal characters. The three-digit RGB notation (#rgb) is converted into six-digit form (#rrggbb) by replicating digits, not by adding zeros. For example,
#fb0
expands to#ffbb00
. This ensures that white (#ffffff
) can be specified with the short notation (#fff
) and removes any dependencies on the color depth of the display.
Edit: Use preformatting markdown for #rgb and #rrggbb so gitlab shows the color beside them.