| 1 | package ColorTheme::Lens::Lighten; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 1 | our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY | |||||||||||||||||||||||||||
| 4 | 1 | our $DATE = '2020-06-19'; # DATE | |||||||||||||||||||||||||||
| 5 | 1 | our $DIST = 'ColorTheme-Lens-Lighten'; # DIST | |||||||||||||||||||||||||||
| 6 | 1 | our $VERSION = '0.002'; # VERSION | |||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use parent 'ColorThemeBase::Base'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 1 | our %THEME = ( | |||||||||||||||||||||||||||
| 13 | v => 2, | ||||||||||||||||||||||||||||
| 14 | summary => 'Lighten other theme', | ||||||||||||||||||||||||||||
| 15 | dynamic => 1, | ||||||||||||||||||||||||||||
| 16 | args => { | ||||||||||||||||||||||||||||
| 17 | theme => { | ||||||||||||||||||||||||||||
| 18 | schema => 'perl::modname_with_args', | ||||||||||||||||||||||||||||
| 19 | req => 1, | ||||||||||||||||||||||||||||
| 20 | pos => 0, | ||||||||||||||||||||||||||||
| 21 | }, | ||||||||||||||||||||||||||||
| 22 | percent => { | ||||||||||||||||||||||||||||
| 23 | schema => ['num*', between=>[0, 100]], | ||||||||||||||||||||||||||||
| 24 | default => 50, | ||||||||||||||||||||||||||||
| 25 | }, | ||||||||||||||||||||||||||||
| 26 | }, | ||||||||||||||||||||||||||||
| 27 | examples => [ | ||||||||||||||||||||||||||||
| 28 | { | ||||||||||||||||||||||||||||
| 29 | summary => 'Lighten another color theme', | ||||||||||||||||||||||||||||
| 30 | args => {theme => 'Test::Static'}, | ||||||||||||||||||||||||||||
| 31 | }, | ||||||||||||||||||||||||||||
| 32 | ], | ||||||||||||||||||||||||||||
| 33 | ); | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 36 | 0 | my $class = shift; | |||||||||||||||||||||||||||
| 37 | 0 | my %args = @_; | |||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 0 | my $self = $class->SUPER::new(%args); | |||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | 0 | require Module::Load::Util; | |||||||||||||||||||||||||||
| 42 | $self->{orig_theme_class} = Module::Load::Util::instantiate_class_with_optional_args( | ||||||||||||||||||||||||||||
| 43 | 0 | {ns_prefix=>'ColorTheme'}, $self->{args}{theme}); | |||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | 0 | $self; | |||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 0 | ▶ | sub list_items { | ||||||||||||||||||||||||||
|
Subroutine
list_items: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 49 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | # return the same list of items as the original theme | ||||||||||||||||||||||||||||
| 52 | 0 | $self->{orig_theme_class}->list_items; | |||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | 0 | ▶ | sub get_item_color { | ||||||||||||||||||||||||||
|
Subroutine
get_item_color: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||
| 56 | 0 | require Color::RGB::Util; | |||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | 0 | my $color = $self->{orig_theme_class}->get_item_color(@_); | |||||||||||||||||||||||||||
| 61 | 0 | ▶ | $color = {%{$color}} if ref $color eq 'HASH'; # shallow copy | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | 0 | ▶ | if (!ref $color) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 64 | 0 | $color = Color::RGB::Util::mix_2_rgb_colors($color, 'ffffff', $self->{args}{percent}/100); | |||||||||||||||||||||||||||
| 65 | } else { # assume hash | ||||||||||||||||||||||||||||
| 66 | 0 | ▶ | $color->{fg} = Color::RGB::Util::mix_2_rgb_colors($color->{fg}, 'ffffff', $self->{args}{percent}/100) if defined $color->{fg} && length $color->{fg}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $color->{"fg"} and length $color->{"fg"}
MC/DC0%0/2
defined $color->{"fg"} and length $color->{"fg"}
defined $color->{"fg"}
length $color->{"fg"}
Truth table0%0/3
A and B
A= defined $color->{"fg"}B= length $color->{"fg"}
| |||||||||||||||||||||||||||||
| 67 | 0 | ▶ | $color->{bg} = Color::RGB::Util::mix_2_rgb_colors($color->{bg}, 'ffffff', $self->{args}{percent}/100) if defined $color->{bg} && length $color->{bg}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $color->{"bg"} and length $color->{"bg"}
MC/DC0%0/2
defined $color->{"bg"} and length $color->{"bg"}
defined $color->{"bg"}
length $color->{"bg"}
Truth table0%0/3
A and B
A= defined $color->{"bg"}B= length $color->{"bg"}
| |||||||||||||||||||||||||||||
| 68 | # can't mix ansi_fg, ansi_bg | ||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||
| 70 | 0 | $color; | |||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | 1 | 1; | |||||||||||||||||||||||||||
| 74 | # ABSTRACT: Lighten other theme | ||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | __END__ | ||||||||||||||||||||||||||||