Sophie

Sophie

distrib > Mageia > 7 > armv7hl > media > core-updates > by-pkgid > 63140a6e2a5fd71cef2e967ff26dba34 > files > 41

perl-PDF-Builder-3.21.0-1.mga7.noarch.rpm

#!/usr/bin/perl

# display a subset of possible HSV colors. 
# TBD: consider at least more Values pages (currently 8 and 10-15).

use strict;
use warnings;

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

#my $compress = 'none'; # uncompressed streams
my $compress = 'flate'; # compressed streams

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

my $pdf = PDF::Builder->new(-compress => $compress);
$pdf->mediabox(595,842);

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

# the 7 pages output are 7 levels of Value (why not anything less than 8?)
foreach my $v (0xf, 0xE, 0xd, 0xC, 0xb, 0xA, 0x8) {
    my $page = $pdf->page();
    my $gfx = $page->gfx();
    my $text = $page->text();
    
    $text->textlabel(300,750, $fnt,20, 'HSV Colorspace', -color=>'#000', -hscale=>125, -center=>1);

    $text->strokecolor('#000');
    foreach my $s (0 .. 0x7) {
        my $ha = $s/2;
        foreach my $h (0 .. (12*$ha)-1) {
		
            my $t = sprintf('&%02X%02X%02X', floor(256*$h/(12*$ha)), (($s*2)<<4|($s*2)), ($v<<4|$v));
            $gfx->fillcolor($t);
            $gfx->circle($cx+cos(deg2rad(360*$h/(12*$ha)))*$cs*$s,$cy+sin(deg2rad(360*$h/(12*$ha)))*$cs*$s, $cr);
            $gfx->fillstroke();
            $text->textlabel($cx+cos(deg2rad(360*$h/(12*$ha)))*$cs*$s,$cy-2+sin(deg2rad(360*$h/(12*$ha)))*$cs*$s, $fnt,6, $t, -color=>'#000', -hscale=>80, -center=>1);
        }
    }
}

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

exit;

__END__