Fossil SCM
Improvements to the automatic background color chooser. Provide a setting which alters the algorithm to work with a light-color foreground.
Commit
ce4a44d931dfb3c0194c6d3b704010205f78c4b5
Parent
3c512b37480e448…
2 files changed
+1
+19
-7
M
src/db.c
+1
| --- src/db.c | ||
| +++ src/db.c | ||
| @@ -1669,10 +1669,11 @@ | ||
| 1669 | 1669 | { "proxy", 0, 32, "off" }, |
| 1670 | 1670 | { "repo-cksum", 0, 0, "on" }, |
| 1671 | 1671 | { "self-register", 0, 0, "off" }, |
| 1672 | 1672 | { "ssh-command", 0, 32, "" }, |
| 1673 | 1673 | { "web-browser", 0, 32, "" }, |
| 1674 | + { "white-foreground", 0, 0, "off" }, | |
| 1674 | 1675 | { 0,0,0,0 } |
| 1675 | 1676 | }; |
| 1676 | 1677 | |
| 1677 | 1678 | /* |
| 1678 | 1679 | ** COMMAND: settings |
| 1679 | 1680 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -1669,10 +1669,11 @@ | |
| 1669 | { "proxy", 0, 32, "off" }, |
| 1670 | { "repo-cksum", 0, 0, "on" }, |
| 1671 | { "self-register", 0, 0, "off" }, |
| 1672 | { "ssh-command", 0, 32, "" }, |
| 1673 | { "web-browser", 0, 32, "" }, |
| 1674 | { 0,0,0,0 } |
| 1675 | }; |
| 1676 | |
| 1677 | /* |
| 1678 | ** COMMAND: settings |
| 1679 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -1669,10 +1669,11 @@ | |
| 1669 | { "proxy", 0, 32, "off" }, |
| 1670 | { "repo-cksum", 0, 0, "on" }, |
| 1671 | { "self-register", 0, 0, "off" }, |
| 1672 | { "ssh-command", 0, 32, "" }, |
| 1673 | { "web-browser", 0, 32, "" }, |
| 1674 | { "white-foreground", 0, 0, "off" }, |
| 1675 | { 0,0,0,0 } |
| 1676 | }; |
| 1677 | |
| 1678 | /* |
| 1679 | ** COMMAND: settings |
| 1680 |
+19
-7
| --- src/timeline.c | ||
| +++ src/timeline.c | ||
| @@ -118,21 +118,33 @@ | ||
| 118 | 118 | */ |
| 119 | 119 | const char *hashColor(const char *z){ |
| 120 | 120 | int i; /* Loop counter */ |
| 121 | 121 | unsigned int h = 0; /* Hash on the branch name */ |
| 122 | 122 | int r, g, b; /* Values for red, green, and blue */ |
| 123 | - int mx, mn, h1, h2; /* Components of HSV */ | |
| 123 | + int h1, h2, h3, h4; /* Elements of the hash value */ | |
| 124 | + int mx, mn; /* Components of HSV */ | |
| 124 | 125 | static char zColor[10]; /* The resulting color */ |
| 126 | + static int ix[2] = {0,0}; /* Color chooser parameters */ | |
| 125 | 127 | |
| 128 | + if( ix[0]==0 ){ | |
| 129 | + if( db_get_boolean("white-foreground", 0) ){ | |
| 130 | + ix[0] = 140; | |
| 131 | + ix[1] = 40; | |
| 132 | + }else{ | |
| 133 | + ix[0] = 216; | |
| 134 | + ix[1] = 16; | |
| 135 | + } | |
| 136 | + } | |
| 126 | 137 | for(i=0; z[i]; i++ ){ |
| 127 | - h = (h<<11) ^ (h<<1) ^ (h>>3) ^ z[0]; | |
| 128 | - z++; | |
| 138 | + h = (h<<11) ^ (h<<1) ^ (h>>3) ^ z[i]; | |
| 129 | 139 | } |
| 130 | - mx = 0xd1; | |
| 131 | - mn = 0xa8; | |
| 132 | - h1 = h%6; | |
| 133 | - h2 = ((h/6)%(mx - mn)) + mn; | |
| 140 | + h1 = h % 6; h /= 6; | |
| 141 | + h3 = h % 30; h /= 30; | |
| 142 | + h4 = h % 40; h /= 40; | |
| 143 | + mx = ix[0] - h3; | |
| 144 | + mn = mx - h4 - ix[1]; | |
| 145 | + h2 = (h%(mx - mn)) + mn; | |
| 134 | 146 | switch( h1 ){ |
| 135 | 147 | case 0: r = mx; g = h2, b = mn; break; |
| 136 | 148 | case 1: r = h2; g = mx, b = mn; break; |
| 137 | 149 | case 2: r = mn; g = mx, b = h2; break; |
| 138 | 150 | case 3: r = mn; g = h2, b = mx; break; |
| 139 | 151 |
| --- src/timeline.c | |
| +++ src/timeline.c | |
| @@ -118,21 +118,33 @@ | |
| 118 | */ |
| 119 | const char *hashColor(const char *z){ |
| 120 | int i; /* Loop counter */ |
| 121 | unsigned int h = 0; /* Hash on the branch name */ |
| 122 | int r, g, b; /* Values for red, green, and blue */ |
| 123 | int mx, mn, h1, h2; /* Components of HSV */ |
| 124 | static char zColor[10]; /* The resulting color */ |
| 125 | |
| 126 | for(i=0; z[i]; i++ ){ |
| 127 | h = (h<<11) ^ (h<<1) ^ (h>>3) ^ z[0]; |
| 128 | z++; |
| 129 | } |
| 130 | mx = 0xd1; |
| 131 | mn = 0xa8; |
| 132 | h1 = h%6; |
| 133 | h2 = ((h/6)%(mx - mn)) + mn; |
| 134 | switch( h1 ){ |
| 135 | case 0: r = mx; g = h2, b = mn; break; |
| 136 | case 1: r = h2; g = mx, b = mn; break; |
| 137 | case 2: r = mn; g = mx, b = h2; break; |
| 138 | case 3: r = mn; g = h2, b = mx; break; |
| 139 |
| --- src/timeline.c | |
| +++ src/timeline.c | |
| @@ -118,21 +118,33 @@ | |
| 118 | */ |
| 119 | const char *hashColor(const char *z){ |
| 120 | int i; /* Loop counter */ |
| 121 | unsigned int h = 0; /* Hash on the branch name */ |
| 122 | int r, g, b; /* Values for red, green, and blue */ |
| 123 | int h1, h2, h3, h4; /* Elements of the hash value */ |
| 124 | int mx, mn; /* Components of HSV */ |
| 125 | static char zColor[10]; /* The resulting color */ |
| 126 | static int ix[2] = {0,0}; /* Color chooser parameters */ |
| 127 | |
| 128 | if( ix[0]==0 ){ |
| 129 | if( db_get_boolean("white-foreground", 0) ){ |
| 130 | ix[0] = 140; |
| 131 | ix[1] = 40; |
| 132 | }else{ |
| 133 | ix[0] = 216; |
| 134 | ix[1] = 16; |
| 135 | } |
| 136 | } |
| 137 | for(i=0; z[i]; i++ ){ |
| 138 | h = (h<<11) ^ (h<<1) ^ (h>>3) ^ z[i]; |
| 139 | } |
| 140 | h1 = h % 6; h /= 6; |
| 141 | h3 = h % 30; h /= 30; |
| 142 | h4 = h % 40; h /= 40; |
| 143 | mx = ix[0] - h3; |
| 144 | mn = mx - h4 - ix[1]; |
| 145 | h2 = (h%(mx - mn)) + mn; |
| 146 | switch( h1 ){ |
| 147 | case 0: r = mx; g = h2, b = mn; break; |
| 148 | case 1: r = h2; g = mx, b = mn; break; |
| 149 | case 2: r = mn; g = mx, b = h2; break; |
| 150 | case 3: r = mn; g = h2, b = mx; break; |
| 151 |