Fossil SCM

Convert background colors into foreground colors before using them for drawing graph lines.

drh 2015-03-30 17:43 UTC improved-skin-edit
Commit 70e882b5db49a9130d0f9ee2f4b29992e61f70bb
2 files changed +4 -4 +32 -1
+4 -4
--- src/captcha.c
+++ src/captcha.c
@@ -28,11 +28,11 @@
2828
#endif
2929
3030
/*
3131
** Convert a hex digit into a value between 0 and 15
3232
*/
33
-static int hexValue(char c){
33
+int hex_digit_value(char c){
3434
if( c>='0' && c<='9' ){
3535
return c - '0';
3636
}else if( c>='a' && c<='f' ){
3737
return c - 'a' + 10;
3838
}else if( c>='A' && c<='F' ){
@@ -75,11 +75,11 @@
7575
int i, j, k, m;
7676
7777
k = 0;
7878
for(i=0; i<6; i++){
7979
for(j=0; zPw[j]; j++){
80
- unsigned char v = hexValue(zPw[j]);
80
+ unsigned char v = hex_digit_value(zPw[j]);
8181
v = (aFont1[v] >> ((5-i)*4)) & 0xf;
8282
for(m=8; m>=1; m = m>>1){
8383
if( v & m ){
8484
z[k++] = 'X';
8585
z[k++] = 'X';
@@ -209,11 +209,11 @@
209209
const char *zChar;
210210
211211
k = 0;
212212
for(i=0; i<4; i++){
213213
for(j=0; zPw[j]; j++){
214
- unsigned char v = hexValue(zPw[j]);
214
+ unsigned char v = hex_digit_value(zPw[j]);
215215
zChar = azFont2[4*v + i];
216216
for(m=0; zChar[m]; m++){
217217
z[k++] = zChar[m];
218218
}
219219
}
@@ -369,11 +369,11 @@
369369
370370
k = 0;
371371
for(i=0; i<6; i++){
372372
x = 0;
373373
for(j=0; zPw[j]; j++){
374
- unsigned char v = hexValue(zPw[j]);
374
+ unsigned char v = hex_digit_value(zPw[j]);
375375
x = (x<<4) + v;
376376
switch( x ){
377377
case 0x7a:
378378
case 0xfa:
379379
y = 3;
380380
--- src/captcha.c
+++ src/captcha.c
@@ -28,11 +28,11 @@
28 #endif
29
30 /*
31 ** Convert a hex digit into a value between 0 and 15
32 */
33 static int hexValue(char c){
34 if( c>='0' && c<='9' ){
35 return c - '0';
36 }else if( c>='a' && c<='f' ){
37 return c - 'a' + 10;
38 }else if( c>='A' && c<='F' ){
@@ -75,11 +75,11 @@
75 int i, j, k, m;
76
77 k = 0;
78 for(i=0; i<6; i++){
79 for(j=0; zPw[j]; j++){
80 unsigned char v = hexValue(zPw[j]);
81 v = (aFont1[v] >> ((5-i)*4)) & 0xf;
82 for(m=8; m>=1; m = m>>1){
83 if( v & m ){
84 z[k++] = 'X';
85 z[k++] = 'X';
@@ -209,11 +209,11 @@
209 const char *zChar;
210
211 k = 0;
212 for(i=0; i<4; i++){
213 for(j=0; zPw[j]; j++){
214 unsigned char v = hexValue(zPw[j]);
215 zChar = azFont2[4*v + i];
216 for(m=0; zChar[m]; m++){
217 z[k++] = zChar[m];
218 }
219 }
@@ -369,11 +369,11 @@
369
370 k = 0;
371 for(i=0; i<6; i++){
372 x = 0;
373 for(j=0; zPw[j]; j++){
374 unsigned char v = hexValue(zPw[j]);
375 x = (x<<4) + v;
376 switch( x ){
377 case 0x7a:
378 case 0xfa:
379 y = 3;
380
--- src/captcha.c
+++ src/captcha.c
@@ -28,11 +28,11 @@
28 #endif
29
30 /*
31 ** Convert a hex digit into a value between 0 and 15
32 */
33 int hex_digit_value(char c){
34 if( c>='0' && c<='9' ){
35 return c - '0';
36 }else if( c>='a' && c<='f' ){
37 return c - 'a' + 10;
38 }else if( c>='A' && c<='F' ){
@@ -75,11 +75,11 @@
75 int i, j, k, m;
76
77 k = 0;
78 for(i=0; i<6; i++){
79 for(j=0; zPw[j]; j++){
80 unsigned char v = hex_digit_value(zPw[j]);
81 v = (aFont1[v] >> ((5-i)*4)) & 0xf;
82 for(m=8; m>=1; m = m>>1){
83 if( v & m ){
84 z[k++] = 'X';
85 z[k++] = 'X';
@@ -209,11 +209,11 @@
209 const char *zChar;
210
211 k = 0;
212 for(i=0; i<4; i++){
213 for(j=0; zPw[j]; j++){
214 unsigned char v = hex_digit_value(zPw[j]);
215 zChar = azFont2[4*v + i];
216 for(m=0; zChar[m]; m++){
217 z[k++] = zChar[m];
218 }
219 }
@@ -369,11 +369,11 @@
369
370 k = 0;
371 for(i=0; i<6; i++){
372 x = 0;
373 for(j=0; zPw[j]; j++){
374 unsigned char v = hex_digit_value(zPw[j]);
375 x = (x<<4) + v;
376 switch( x ){
377 case 0x7a:
378 case 0xfa:
379 y = 3;
380
+32 -1
--- src/timeline.c
+++ src/timeline.c
@@ -596,10 +596,41 @@
596596
}
597597
@ </table>
598598
if( fchngQueryInit ) db_finalize(&fchngQuery);
599599
timeline_output_graph_javascript(pGraph, (tmFlags & TIMELINE_DISJOINT)!=0, 0);
600600
}
601
+
602
+/*
603
+** Change the RGB background color given in the argument in a foreground
604
+** color with the same hue.
605
+*/
606
+static const char *bg_to_fg(const char *zIn){
607
+ int i;
608
+ unsigned int x[3];
609
+ unsigned int mx = 0;
610
+ static int whiteFg = -1;
611
+ static char zRes[10];
612
+ if( strlen(zIn)!=7 || zIn[0]!='#' ) return zIn;
613
+ zIn++;
614
+ for(i=0; i<3; i++){
615
+ x[i] = hex_digit_value(zIn[0])*16 + hex_digit_value(zIn[1]);
616
+ zIn += 2;
617
+ if( x[i]>mx ) mx = x[i];
618
+ }
619
+ if( whiteFg<0 ) whiteFg = skin_detail_boolean("white-foreground");
620
+ if( whiteFg ){
621
+ /* Make the color lighter */
622
+ static const unsigned int t = 215;
623
+ if( mx<t ) for(i=0; i<3; i++) x[i] += t - mx;
624
+ }else{
625
+ /* Make the color darker */
626
+ static const unsigned int t = 128;
627
+ if( mx>t ) for(i=0; i<3; i++) x[i] -= mx - t;
628
+ }
629
+ sqlite3_snprintf(sizeof(zRes),zRes,"#%02x%02x%02x",x[0],x[1],x[2]);
630
+ return zRes;
631
+}
601632
602633
/*
603634
** Generate all of the necessary javascript to generate a timeline
604635
** graph.
605636
*/
@@ -698,11 +729,11 @@
698729
}
699730
}
700731
if( cSep=='[' ) cgi_printf("[");
701732
cgi_printf("],");
702733
if( colorGraph && pRow->zBgClr[0]=='#' ){
703
- cgi_printf("fg:\"%s\",", pRow->zBgClr);
734
+ cgi_printf("fg:\"%s\",", bg_to_fg(pRow->zBgClr));
704735
}
705736
/* mi */
706737
cgi_printf("mi:");
707738
cSep = '[';
708739
for(i=0; i<GR_MAX_RAIL; i++){
709740
--- src/timeline.c
+++ src/timeline.c
@@ -596,10 +596,41 @@
596 }
597 @ </table>
598 if( fchngQueryInit ) db_finalize(&fchngQuery);
599 timeline_output_graph_javascript(pGraph, (tmFlags & TIMELINE_DISJOINT)!=0, 0);
600 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
601
602 /*
603 ** Generate all of the necessary javascript to generate a timeline
604 ** graph.
605 */
@@ -698,11 +729,11 @@
698 }
699 }
700 if( cSep=='[' ) cgi_printf("[");
701 cgi_printf("],");
702 if( colorGraph && pRow->zBgClr[0]=='#' ){
703 cgi_printf("fg:\"%s\",", pRow->zBgClr);
704 }
705 /* mi */
706 cgi_printf("mi:");
707 cSep = '[';
708 for(i=0; i<GR_MAX_RAIL; i++){
709
--- src/timeline.c
+++ src/timeline.c
@@ -596,10 +596,41 @@
596 }
597 @ </table>
598 if( fchngQueryInit ) db_finalize(&fchngQuery);
599 timeline_output_graph_javascript(pGraph, (tmFlags & TIMELINE_DISJOINT)!=0, 0);
600 }
601
602 /*
603 ** Change the RGB background color given in the argument in a foreground
604 ** color with the same hue.
605 */
606 static const char *bg_to_fg(const char *zIn){
607 int i;
608 unsigned int x[3];
609 unsigned int mx = 0;
610 static int whiteFg = -1;
611 static char zRes[10];
612 if( strlen(zIn)!=7 || zIn[0]!='#' ) return zIn;
613 zIn++;
614 for(i=0; i<3; i++){
615 x[i] = hex_digit_value(zIn[0])*16 + hex_digit_value(zIn[1]);
616 zIn += 2;
617 if( x[i]>mx ) mx = x[i];
618 }
619 if( whiteFg<0 ) whiteFg = skin_detail_boolean("white-foreground");
620 if( whiteFg ){
621 /* Make the color lighter */
622 static const unsigned int t = 215;
623 if( mx<t ) for(i=0; i<3; i++) x[i] += t - mx;
624 }else{
625 /* Make the color darker */
626 static const unsigned int t = 128;
627 if( mx>t ) for(i=0; i<3; i++) x[i] -= mx - t;
628 }
629 sqlite3_snprintf(sizeof(zRes),zRes,"#%02x%02x%02x",x[0],x[1],x[2]);
630 return zRes;
631 }
632
633 /*
634 ** Generate all of the necessary javascript to generate a timeline
635 ** graph.
636 */
@@ -698,11 +729,11 @@
729 }
730 }
731 if( cSep=='[' ) cgi_printf("[");
732 cgi_printf("],");
733 if( colorGraph && pRow->zBgClr[0]=='#' ){
734 cgi_printf("fg:\"%s\",", bg_to_fg(pRow->zBgClr));
735 }
736 /* mi */
737 cgi_printf("mi:");
738 cSep = '[';
739 for(i=0; i<GR_MAX_RAIL; i++){
740

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button