At 12:14 PM 7/22/2011, Richard Hipp wrote: >On Fri, Jul 22, 2011 at 3:07 PM, Ross Berteig ><r...@cheshireeng.com> wrote: > >> It would be nice if branches had a default color distinct from >> the trunk. ... One way to do that that *might* be ... generate a >> hash of the branch tag name and use it for the color. > > >Do you have a suggested hash algorithm that will always generate >a usable color - one that has sufficient contrast with foreground >to be readable, yet not eye-jarring. Most of the RGB color space >is, after all, unsuitable for use as background colors on Fossil >timelines. Note also that the set of suitable background colors >will also depend on what foreground color you use for the font. >I guess you could assume that foreground is always black....
For skins that are dark text on white background, then using the existing MD5 hash on the tag name, picking a convenient three bytes, then forcing some high bits of each byte to ones will do the trick. For example, say the MD5 hash begins 0x37 0xfa 0x80. so to get colors that are always light, you could OR in 0xc0, giving #F7FAC0 as the color. This will have the disadvantage of not separating neighboring hashes by very much, so it is probably useful to force some low bits of each color as well. That can be done by using 0xC3 as the mask, so that same hash becomes the color #F7FBC3. Almost none of the colors will be in the Netscape 216 websafe color list, but that is probably not an issue today. MD5 is probably overkill, but it is fast and you already use it in fossil for other purposes. It might make sense to collect a list of actual branch names in use in a real repo (the fossil repo is a good candidate) and see what results. Naturally, getting the trunk to come out white is also easily done by calculating its hash and working out the difference from #FFFFFF. Ross Berteig r...@cheshireeng.com Cheshire Engineering Corp. http://www.CheshireEng.com/ _______________________________________________ fossil-users mailing list fossil-users@lists.fossil-scm.org http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users