#!/usr/bin/perl
my
$compress
=
'flate'
;
my
$cx
= 315;
my
$cy
= 400;
my
$cr
= 15;
my
$cs
= 32;
my
$ang
= 30;
my
$pdf
= PDF::Builder->new(
-compress
=>
$compress
);
my
@doSect
= (1, 1, 1, 1, 1);
$pdf
->mediabox(595,842);
my
$fnt
=
$pdf
->corefont(
'Verdana-Bold'
);
my
(
$page
,
$gfx
,
$text
);
if
(
$doSect
[0]) {
print
STDERR
"RGB colorspace (16 pages) "
;
foreach
my
$z
(0 .. 0xf) {
print
STDERR
"."
;
$page
=
$pdf
->page();
$gfx
=
$page
->gfx();
$text
=
$page
->text();
$text
->linewidth(0);
$text
->render(2);
$text
->textlabel(300,750,
$fnt
, 20,
'RGB Colorspace'
,
-color
=>
'#000'
,
-hscale
=>125,
-center
=>1);
$text
->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();
$text
->textlabel(
$cx
+(
$x
-8)
*$cs
+2,
$cy
+(
$y
-8)
*$cs
-2,
$fnt
,8,
$t
,
-color
=>
'#000'
,
-strokecolor
=>
'#FFF'
,
-rotate
=>
$ang
,
-hscale
=>85,
-center
=>1);
}
}
}
print
STDERR
"\n"
;
}
if
(
$doSect
[1]) {
print
STDERR
"RGB colorspace with Gamma 2.2 (16 pages) "
;
foreach
my
$z
(0 .. 0xf) {
print
STDERR
"."
;
$page
=
$pdf
->page();
$gfx
=
$page
->gfx();
$text
=
$page
->text();
$text
->linewidth(0);
$text
->render(2);
$text
->textlabel(300,750,
$fnt
, 20,
'RGB Colorspace (Gamma=2.2)'
,
-color
=>
'#000'
,
-hscale
=>125,
-center
=>1);
$text
->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();
$text
->textlabel(
$cx
+(
$x
-8)
*$cs
+2,
$cy
+(
$y
-8)
*$cs
-2,
$fnt
,8,
$t
,
-color
=>
'#000'
,
-strokecolor
=>
'#FFF'
,
-rotate
=>
$ang
,
-hscale
=>85,
-center
=>1);
}
}
}
print
STDERR
"\n"
;
}
if
(
$doSect
[2]) {
print
STDERR
"CMYK colorspace (16 pages) "
;
foreach
my
$z
(0 .. 0xf) {
print
STDERR
"."
;
$page
=
$pdf
->page();
$gfx
=
$page
->gfx();
$text
=
$page
->text();
$text
->linewidth(0);
$text
->render(2);
$text
->textlabel(300,750,
$fnt
,20,
'CMYK Colorspace'
,
-color
=>
'#000'
,
-hscale
=>125,
-center
=>1);
$text
->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();
$text
->textlabel(
$cx
+(
$x
-8)
*$cs
+2,
$cy
+(
$y
-8)
*$cs
-2,
$fnt
,8,
$t
,
-color
=>
'#000'
,
-strokecolor
=>
'#FFF'
,
-rotate
=>
$ang
,
-hscale
=>85,
-center
=>1);
}
}
}
print
STDERR
"\n"
;
}
if
(
$doSect
[3]) {
print
STDERR
"L*a*b colorspace (16 pages) "
;
foreach
my
$z
(0 .. 0xf) {
print
STDERR
"."
;
$page
=
$pdf
->page();
$gfx
=
$page
->gfx();
$text
=
$page
->text();
$text
->linewidth(0);
$text
->render(2);
$text
->textlabel(300,750,
$fnt
,20,
'Lab Colorspace'
,
-color
=>
'#000'
,
-hscale
=>125,
-center
=>1);
$text
->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();
$text
->textlabel(
$cx
+(
$x
-8)
*$cs
+2,
$cy
+(
$y
-8)
*$cs
-2,
$fnt
,8,
$t
,
-color
=>
'#000'
,
-strokecolor
=>
'#FFF'
,
-rotate
=>
$ang
,
-hscale
=>85,
-center
=>1);
}
}
}
print
STDERR
"\n"
;
}
if
(
$doSect
[4]) {
print
STDERR
"named colors (RGB colorspace) "
;
my
@cols
=
sort
keys
%PDF::Builder::Util::colors
;
foreach
my
$base
(
'gray'
,
'grey'
) {
my
$start
= 0;
my
$end
= -1;
my
(
$i
,
$j
);
for
(
$i
=0;
$i
<
scalar
@cols
;
$i
++) {
next
unless
$cols
[
$i
] =~ m/^
$base
\d+$/;
if
(
$end
<
$start
) {
$start
=
$end
=
$i
; }
else
{
$end
=
$i
; }
}
$j
=0;
for
(
$i
=
$start
;
$i
<=
$end
;
$i
++) {
$cols
[
$i
] =
$base
.
$j
;
$j
++;
}
}
while
(
scalar
@cols
> 0) {
print
STDERR
"."
;
$page
=
$pdf
->page();
$gfx
=
$page
->gfx();
$text
=
$page
->text();
$text
->linewidth(0);
$text
->render(2);
$text
->textlabel(300,750,
$fnt
,20,
'Named Colors (RGB)'
,
-color
=>
'#000'
,
-hscale
=>125,
-center
=>1);
$text
->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();
$text
->textlabel(
$cx
+(
$x
-8)
*$cs
+2,
$cy
+(
$y
-8)
*$cs
-2,
$fnt
,7,
$t
,
-color
=>
'#000'
,
-strokecolor
=>
'#FFF'
,
-rotate
=>
$ang
,
-hscale
=>85,
-center
=>1);
}
}
}
print
STDERR
"\n"
;
}
$pdf
->saveas(
"$0.pdf"
);
$pdf
->end();
exit
;