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

filter: Statementstmt 0.0% 0 / 29 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 10 Podpod 0.0% 0 / 5 totaltotal 0.0% 0 / 44 CC 1 SCAR 6.9
CC
1
Cov
0%
cmy
2.0
rgb
2.0
hsb
2.0
CRAP 2.0
1 # /=====================================================================\ #
2 # | LaTeXML::Common::Color::cmy | #
3 # | A representation of colors in the cmy color model | #
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::cmy;
13 use strict;
14 use warnings;
15 use base qw(LaTeXML::Common::Color);
16 use LaTeXML::Global;
17 use List::Util qw(min max);
18  
19 sub cmy {
20 my ($self) = @_;
21 return $self; }
22  
23 sub rgb {
24 my ($self) = @_;
25 return LaTeXML::Common::Color->new('rgb', 1 - $$self[1], 1 - $$self[2], 1 - $$self[3]); }
26  
27 sub hsb {
28 my ($self) = @_;
29 return $self->rgb->hsb; }
30  
31 sub gray {
32 my ($self) = @_;
33 return LaTeXML::Common::Color->new('gray', 1 - (0.3 * $$self[1] + 0.59 * $$self[2] + 0.11 * $$self[3])); }
34  
35 sub cmyk {
36 my ($self) = @_;
37 my ($model, $c, $m, $y) = @$self;
38 # These beta parameters are linear coefficients for "undercolor-removal", and "black-generation"
39 # In xcolor, they could come from \adjustUCRBG
40 my ($bc, $bm, $by, $bk) = (1, 1, 1, 1);
41 my $k = min($c, min($m, $y));
42 return LaTeXML::Common::Color->new('cmyk', min(1, max(0, $c - $bc * $k)),
43 min(1, max(0, $m - $bm * $k)),
44 min(1, max(0, $y - $by * $k)),
45 $bk * $k); }
46  
47 #======================================================================
48 1;
49  
50 __END__