File: 030_colorspecs

package info (click to toggle)
libpdf-api2-perl 2.019-1%2Bdeb7u1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 20,264 kB
  • sloc: perl: 42,313; sh: 23; makefile: 9
file content (125 lines) | stat: -rw-r--r-- 3,362 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#!/usr/bin/perl

use PDF::API2;
use PDF::API2::Util;
use POSIX;
use Math::Trig;

my $cx=315;
my $cy=400;
my $cr=15;
my $cs=32;
my $ang=30;

$pdf=PDF::API2->new;
$pdf->mediabox(595,842);

$fnt=$pdf->corefont('Verdana-Bold');

foreach my $z (0 .. 0xf) {
    $page = $pdf->page;
    $gfx=$page->gfx;
    
    $gfx->textlabel(300,750,$fnt,20,'RGB Colorspace',-color=>'#000',-hspace=>125,-center=>1);

    $gfx->strokecolor('#000');

    foreach my $x (0 .. 0xf) {
        foreach my $y (0 .. 0xf) {
            my $t=sprintf('#%01X%01X%01X',$x,$z,$y);
            $gfx->fillcolor($t);
            $gfx->circle($cx+($x-8)*$cs,$cy+($y-8)*$cs,$cr);
            $gfx->fillstroke;
            $gfx->textlabel($cx+($x-8)*$cs,$cy+($y-8)*$cs,$fnt,8,$t,-color=>'#000',-rotate=>$ang,-hspace=>85,-center=>1);
        }
    }
}

foreach my $z (0 .. 0xf) {
    $page = $pdf->page;
    $gfx=$page->gfx;
    
    $gfx->textlabel(300,750,$fnt,20,'RGB Colorspace (Gamma=2.2)',-color=>'#000',-hspace=>125,-center=>1);

    $gfx->strokecolor('#000');

    foreach my $x (0 .. 0xf) {
        foreach my $y (0 .. 0xf) {
            my $t=sprintf('#%01X%01X%01X',$x,$z,$y);
            $gfx->fillcolor($x/0xf,$z/0xf,$y/0xf);
            $gfx->circle($cx+($x-8)*$cs,$cy+($y-8)*$cs,$cr);
            $gfx->fillstroke;
            $gfx->textlabel($cx+($x-8)*$cs,$cy+($y-8)*$cs,$fnt,8,$t,-color=>'#000',-rotate=>$ang,-hspace=>85,-center=>1);
        }
    }
}

foreach my $z (0 .. 0xf) {
    $page = $pdf->page;
    $gfx=$page->gfx;
    
    $gfx->textlabel(300,750,$fnt,20,'CMYK Colorspace',-color=>'#000',-hspace=>125,-center=>1);

    $gfx->strokecolor('#000');

    foreach my $x (0 .. 0xf) {
        foreach my $y (0 .. 0xf) {
            my $t=sprintf('%%%01X%01X%01X0',$x,$z,$y);
            $gfx->fillcolor($t);
            $gfx->circle($cx+($x-8)*$cs,$cy+($y-8)*$cs,$cr);
            $gfx->fillstroke;
            $gfx->textlabel($cx+($x-8)*$cs,$cy+($y-8)*$cs,$fnt,8,$t,-color=>'#000',-rotate=>$ang,-hspace=>85,-center=>1);
        }
    }
}

foreach my $z (0 .. 0xf) {
    $page = $pdf->page;
    $gfx=$page->gfx;
    
    $gfx->textlabel(300,750,$fnt,20,'Lab Colorspace',-color=>'#000',-hspace=>125,-center=>1);

    $gfx->strokecolor('#000');

    foreach my $x (0 .. 0xf) {
        foreach my $y (0 .. 0xf) {
            my $t=sprintf('$%01X%01X%01X',$z,$x,$y);
            $gfx->fillcolor($t);
            $gfx->circle($cx+($x-8)*$cs,$cy+($y-8)*$cs,$cr);
            $gfx->fillstroke;
            $gfx->textlabel($cx+($x-8)*$cs,$cy+($y-8)*$cs,$fnt,8,$t,-color=>'#000',-rotate=>$ang,-hspace=>85,-center=>1);
        }
    }
}

my @cols=sort keys %PDF::API2::Util::colors;

while (scalar @cols > 0) {
    $page = $pdf->page;
    $gfx=$page->gfx;
    
    $gfx->textlabel(300,750,$fnt,20,'Named Colors (RGB)',-color=>'#000',-hspace=>125,-center=>1);

    $gfx->strokecolor('#000');

    foreach my $x (0 .. 0xf) {
        last if(scalar @cols == 0);
        foreach my $y (0 .. 0xf) { 
            last if(scalar @cols == 0);
            my $t=shift @cols;
            $gfx->fillcolor($t);
            $gfx->circle($cx+($x-8)*$cs,$cy+($y-8)*$cs,$cr);
            $gfx->fillstroke;
            $gfx->textlabel($cx+($x-8)*$cs,$cy+($y-8)*$cs,$fnt,7,$t,-color=>'#000',-rotate=>$ang,-hspace=>85,-center=>1);
        }
    }
}

$pdf->saveas("$0.pdf");
$pdf->end();

exit;

__END__