Fossil

Check-in [ce4a44d931]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Improvements to the automatic background color chooser. Provide a setting which alters the algorithm to work with a light-color foreground.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: ce4a44d931dfb3c0194c6d3b704010205f78c4b5
User & Date: drh 2011-07-23 22:05:04.501
Context
2011-07-23
22:13
Fix a harmless compiler warning. check-in: ba15af450d user: drh tags: trunk
22:05
Improvements to the automatic background color chooser. Provide a setting which alters the algorithm to work with a light-color foreground. check-in: ce4a44d931 user: drh tags: trunk
16:01
Merge the autosetup update into trunk. check-in: 3c512b3748 user: drh tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/db.c.
1667
1668
1669
1670
1671
1672
1673

1674
1675
1676
1677
1678
1679
1680
  { "mtime-changes", 0,                0, "on"                  },
  { "pgp-command",   0,               32, "gpg --clearsign -o " },
  { "proxy",         0,               32, "off"                 },
  { "repo-cksum",    0,                0, "on"                  },
  { "self-register", 0,                0, "off"                 },
  { "ssh-command",   0,               32, ""                    },
  { "web-browser",   0,               32, ""                    },

  { 0,0,0,0 }
};

/*
** COMMAND: settings
** COMMAND: unset
**







>







1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
  { "mtime-changes", 0,                0, "on"                  },
  { "pgp-command",   0,               32, "gpg --clearsign -o " },
  { "proxy",         0,               32, "off"                 },
  { "repo-cksum",    0,                0, "on"                  },
  { "self-register", 0,                0, "off"                 },
  { "ssh-command",   0,               32, ""                    },
  { "web-browser",   0,               32, ""                    },
  { "white-foreground", 0,             0, "off"                 },
  { 0,0,0,0 }
};

/*
** COMMAND: settings
** COMMAND: unset
**
Changes to src/timeline.c.
116
117
118
119
120
121
122

123
124

125









126
127
128
129



130
131
132
133
134
135
136
137
138
139
140
/*
** Hash a string and use the hash to determine a background color.
*/
const char *hashColor(const char *z){
  int i;                       /* Loop counter */
  unsigned int h = 0;          /* Hash on the branch name */
  int r, g, b;                 /* Values for red, green, and blue */

  int mx, mn, h1, h2;          /* Components of HSV */
  static char zColor[10];      /* The resulting color */











  for(i=0; z[i]; i++ ){
    h = (h<<11) ^ (h<<1) ^ (h>>3) ^ z[0];
    z++;
  }



  mx = 0xd1;
  mn = 0xa8;
  h1 = h%6;
  h2 = ((h/6)%(mx - mn)) + mn;
  switch( h1 ){
    case 0:  r = mx; g = h2, b = mn;  break;
    case 1:  r = h2; g = mx, b = mn;  break;
    case 2:  r = mn; g = mx, b = h2;  break;
    case 3:  r = mn; g = h2, b = mx;  break;
    case 4:  r = h2; g = mn, b = mx;  break;
    default: r = mx; g = mn, b = h2;  break;







>
|

>

>
>
>
>
>
>
>
>
>

|
<

>
>
>
|
|
<
|







116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138

139
140
141
142
143
144

145
146
147
148
149
150
151
152
/*
** Hash a string and use the hash to determine a background color.
*/
const char *hashColor(const char *z){
  int i;                       /* Loop counter */
  unsigned int h = 0;          /* Hash on the branch name */
  int r, g, b;                 /* Values for red, green, and blue */
  int h1, h2, h3, h4;          /* Elements of the hash value */
  int mx, mn;                  /* Components of HSV */
  static char zColor[10];      /* The resulting color */
  static int ix[2] = {0,0};    /* Color chooser parameters */

  if( ix[0]==0 ){
    if( db_get_boolean("white-foreground", 0) ){
      ix[0] = 140;
      ix[1] = 40;
    }else{
      ix[0] = 216;
      ix[1] = 16;
    }
  }
  for(i=0; z[i]; i++ ){
    h = (h<<11) ^ (h<<1) ^ (h>>3) ^ z[i];

  }
  h1 = h % 6;  h /= 6;
  h3 = h % 30; h /= 30;
  h4 = h % 40; h /= 40;
  mx = ix[0] - h3;
  mn = mx - h4 - ix[1];

  h2 = (h%(mx - mn)) + mn;
  switch( h1 ){
    case 0:  r = mx; g = h2, b = mn;  break;
    case 1:  r = h2; g = mx, b = mn;  break;
    case 2:  r = mn; g = mx, b = h2;  break;
    case 3:  r = mn; g = h2, b = mx;  break;
    case 4:  r = h2; g = mn, b = mx;  break;
    default: r = mx; g = mn, b = h2;  break;