lib/LaTeXML/Common/Color/Derived.pm untested

filter: Statementstmt 0.0% 0 / 38 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 12 Podpod 0.0% 0 / 6 totaltotal 0.0% 0 / 58 CC 2 SCAR 9.6
CC
2
Cov
0%
toCore
6.0
rgb
2.0
cmy
2.0
CRAP 2.6
1 # /=====================================================================\ #
2 # | LaTeXML::Common::Color::Derived | #
3 # | A representation of colors in color models derived from core | #
4 # |=====================================================================| #
5 # | Part of LaTeXML: | #
6 # | Public domain software, produced as part of work done by the | #
7 # | United States Government & not subject to copyright in the US. | #
8 # |---------------------------------------------------------------------| #
9 # | Bruce Miller <bruce.miller@nist.gov> #_# | #
10 # | http://dlmf.nist.gov/LaTeXML/ (o o) | #
11 # \=========================================================ooo==U==ooo=/ #
12 package LaTeXML::Common::Color::Derived;
13 use strict;
14 use warnings;
15 use LaTeXML::Common::Color;
16 use base qw(LaTeXML::Common::Color);
17 use LaTeXML::Global;
18 use LaTeXML::Common::Error;
19  
20 # Convert this derived color to one of the Core colors
21 # Subclasses of this color need to set the variable:
22 # derived_color_model_<name> => [$coremodel, &convertto($self), &convertfrom($core) ]
23 # $coremodel is the core model class name associated with this color model
24 # &convertto($self) converts an instance of the derived model to the core color
25 # &convertfrom($core) converts an instance od the core model to the derived color
26 sub toCore {
27 my ($self) = @_;
28 my $model = $$self[0];
29 if (my $data = $STATE->lookupValue('derived_color_model_' . $model)) {
30 my $convertto = $$data[1];
31 return &{$convertto}($self); }
32 else {
33 Error('unexpected', $self->model, undef, "Color is not in valid model '$model'");
34 return Black; } }
35  
36 sub rgb { my ($self) = @_; return $self->convert('rgb'); }
37 sub cmy { my ($self) = @_; return $self->convert('cmy'); }
38 sub cmyk { my ($self) = @_; return $self->convert('cmyk'); }
39 sub hsb { my ($self) = @_; return $self->convert('hsb'); }
40 sub gray { my ($self) = @_; return $self->convert('gray'); }
41  
42 #======================================================================
43 1;
44  
45 __END__