« Text/ANSITable/StyleSet/AltRow.pm
↑ Summary
ColorTheme/Text/ANSITable/Standard/GradationWhiteBG.pm »
| 1 | # no code | ||||||||||||||||||||||||||||
| 2 | ## no critic: TestingAndDebugging::RequireUseStrict | ||||||||||||||||||||||||||||
| 3 | package ColorTheme::Text::ANSITable::Standard::Gradation; | ||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 8 | our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY | |||||||||||||||||||||||||||
| 6 | 8 | our $DATE = '2025-02-24'; # DATE | |||||||||||||||||||||||||||
| 7 | 8 | our $DIST = 'Text-ANSITable'; # DIST | |||||||||||||||||||||||||||
| 8 | 8 | our $VERSION = '0.610'; # VERSION | |||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 8 | ▶ | use parent 'ColorThemeBase::Static::FromStructColors'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 8 | ▶ | use Color::RGB::Util qw(mix_2_rgb_colors); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | our %THEME = ( | ||||||||||||||||||||||||||||
| 15 | v => 2, | ||||||||||||||||||||||||||||
| 16 | summary => 'Gradation border (for terminal with black background)', | ||||||||||||||||||||||||||||
| 17 | args => { | ||||||||||||||||||||||||||||
| 18 | border1_fg => { | ||||||||||||||||||||||||||||
| 19 | schema => 'color::rgb24*', | ||||||||||||||||||||||||||||
| 20 | default => 'ffffff', | ||||||||||||||||||||||||||||
| 21 | }, | ||||||||||||||||||||||||||||
| 22 | border2_fg => { | ||||||||||||||||||||||||||||
| 23 | schema => 'color::rgb24*', | ||||||||||||||||||||||||||||
| 24 | default => '444444', | ||||||||||||||||||||||||||||
| 25 | }, | ||||||||||||||||||||||||||||
| 26 | border1_bg => { | ||||||||||||||||||||||||||||
| 27 | schema => 'color::rgb24*', | ||||||||||||||||||||||||||||
| 28 | default => undef, | ||||||||||||||||||||||||||||
| 29 | }, | ||||||||||||||||||||||||||||
| 30 | border2_bg => { | ||||||||||||||||||||||||||||
| 31 | schema => 'color::rgb24*', | ||||||||||||||||||||||||||||
| 32 | default => undef, | ||||||||||||||||||||||||||||
| 33 | }, | ||||||||||||||||||||||||||||
| 34 | }, | ||||||||||||||||||||||||||||
| 35 | description => <<'_', | ||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | Border color has gradation from top to bottom. Accept arguments `border1_fg` and | ||||||||||||||||||||||||||||
| 38 | `border2_fg` to set first (top) and second (bottom) foreground RGB colors. | ||||||||||||||||||||||||||||
| 39 | Colors will fade from the top color to bottom color. Also accept `border1_bg` | ||||||||||||||||||||||||||||
| 40 | and `border2_bg` to set background RGB colors. | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | _ | ||||||||||||||||||||||||||||
| 43 | items => { | ||||||||||||||||||||||||||||
| 44 | 0 | ▶ | border => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 45 | 0 | my ($self, $name, $args) = @_; | |||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | 0 | my $t = $args->{table}; | |||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | 0 | my $pct = ($t->{_draw}{y}+1) / $t->{_draw}{table_height}; | |||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | 0 | my $rgbf1 = $self->{args}{border1_fg}; | |||||||||||||||||||||||||||
| 52 | 0 | my $rgbf2 = $self->{args}{border2_fg}; | |||||||||||||||||||||||||||
| 53 | 0 | my $rgbf = mix_2_rgb_colors($rgbf1, $rgbf2, $pct); | |||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | 0 | my $rgbb1 = $self->{args}{border1_bg}; | |||||||||||||||||||||||||||
| 56 | 0 | my $rgbb2 = $self->{args}{border2_bg}; | |||||||||||||||||||||||||||
| 57 | 0 | my $rgbb; | |||||||||||||||||||||||||||
| 58 | 0 | ▶ | if ($rgbb1 && $rgbb2) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$rgbb1 and $rgbb2
MC/DC0%0/2
$rgbb1 and $rgbb2
$rgbb1
$rgbb2
Truth table0%0/3
A and B
A= $rgbb1B= $rgbb2
| |||||||||||||||||||||||||||||
| 59 | 0 | $rgbb = mix_2_rgb_colors($rgbb1, $rgbb2, $pct); | |||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | #say "D:$rgbf, $rgbb"; | ||||||||||||||||||||||||||||
| 63 | 0 | {fg=>$rgbf, bg=>$rgbb}; | |||||||||||||||||||||||||||
| 64 | }, | ||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | header => '808080', | ||||||||||||||||||||||||||||
| 67 | header_bg => undef, | ||||||||||||||||||||||||||||
| 68 | cell => undef, | ||||||||||||||||||||||||||||
| 69 | cell_bg => undef, | ||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | num_data => '66ffff', | ||||||||||||||||||||||||||||
| 72 | str_data => undef, | ||||||||||||||||||||||||||||
| 73 | date_data => 'aaaa00', | ||||||||||||||||||||||||||||
| 74 | 0 | ▶ | bool_data => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 75 | 0 | my ($self, $name, $args) = @_; | |||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | 0 | ▶ | $args->{orig_data} ? '00ff00' : 'ff0000'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 78 | }, | ||||||||||||||||||||||||||||
| 79 | }, | ||||||||||||||||||||||||||||
| 80 | 8 | ); | |||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | 8 | 1; | |||||||||||||||||||||||||||
| 83 | # ABSTRACT: Gradation border (for terminal with black background) | ||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | __END__ | ||||||||||||||||||||||||||||