comparison lib/CPT/Plot/Colours.pm @ 1:97ef96676b48 draft

planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
author cpt
date Mon, 05 Jun 2023 02:51:26 +0000
parents
children
comparison
equal deleted inserted replaced
0:b18e8268bf4e 1:97ef96676b48
1 package CPT::Plot::Colours;
2
3 # ABSTRACT: Color transformation library.
4
5 our %artemis_colours = (
6 0 => 'rgb(255,255,255)',
7 1 => 'rgb(100,100,100)',
8 2 => 'rgb(255,0,0)',
9 3 => 'rgb(0,255,0)',
10 4 => 'rgb(0,0,255)',
11 5 => 'rgb(0,255,255)',
12 6 => 'rgb(255,0,255)',
13 7 => 'rgb(255,255,0)',
14 8 => 'rgb(152,251,152)',
15 9 => 'rgb(135,206,250)',
16 10 => 'rgb(255,165,0)',
17 11 => 'rgb(200,150,100)',
18 12 => 'rgb(255,200,200)',
19 13 => 'rgb(170,170,170)',
20 14 => 'rgb(0,0,0)',
21 15 => 'rgb(255,63,63)',
22 16 => 'rgb(255,127,127)',
23 17 => 'rgb(255,191,191)',
24 );
25
26 sub new {
27 my $class = shift;
28 my $self = {@_};
29 bless $self, $class;
30 return $self;
31 }
32
33 sub getColour {
34 my ( $self, $string ) = @_;
35 if ($string) {
36 my $colour_result;
37 if ( $string =~ qr/^\s*(\d+)\s*$/ ) {
38 $colour_result = $artemis_colours{$1};
39 }
40 elsif ( $string =~ qr/^\s*(\d+)\s+(\d+)\s+(\d+)\s*$/ ) {
41 $colour_result = "rgb($1,$2,$3)";
42 }
43 else {
44 warn "Bad Colour Specfication";
45 return undef;
46 }
47 return $colour_result;
48 }
49 else {
50 return undef;
51 }
52 }
53
54 1;
55
56 __END__
57
58 =pod
59
60 =encoding UTF-8
61
62 =head1 NAME
63
64 CPT::Plot::Colours - Color transformation library.
65
66 =head1 VERSION
67
68 version 1.96
69
70 =head1 AUTHOR
71
72 Eric Rasche <rasche.eric@yandex.ru>
73
74 =head1 COPYRIGHT AND LICENSE
75
76 This software is Copyright (c) 2014 by Eric Rasche.
77
78 This is free software, licensed under:
79
80 The GNU General Public License, Version 3, June 2007
81
82 =cut