Fossil SCM
Convert background colors into foreground colors before using them for drawing graph lines.
Commit
70e882b5db49a9130d0f9ee2f4b29992e61f70bb
Parent
675f8c7d29b09ea…
2 files changed
+4
-4
+32
-1
+4
-4
| --- src/captcha.c | ||
| +++ src/captcha.c | ||
| @@ -28,11 +28,11 @@ | ||
| 28 | 28 | #endif |
| 29 | 29 | |
| 30 | 30 | /* |
| 31 | 31 | ** Convert a hex digit into a value between 0 and 15 |
| 32 | 32 | */ |
| 33 | -static int hexValue(char c){ | |
| 33 | +int hex_digit_value(char c){ | |
| 34 | 34 | if( c>='0' && c<='9' ){ |
| 35 | 35 | return c - '0'; |
| 36 | 36 | }else if( c>='a' && c<='f' ){ |
| 37 | 37 | return c - 'a' + 10; |
| 38 | 38 | }else if( c>='A' && c<='F' ){ |
| @@ -75,11 +75,11 @@ | ||
| 75 | 75 | int i, j, k, m; |
| 76 | 76 | |
| 77 | 77 | k = 0; |
| 78 | 78 | for(i=0; i<6; i++){ |
| 79 | 79 | for(j=0; zPw[j]; j++){ |
| 80 | - unsigned char v = hexValue(zPw[j]); | |
| 80 | + unsigned char v = hex_digit_value(zPw[j]); | |
| 81 | 81 | v = (aFont1[v] >> ((5-i)*4)) & 0xf; |
| 82 | 82 | for(m=8; m>=1; m = m>>1){ |
| 83 | 83 | if( v & m ){ |
| 84 | 84 | z[k++] = 'X'; |
| 85 | 85 | z[k++] = 'X'; |
| @@ -209,11 +209,11 @@ | ||
| 209 | 209 | const char *zChar; |
| 210 | 210 | |
| 211 | 211 | k = 0; |
| 212 | 212 | for(i=0; i<4; i++){ |
| 213 | 213 | for(j=0; zPw[j]; j++){ |
| 214 | - unsigned char v = hexValue(zPw[j]); | |
| 214 | + unsigned char v = hex_digit_value(zPw[j]); | |
| 215 | 215 | zChar = azFont2[4*v + i]; |
| 216 | 216 | for(m=0; zChar[m]; m++){ |
| 217 | 217 | z[k++] = zChar[m]; |
| 218 | 218 | } |
| 219 | 219 | } |
| @@ -369,11 +369,11 @@ | ||
| 369 | 369 | |
| 370 | 370 | k = 0; |
| 371 | 371 | for(i=0; i<6; i++){ |
| 372 | 372 | x = 0; |
| 373 | 373 | for(j=0; zPw[j]; j++){ |
| 374 | - unsigned char v = hexValue(zPw[j]); | |
| 374 | + unsigned char v = hex_digit_value(zPw[j]); | |
| 375 | 375 | x = (x<<4) + v; |
| 376 | 376 | switch( x ){ |
| 377 | 377 | case 0x7a: |
| 378 | 378 | case 0xfa: |
| 379 | 379 | y = 3; |
| 380 | 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 | 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 @@ | ||
| 596 | 596 | } |
| 597 | 597 | @ </table> |
| 598 | 598 | if( fchngQueryInit ) db_finalize(&fchngQuery); |
| 599 | 599 | timeline_output_graph_javascript(pGraph, (tmFlags & TIMELINE_DISJOINT)!=0, 0); |
| 600 | 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 | +} | |
| 601 | 632 | |
| 602 | 633 | /* |
| 603 | 634 | ** Generate all of the necessary javascript to generate a timeline |
| 604 | 635 | ** graph. |
| 605 | 636 | */ |
| @@ -698,11 +729,11 @@ | ||
| 698 | 729 | } |
| 699 | 730 | } |
| 700 | 731 | if( cSep=='[' ) cgi_printf("["); |
| 701 | 732 | cgi_printf("],"); |
| 702 | 733 | if( colorGraph && pRow->zBgClr[0]=='#' ){ |
| 703 | - cgi_printf("fg:\"%s\",", pRow->zBgClr); | |
| 734 | + cgi_printf("fg:\"%s\",", bg_to_fg(pRow->zBgClr)); | |
| 704 | 735 | } |
| 705 | 736 | /* mi */ |
| 706 | 737 | cgi_printf("mi:"); |
| 707 | 738 | cSep = '['; |
| 708 | 739 | for(i=0; i<GR_MAX_RAIL; i++){ |
| 709 | 740 |
| --- 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 |