diff --git a/lemonbar.c b/lemonbar.c index b9fe2c9..e21267c 100644 --- a/lemonbar.c +++ b/lemonbar.c @@ -97,11 +97,16 @@ static int bu = 1; // Underline height static rgba_t fgc, bgc, ugc; static rgba_t dfgc, dbgc, dugc; static area_stack_t area_stack; + +// slant vars static int slant; +static int right; static int slant_width; static int full_slant_width; static int slant_counter; static int upslant; +static int fg_height; +static int bg_height; void update_gc (void) @@ -220,10 +225,6 @@ draw_char (monitor_t *mon, font_t *cur_font, int x, int align, uint16_t ch, int // Draw the background first if(slant_width) { - // even = slant left, odd = slant right - int right = slant % 2; - int cur_height = 0; - if(!full_slant_width) full_slant_width = slant_width * ch_width; @@ -231,15 +232,25 @@ draw_char (monitor_t *mon, font_t *cur_font, int x, int align, uint16_t ch, int { slant_counter++; if (right) - cur_height = (bh * (full_slant_width - slant_counter)) / full_slant_width; + { + fg_height = (bh * (full_slant_width - slant_counter)) / full_slant_width; + bg_height = (slant_counter * bh) / full_slant_width; + } else - cur_height = (slant_counter * bh) / full_slant_width; + { + fg_height = (slant_counter * bh) / full_slant_width; + bg_height = (bh * (full_slant_width - slant_counter)) / full_slant_width; + } - if (!upslant) - cur_height *= -1; + if (upslant) + bg_height *= -1; + else + fg_height *= -1; - fill_rect(mon->pixmap, gc[GC_CLEAR], x+i, cur_height, 1, bh); + fill_rect(mon->pixmap, gc[GC_DRAW], x+i, fg_height, 1, bh); + fill_rect(mon->pixmap, gc[GC_CLEAR], x+i, bg_height, 1, bh); } + slant_width--; } else { @@ -561,7 +572,10 @@ parse (char *text) case 'd': slant = *(p-1) - 'A'; // 4,36,5,37 slant_width = (*p++) - '0'; + right = slant % 2; full_slant_width = 0; + fg_height = 0; + bg_height = 0; slant_counter = 0; upslant = slant > 20 ? 1 : 0; break; diff --git a/slant_demo.sh b/slant_demo.sh index 9ea9905..bd21d8a 100755 --- a/slant_demo.sh +++ b/slant_demo.sh @@ -3,9 +3,12 @@ # demonstrate slant flags and what they look like Len=2 -geom=200x20+10+10 -bg='%{B#ff000000}' -sbg='%{B#ff00ff00}' +geom=400x20+10+10 +slant_fg='#a7a7a7' +slant_bg='#3e3e3e' +colors="%{F${slant_fg}}%{B${slant_bg}}" + +reset='%{B-}%{F-}' space() { @@ -13,8 +16,10 @@ space() } echo " \ -${sbg}%{E${Len}}$(space)${bg} - \ -${sbg}%{e${Len}}$(space)${bg} - \ -${sbg}%{D${Len}}$(space)${bg} - \ -${sbg}%{d${Len}}$(space)${bg} " \ -| ./lemonbar -g $geom -p -B "#000000" +${colors}%{E${Len}}$(space)${reset} - \ +${colors}%{e${Len}}$(space)${reset} - \ +${colors}%{D${Len}}$(space)${reset} - \ +${colors}%{d${Len}}$(space)${reset} \ +${colors}%{d${Len}}$(space)%{B${slant_fg}}%{F${slant_bg}} ~ slants and shit ~ \ +${colors}%{E${Len}}$(space)${reset}" \ +| ./lemonbar -g $geom -p -B "$slant_bg" -F "#FFFFFF"