<?
// graphicsPDF testing
define('FPDF_FONTPATH''tfpdf_fonts/');
require_once(
'tfpdf.php');
require_once(
'GraphicsPDF.php');

$pdf = new GraphicsPDF('P''in''letter');
$pdf->SetDisplayMode('default');
$pdf->SetCompression(isset($_GET['debug'])); // so we can examine the output

$pdf->AddPage();
$pdf->SetFont('Helvetica'''12);
$pdf->Cell(0,0,'Text and Image Placement');

$pdf->Text(1.51'Rotating Text');
$pdf->SetFont('Helvetica'''30);
$count 6;
for (
$i 1$i <= $count; ++$i){
    
$pdf->SetTextColor(255*$i/$count);
    
$pdf->Text(2.1252.75'Hello, World'M_TAU*$i/$count); // M_TAU is defined in GraphicsPDF.php as 2 pi (one complete revolution)
}

$pdf->SetFont('Helvetica'''12);
$pdf->SetTextColor(0);
$pdf->Text(4.51'Image (placed by top left corner)');
$pdf->Text(4.51.2' vs. PlaceImage (placed by center)');
$pdf->Image(dirname(__FILE__).'/smiley.png'6.3752.75);
$pdf->PlaceImage(dirname(__FILE__).'/smiley.png'6.3752.75);
$pdf->SetDrawColor(1250030);
$pdf->SetLineWidth(0.1);
$pdf->Line (6.25,2.6256.5,2.875);
$pdf->Line (6.25,2.8756.5,2.625);

$pdf->Text(.56'Rotating Rect (around top left)');
$pdf->Text(.56.2'Rotating Images (around center)');
$pdf->SetFillColor(25500);
$pdf->Rect(2.12510.542'F'deg2rad(135));
$pdf->Arc(2.12510.5.2);
$count 3;
for (
$i 0$i $count; ++$i){
    
$pdf->PlaceImage(dirname(__FILE__).'/smiley2.png'2.1258.2500M_TAU*$i/$count);
}

$pdf->Text(66'Path Operations');
$pdf->SetDrawColor(02550);
$pdf->SetLineWidth(0.125);
$pdf->MoveTo(4.255.5);
$pdf->LineTo(5.256.5);
$pdf->CurveTo(6.257.56.57.57.56.5);
$pdf->LineTo(8.55.5);
$pdf->DrawPath();
$pdf->MoveTo(4.58.5);
$pdf->CurveTo(4.510.57.510.57.58.5);
$pdf->CurveTo(4.58.54.510.57.510.5);
$pdf->CurveTo(7.58.54.58.54.510.5);
$pdf->CurveTo(7.510.57.58.54.58.5);
$pdf->ClosePath();
$pdf->DrawPath('DF');

$pdf->AddPage();
$pdf->Text(.51'Wedges and Ellipses');
$pdf->SetFillColor(200);
$pdf->Arc(4.1252.752.75'F'M_TAU/12M_TAU/30);
$pdf->Arc(4.252.52.75'F'M_TAU/120M_TAU/3);
$pdf->SetFillColor(255,0,0);
$pdf->Arc(2.1252.751NULL'F'0M_TAU/3, -M_TAU/3);
$pdf->SetFillColor(0,0,255);
$pdf->Arc(2.1252.751NULL'F'0, -M_TAU/30);
$pdf->SetFillColor(0,2550);
$pdf->Arc(2.3752.51NULL'F'00M_TAU/3);

$pdf->Text(0.54.25'Transparency in images and drawing');
$pdf->Image (dirname(__FILE__).'/stlouis.png'.54.5);
$dice imagecreatefrompng(dirname(__FILE__).'/dice.png');
$pdf->Image ($dice15.5);
$gecko imagecreatefrompng(dirname(__FILE__).'/shadowmaker-gecko.png');
$pdf->Image ($gecko4.257.25);
$pdf->SetDrawColor (12012025560);
$pdf->SetFillColor (17523823880);
$pdf->Rect(67.522'DF');

$pdf->AddPage();
$pdf->SetDrawColor (120120255);
$pdf->SetFillColor (175238238);
$pdf->SetLineWidth(0.01);
$size 0.25;
for (
$row 2$row 20; ++$row){
    for (
$col 0$col < ($row-1)/2; ++$col){
        
$pdf->Polygon(1+(2*$size+.1)*$col$size+(2*$size+.1)*($row-2), $row$sizeNULL'DF'$col+1);
    }
}
for (
$row 2$row 20; ++$row){
    for (
$col 0$col $row/2; ++$col){
        
$pdf->Cloverleaf(7.5-(2*$size+.1)*$col2*$size+(2*$size+.1)*(19-$row), $row$sizeNULL'D'$col+1);
    }
}
$pdf->SetTextColor(0);
$pdf->Text(0.56'Polygons and Cloverleafs'M_TAU/4);

// colors and dimensions from http://en.wikipedia.org/wiki/Flag_of_the_United_States
// a white five-pointed star
$pdf->OpenImage('star'11);
$pdf->SetFillColor(255255255); 
$pdf->Polygon(0.50.55.5NULL'F'2M_TAU/4);
$pdf->CloseImage();
// "Old Glory" blue field
$pdf->OpenImage('starfield'0.760.5385);
$pdf->SetFillColor(59.6759.415109.65);
$pdf->Rect(00,  0.760.5385'F');
for (
$row =0$row 9; ++$row){
    
$nstars $row 6;
    
$start $row 0.1266 0.0633;
    for (
$col 0$col $nstars; ++$col){
        
$pdf->PlaceImage('star'$start+0.1266*$col0.0538*($row+1), 0.0616);
    }
}
$pdf->CloseImage();
$pdf->OpenImage('flag'1.91);
$pdf->SetFillColor(255255255);
$pdf->Rect(001.91'F');
$pdf->SetFillColor(177.9933.6651.765); // Old Glory Red
for ($stripe 0$stripe 13$stripe += 2){
    
$pdf->Rect(00.0769*$stripe1.90.0769'F');
}
$pdf->Image('starfield'000.76);
$pdf->CloseImage();
$pdf->AddPage();
$pdf->Cell(01'Vector Graphics'01);
$pdf->Image('flag');
$pdf->PlaceImage('flag'4130deg2rad(30));
$pdf->PlaceImage('flag'4330deg2rad(-30));
$pdf->SetFillColor(0,0,0,60);
$pdf->Rect (4324'F');
$pdf->OpenImage('trefoil'1.31.3);
$pdf->SetLineWidth(0.1);
$pdf->SetDrawColor(17120523960);
$pdf->CloverLeaf(0.650.6530.5null'D');
$pdf->CloseImage();
$pdf->PlaceImage('trefoil'0.5711);
$pdf->PlaceImage('trefoil'17.251.5);
$pdf->PlaceImage('trefoil'1.56.511.5);
$pdf->PlaceImage('trefoil'2611M_TAU/6);
$pdf->PlaceImage('trefoil'2.55.511M_TAU/3);
$pdf->PlaceImage('trefoil'35.511, -M_TAU/3);
$pdf->PlaceImage('trefoil'3.5611, -M_TAU/6);
$pdf->PlaceImage('trefoil'46.511.5);
$pdf->PlaceImage('trefoil'4.57.251.5);
$pdf->PlaceImage('trefoil'5711);
$pdf->Output();
?>