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
| <?php
header("Content-type: image/png");
$offsetGauche = 30;
$offsetDroit = 15;
$xsize = abs($size[0]) + abs($size[2]);
$ysize = abs($size[5]) + abs($size[1]);
$size = imagettfbbox($_GET['size'], 0, $fontfile, $_GET['title']);
// $width = (isset($_GET['width']) ? $_GET['width'] : 240);
$width = (isset($_GET['width']) ? $_GET['width'] : $xsize);
// $height = (isset($_GET['height']) ? $_GET['height'] : 35);
$height = (isset($_GET['height']) ? $_GET['height'] : $ysize);
$prog = (isset($_GET['prog']) ? $_GET['prog'] : '');
$title = (isset($_GET['title']) ? $_GET['title'] : ' ');
$n = intval(($width - $offsetGauche - $offsetDroit) / 24);
$taille = $n * 24;
// $fontSize = 10;
if(!isset($_GET['size'])) $_GET['size'] = 10;
$fontfile = getcwd().'/segoeui.ttf'; // mettre le fichier de la police à utiliser dans le même répertoire que le script.
// $fontfile = "C:\wamp64\www\projet\Viessmann\images\ARIALN.TTF";
// $image = imagecreate($width, $height);
$image = imagecreatetruecolor($width, $height);
//Pour fond transparent
imagealphablending($image, false);
imagesavealpha($image, true);
$col=imagecolorallocatealpha($image,255,255,255,127);
imagefill($image, 0, 0, $col);
$blanc = imagecolorallocate($image, 255, 255, 255);
$orange = imagecolorallocate($image, 247, 163, 92);
$rouge = imagecolorallocate($image, 255, 0, 0);
$bleuclair = imagecolorallocate($image, 124, 182, 236);
$gris = imagecolorallocate($image, 128, 128, 128);
$grisClair = imagecolorallocate($image, 192, 192, 192);
$noir = imagecolorallocate($image, 0, 0, 0);
$strAngle = 0;
$strX = 15;
$strY = 10;
$titleAngle = 0;
$titleX = 0;
$titleY = 30;
for ($i=0; $i<=24; $i++) {
$x = $i*$n+$offsetGauche;
if (($i % 6) == 0) {
ImageLine($image, $x, 15, $x, 25, $gris);
if ($i < 12) {
$str = '0' . $i . ':00';
} else {
$str = $i . ':00';
}
// imagestring($image, 2, $x-15, 0, $str, $noir);
//imagefttext($image, $fontSize, $strAngle, $x-$strX, $strY, $noir, $fontfile, $str);
imagefttext($image, $_GET['size'], $strAngle, abs($size[0]), abs($size[5]), $noir, $fontfile, $str);
} else {
ImageLine($image, $x, 20, $x, 25, $grisClair);
}
}
// imagestring($image, 2, 0, 20, $title, $noir);
//imagefttext($image, $fontSize, $titleAngle, $titleX, $titleY, $noir, $fontfile, $title);
imagefttext($image, $_GET['size'], $titleAngle, abs($size[0]), abs($size[5]), $noir, $fontfile, $title);
imagefilledrectangle($image, $offsetGauche, 26, $taille + $offsetGauche, 35, $bleuclair);
if ($prog !== '') {
$progs = explode(",", $prog);
$n = count($progs);
if (($n % 3) == 0) {
for ($i=0; $i<$n; $i+=3) {
$mode = $progs[$i];
$start = $progs[$i+1];
$end = $progs[$i+2];
$nombres = explode(":", $start);
$debut = $nombres[0] * 60 + $nombres[1];
$debut = $offsetGauche + $taille * $debut / 1440;
$nombres = explode(":", $end);
$fin = $nombres[0] * 60 + $nombres[1];
$fin = $offsetGauche + $taille * $fin / 1440;
if ($mode === 'n') {
imagefilledrectangle($image, $debut, 26, $fin, 35, $orange);
} else {
imagefilledrectangle($image, $debut, 26, $fin, 35, $rouge);
}
}
}
}
imagepng($image, null, 9);
imagedestroy($image);
?> |
Partager