allow dim background color in "View -> Dim oclors"

This commit is contained in:
Stefan Schippers 2020-10-17 03:47:32 +02:00
parent 8a45e319c9
commit 632dbd8931
2 changed files with 16 additions and 3 deletions

View File

@ -261,8 +261,12 @@ void init_color_array(double dim)
{
char s[256]; /* overflow safe 20161122 */
int i;
int dim_bg;
unsigned int r, g, b;
double rr, gg, bb;
static int done=0;
dim_bg = tclgetvar("dim_background")[0] == '1' ? 1: 0;
for(i=0;i<cadlayers;i++) {
my_snprintf(s, S(s), "lindex $colors %d",i);
tcleval(s);
@ -271,7 +275,8 @@ void init_color_array(double dim)
sscanf(tclresult(), "#%02x%02x%02x", &r, &g, &b);
rr=r; gg=g; bb=b;
if( (i!=BACKLAYER) ) {
if(dim_bg || i!=BACKLAYER ) {
if(dim>=0.) {
rr +=(51.-rr/5.)*dim;
gg +=(51.-gg/5.)*dim;
@ -288,7 +293,12 @@ void init_color_array(double dim)
if(b>0xff) b=0xff;
}
my_snprintf(s, S(s), "#%02x%02x%02x", r, g, b);
my_strdup(605, &color_array[i], s);
if(!done) {
my_strdup(605, &color_array[i], s);
done = 1;
} else if(dim_bg || i!=BACKLAYER ) {
my_strdup(605, &color_array[i], s);
}
}
}

View File

@ -1739,13 +1739,15 @@ proc select_layers {} {
proc color_dim {} {
toplevel .dim -class dialog
wm title .dim {Dim colors}
checkbutton .dim.bg -text {Dim background} -variable dim_background
scale .dim.scale -digits 2 -label {Dim factor} -length 256 \
-showvalue 1 -command {xschem color_dim} -orient horizontal \
-from -5 -to 5 -resolution 0.1
button .dim.ok -text OK -command {destroy .dim}
.dim.scale set [xschem get dim]
pack .dim.scale
pack .dim.ok
pack .dim.bg -side left
pack .dim.ok -side right -anchor e
}
proc about {} {
@ -3210,6 +3212,7 @@ set_ne cairo_font_name {Arial}
set has_cairo 0
set rotated_text {} ;#20171208
set_ne dark_colorscheme 1
set_ne dim_background 0
##### set colors
if {!$rainbow_colors} {
set_ne cadlayers 22