Mercurial > repos > cpt > cpt_psm_recombine
comparison lib/CPT/Plot/ArtemisColours.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::ArtemisColours; | |
2 use Moose; | |
3 use strict; | |
4 use warnings; | |
5 use Carp; | |
6 | |
7 has format => ( | |
8 is => 'rw', | |
9 isa => 'Str', | |
10 default => sub { | |
11 'svg/rgb' | |
12 }, | |
13 ); | |
14 | |
15 my %artemis_colours = ( | |
16 0 => [ 255, 255, 255 ], | |
17 1 => [ 100, 100, 100 ], | |
18 2 => [ 255, 0, 0 ], | |
19 3 => [ 0, 255, 0 ], | |
20 4 => [ 0, 0, 255 ], | |
21 5 => [ 0, 255, 255 ], | |
22 6 => [ 255, 0, 255 ], | |
23 7 => [ 255, 255, 0 ], | |
24 8 => [ 152, 251, 152 ], | |
25 9 => [ 135, 206, 250 ], | |
26 10 => [ 255, 165, 0 ], | |
27 11 => [ 200, 150, 100 ], | |
28 12 => [ 255, 200, 200 ], | |
29 13 => [ 170, 170, 170 ], | |
30 14 => [ 0, 0, 0 ], | |
31 15 => [ 255, 63, 63 ], | |
32 16 => [ 255, 127, 127 ], | |
33 17 => [ 255, 191, 191 ], | |
34 ); | |
35 | |
36 sub getAvailableFormats { | |
37 my ($self) = @_; | |
38 return [ 'svg/rgb', 'artemis' ]; | |
39 } | |
40 | |
41 sub getColour { | |
42 my ( $self, $string ) = @_; | |
43 if ($string) { | |
44 my @rgb; | |
45 if ( $string =~ qr/^\s*(\d+)\s*$/ ) { | |
46 @rgb = @{ $artemis_colours{$1} }; | |
47 } | |
48 elsif ( $string =~ qr/^\s*(\d+)\s+(\d+)\s+(\d+)\s*$/ ) { | |
49 @rgb = ( $1, $2, $3 ); | |
50 } | |
51 else { | |
52 confess "Bad Colour Specfication [$string]"; | |
53 return; | |
54 } | |
55 | |
56 # return $colour_result; | |
57 my $format = $self->format(); | |
58 if ( $format eq 'svg/rgb' ) { | |
59 return 'rgb(' . join( ',', @rgb ) . ')'; | |
60 } | |
61 elsif ( $format eq 'artemis' ) { | |
62 return join( ' ', @rgb ); | |
63 } | |
64 else { | |
65 carp "Bad format specified, or format not added to spec list [$format]"; | |
66 } | |
67 } | |
68 else { | |
69 return; | |
70 } | |
71 } | |
72 | |
73 no Moose; | |
74 1; | |
75 | |
76 __END__ | |
77 | |
78 =pod | |
79 | |
80 =encoding UTF-8 | |
81 | |
82 =head1 NAME | |
83 | |
84 CPT::Plot::ArtemisColours | |
85 | |
86 =head1 VERSION | |
87 | |
88 version 1.99.4 | |
89 | |
90 =head1 AUTHOR | |
91 | |
92 Eric Rasche <rasche.eric@yandex.ru> | |
93 | |
94 =head1 COPYRIGHT AND LICENSE | |
95 | |
96 This software is Copyright (c) 2014 by Eric Rasche. | |
97 | |
98 This is free software, licensed under: | |
99 | |
100 The GNU General Public License, Version 3, June 2007 | |
101 | |
102 =cut |