| 1 | package PDF::Builder::Resource::ColorSpace::Indexed::WebColor; | ||||||||||
| 2 | |||||||||||
| 3 | 2 | ▶ | use base 'PDF::Builder::Resource::ColorSpace::Indexed'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | |||||||||||
| 5 | 2 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 2 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 2 | our $VERSION = '3.028'; # VERSION | |||||||||
| 9 | 2 | our $LAST_UPDATE = '3.027'; # manually update whenever code is changed | |||||||||
| 10 | |||||||||||
| 11 | =head1 NAME | ||||||||||
| 12 | |||||||||||
| 13 | PDF::Builder::Resource::ColorSpace::Indexed::WebColor - Colorspace support for "Web Safe" Device RGB colors | ||||||||||
| 14 | |||||||||||
| 15 | Inherits from L<PDF::Builder::Resource::ColorSpace::Indexed> | ||||||||||
| 16 | |||||||||||
| 17 | =cut | ||||||||||
| 18 | |||||||||||
| 19 | 2 | ▶ | use PDF::Builder::Basic::PDF::Utils; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 20 | 2 | ▶ | use PDF::Builder::Util; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 21 | 2 | ▶ | use Scalar::Util qw(weaken); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 22 | |||||||||||
| 23 | =head1 METHODS | ||||||||||
| 24 | |||||||||||
| 25 | =head2 new | ||||||||||
| 26 | |||||||||||
| 27 | PDF::Builder::Resource::ColorSpace::Indexed::WebColor->new() | ||||||||||
| 28 | |||||||||||
| 29 | =over | ||||||||||
| 30 | |||||||||||
| 31 | Create a new "web-safe" indexed colorspace object. | ||||||||||
| 32 | |||||||||||
| 33 | =back | ||||||||||
| 34 | |||||||||||
| 35 | =cut | ||||||||||
| 36 | |||||||||||
| 37 | 1 | ▶ | sub new { | ||||||||
|
Subroutine
new: called CC=9 SCAR=22.0
Pod
documented
| |||||||||||
| 38 | 1 | my ($class, $pdf) = @_; | |||||||||
| 39 | |||||||||||
| 40 | 1 | ▶ | $class = ref($class) if ref($class); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 41 | 1 | my $self = $class->SUPER::new($pdf, pdfkey()); | |||||||||
| 42 | 1 | ▶ | $pdf->new_obj($self) unless $self->is_obj($pdf); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 43 | 1 | $self->{' apipdf'} = $pdf; | |||||||||
| 44 | 1 | weaken $self->{' apipdf'}; | |||||||||
| 45 | |||||||||||
| 46 | 1 | my $csd = PDFDict(); | |||||||||
| 47 | 1 | $pdf->new_obj($csd); | |||||||||
| 48 | 1 | $csd->{'Filter'} = PDFArray(PDFName('ASCIIHexDecode')); | |||||||||
| 49 | #$csd->{'WhitePoint'} = PDFArray(map {PDFNum($_)} (0.95049, 1, 1.08897)); | ||||||||||
| 50 | #$csd->{'BlackPoint'} = PDFArray(map {PDFNum($_)} (0, 0, 0)); | ||||||||||
| 51 | #$csd->{'Gamma'} = PDFArray(map {PDFNum($_)} (2.22218, 2.22218, 2.22218)); | ||||||||||
| 52 | 1 | $csd->{' stream'} = ''; | |||||||||
| 53 | |||||||||||
| 54 | # 0-215 | ||||||||||
| 55 | 1 | foreach my $r (0,0x33,0x66,0x99,0xCC,0xFF) { | |||||||||
| 56 | 6 | foreach my $g (0,0x33,0x66,0x99,0xCC,0xFF) { | |||||||||
| 57 | 36 | foreach my $b (0,0x33,0x66,0x99,0xCC,0xFF) { | |||||||||
| 58 | 216 | $csd->{' stream'} .= pack('CCC', $r,$g,$b); | |||||||||
| 59 | } | ||||||||||
| 60 | } | ||||||||||
| 61 | } | ||||||||||
| 62 | |||||||||||
| 63 | # 216-231 | ||||||||||
| 64 | 1 | foreach my $r (0,0x11,0x22,0x33,0x44,0x55,0x66,0x77, | |||||||||
| 65 | 0x88,0x99,0xAA,0xBB,0xCC,0xDD,0xEE,0xFF) { | ||||||||||
| 66 | 16 | $csd->{' stream'} .= pack('CCC', $r,$r,$r); | |||||||||
| 67 | } | ||||||||||
| 68 | |||||||||||
| 69 | # 232-247 | ||||||||||
| 70 | 1 | foreach my $r (0,0x11,0x22,0x33,0x44,0x55,0x66,0x77, | |||||||||
| 71 | 0x88,0x99,0xAA,0xBB,0xCC,0xDD,0xEE,0xFF) { | ||||||||||
| 72 | $csd->{' stream'} .= pack('CCC', | ||||||||||
| 73 | 16 | map { $_*255 } | |||||||||
| 74 | namecolor('!'.sprintf('%02X', $r).'FFFF')); | ||||||||||
| 75 | } | ||||||||||
| 76 | |||||||||||
| 77 | # 248-255 | ||||||||||
| 78 | 1 | foreach my $r (0,0x22,0x44,0x66,0x88,0xAA,0xCC,0xEE) { | |||||||||
| 79 | $csd->{' stream'} .= pack('CCC', | ||||||||||
| 80 | 8 | map { $_*255 } | |||||||||
| 81 | namecolor('!'.sprintf('%02X', $r).'FF99')); | ||||||||||
| 82 | } | ||||||||||
| 83 | |||||||||||
| 84 | 1 | $csd->{' stream'} .= "\x00" x 768; | |||||||||
| 85 | 1 | $csd->{' stream'} = substr($csd->{' stream'}, 0, 768); | |||||||||
| 86 | |||||||||||
| 87 | 1 | $self->add_elements(PDFName('DeviceRGB'), PDFNum(255), $csd); | |||||||||
| 88 | 1 | $self->{' csd'} = $csd; | |||||||||
| 89 | |||||||||||
| 90 | 1 | return $self; | |||||||||
| 91 | } | ||||||||||
| 92 | |||||||||||
| 93 | 2 | 1; | |||||||||