note 57586 deleted from ref.pdf by aidan
| From: | aidan@php.net | Date: | Sat, 08 Oct 2005 01:27:44 +0000 |
| Subject: | note 57586 deleted from ref.pdf by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-96649@lists.php.net to get a copy of this message | ||
Note Submitter: ragnar at deulos dot com
Reason: useless
----
PART II
<?php
// pdf_color(pdf resource, stroke color, fill color)
// this is used to set the colors, leave like empty string ("") to dont change the color
of what you want. The values are hexadecimal color like in the html (#FF00CC).
function pdf_color($pdf, $trazado, $relleno) {
if ($trazado != "") {
$color = str_replace("#", "", $trazado);
$rojo = (hexdec(substr($color, 0, 2)) / 255);
$verde = (hexdec(substr($color, 2, 2)) / 255);
$azul = (hexdec(substr($color, -2)) / 255);
pdf_setcolor($pdf, "stroke", "rgb", $rojo, $verde, $azul, 0);
}
if ($relleno != "") {
$color = str_replace("#", "", $relleno);
$rojo = (hexdec(substr($color, 0, 2)) / 255);
$verde = (hexdec(substr($color, 2, 2)) / 255);
$azul = (hexdec(substr($color, -2)) / 255);
pdf_setcolor($pdf, "fill", "rgb", $rojo, $verde, $azul, 0);
}
}
// pdf_linea(pdf resource, start x, start y, end x, end y, line width, color of the line)
// draws a line from start to the end with the width and color you want (the color is set in
hexadecimal)
function pdf_linea($pdf, $tx, $ty, $bx, $by, $grosor, $color) {
pdf_color($pdf, $color, "");
pdf_setlinewidth($pdf, $grosor);
pdf_moveto($pdf, $tx, $ty);
pdf_lineto($pdf, $bx, $by);
pdf_stroke($pdf);
}
// pdf_circulo(pdf resource, x, y, radius, stroke width, stroke color, fill color)
// draws a circle. if u dont want to stroke it set stroke width to 0 and if u dont want to fill it
leave the fill color as an empty string.
function pdf_circulo($pdf, $x, $y, $radio, $trazado, $c_trazado, $c_relleno) {
if ($trazado == 0) {
pdf_color($pdf, "", $c_relleno);
pdf_circle($pdf, $x, $y, $radio);
pdf_fill($pdf);
} elseif ($c_relleno == "") {
pdf_color($pdf, $c_trazado, $c_relleno);
pdf_setlinewidth($pdf, $trazado);
pdf_circle($pdf, $x, $y, $radio);
pdf_stroke($pdf);
} else {
pdf_color($pdf, $c_trazado, $c_relleno);
pdf_setlinewidth($pdf, $trazado);
pdf_circle($pdf, $x, $y, $radio);
pdf_fill_stroke($pdf);
}
}
// pdf_angulo(pdf resource, x, y, radius, starting degrees, ending degrees, stroke width, stroke
color, fill color)
// draws an arc. if u dont want to stroke it set stroke width to 0 and if u dont want to fill it
leave the fill color as an empty string.
function pdf_angulo($pdf, $x, $y, $radio, $angulo1, $angulo2, $trazado, $c_trazado, $c_relleno) {
if ($trazado == 0) {
pdf_color($pdf, "", $c_relleno);
pdf_arcn($pdf, $x, $y, $radio, $angulo1, $angulo2);
pdf_fill($pdf);
pdf_arc($pdf, $x, $y, $radio, $angulo1, $angulo2);
pdf_fill($pdf);
} elseif ($c_relleno == "") {
pdf_color($pdf, $c_trazado, $c_relleno);
pdf_setlinewidth($pdf, $trazado);
pdf_arc($pdf, $x, $y, $radio, $angulo1, $angulo2);
pdf_stroke($pdf);
} else {
pdf_color($pdf, $c_trazado, $c_relleno);
pdf_arcn($pdf, $x, $y, $radio, $angulo1, $angulo2);
pdf_fill($pdf);
pdf_setlinewidth($pdf, $trazado);
pdf_arc($pdf, $x, $y, $radio, $angulo1, $angulo2);
pdf_fill_stroke($pdf);
}
}
?>