File Coverage

blib/lib/FigAnim/Color.pm
Criterion Covered Total %
statement 6 21 28.5
branch n/a
condition 0 3 0.0
subroutine 2 5 40.0
pod n/a
total 8 29 27.5


line stmt bran cond sub pod time code
1             package Color;
2              
3             =head1 NAME
4              
5             Color - A XFig file animator class - Color object
6              
7             =head1 DESCRIPTION
8              
9             Color pseudo-object (user defined colors) - object code in FIG format: 0.
10             This is used to define arbitrary colors beyond the 32 standard colors.
11             Here are all the attributes of this class:
12              
13             B
14              
15             =head1 FIG ATTRIBUTES
16              
17             =over
18              
19             =item color_bumber
20              
21             color number, from 32-543 (512 total)
22              
23             The two color fields (pen and fill; pen only, for texts) are
24             defined as follows:
25              
26             -1: Default;
27             0: Black;
28             1: Blue;
29             2: Green;
30             3: Cyan;
31             4: Red;
32             5: Magenta;
33             6: Yellow;
34             7: White;
35             8..11: four shades of blue (dark to lighter);
36             12..14: three shades of green (dark to lighter);
37             15..17: three shades of cyan (dark to lighter);
38             18..20: three shades of red (dark to lighter);
39             21..23: three shades of magenta (dark to lighter);
40             24..26: three shades of brown (dark to lighter);
41             27..30: four shades of pink (dark to lighter);
42             31: Gold;
43             32..543 (512 total): user colors defined in color pseudo-objects (type 0).
44              
45             For White color, the area fill field is defined as follows:
46              
47             -1: not filled;
48             0: black;
49             1..19: shades of grey, from darker to lighter;
50             20: white;
51             21..40: not used;
52             41..56: see patterns for colors, below.
53              
54             For Black or Default color, the area fill field is defined as follows:
55              
56             -1: not filled;
57             0: white;
58             1..19: shades of grey, from lighter to darker;
59             20: black;
60             21..40: not used;
61             41..56: see patterns for colors, below.
62              
63             For all other colors, the area fill field is defined as follows:
64              
65             -1: not filled;
66             0: black;
67             1..19: "shades" of the color, from darker to lighter,
68             a shade is defined as the color mixed with black;
69             20: full saturation of the color;
70             21..39: "tints" of the color from the color to white,
71             a tint is defined as the color mixed with white;
72             40: white;
73             41: 30 degree left diagonal pattern;
74             42: 30 degree right diagonal pattern;
75             43: 30 degree crosshatch;
76             44: 45 degree left diagonal pattern;
77             45: 45 degree right diagonal pattern;
78             46: 45 degree crosshatch;
79             47: bricks;
80             48: circles;
81             49: horizontal lines;
82             50: vertical lines;
83             51: crosshatch;
84             52: fish scales;
85             53: small fish scales;
86             54: octagons;
87             55: horizontal "tire treads";
88             56: vertical "tire treads".
89              
90             =item rgb
91              
92             hex string rgb values:
93             hexadecimal string describing red, green and blue values (e.g. #330099)
94              
95             =back
96              
97             =cut
98              
99 1     1   9 use strict;
  1         2  
  1         31  
100 1     1   4 use warnings;
  1         1  
  1         221  
101              
102             # constructor
103             sub new {
104 0     0     my $proto = shift;
105 0   0       my $class = ref($proto) || $proto;
106 0           my $self = {};
107            
108             #$self->{object_code} = 0;
109 0           $self->{color_number} = shift;
110 0           $self->{rgb} = shift;
111            
112 0           bless ($self, $class);
113 0           return $self;
114             }
115              
116              
117             # methods
118             sub clone {
119 0     0     my $self = shift;
120 0           my $obj = new Color;
121 0           $obj->{$_} = $self->{$_} foreach (keys %{$self});
  0            
122 0           return $obj;
123             }
124              
125             sub output {
126 0     0     my $self = shift;
127 0           my $fh = shift;
128            
129 0           printf $fh "0 %d %s\n", @$self{'color_number','rgb'};
130             }
131              
132             1;