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 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
|
<?php
$dbabr = unserialize($_GET['dbabr']);
$limsupy = 10;
$liminfy = -15;
$pasy = $limsupy-$liminfy;
$largeur = 800;
$hauteur = 400;
$originex = $largeur/20;
$originey = $hauteur/20;
$largeurx = $largeur-$originex;
$hauteury = $hauteur-$originey;
$image = imagecreate($largeur, $hauteur);
$fond = imagecolorallocate($image, 220, 220, 220);
$trait = imagecolorallocate($image, 32, 32, 32);
$rouge = imagecolorallocate($image, 255, 0, 0);
$vert = imagecolorallocate($image, 0, 255, 0);
$bleu = imagecolorallocate($image, 0, 0, 255);
$gris = imagecolorallocate($image, 160, 160, 160);
$noir = imagecolorallocate($image, 0, 0, 0);
//Echelle
$octavex = log10(320/10)/log10(2);
$echellex = ($largeurx-$originex)/$octavex;
$zeroy = ($hauteury-$originey)/$pasy*$limsupy+$originey;
$echelley = ($hauteury-$originey)/$pasy;
//Traits verticaux normalisés
$p1xaff = log10(10/10)/log10(2)*$echellex+$originex;
imageline( $image, $p1xaff, $originey, $p1xaff, $hauteury, $noir);
imagestring( $image, 3, $p1xaff, 8, "10", $noir);
$p1xaff = log10(15/10)/log10(2)*$echellex+$originex;
imageline( $image, $p1xaff, $originey, $p1xaff, $hauteury, $gris);
$p1xaff = log10(20/10)/log10(2)*$echellex+$originex;
imageline( $image, $p1xaff, $originey, $p1xaff, $hauteury, $noir);
imagestring( $image, 3, $p1xaff, 8, "20", $noir);
imagestring( $image, 3, $p1xaff, 3+$hauteury, "20", $noir);
$p1xaff = log10(30/10)/log10(2)*$echellex+$originex;
imageline( $image, $p1xaff, $originey, $p1xaff, $hauteury, $gris);
$p1xaff = log10(40/10)/log10(2)*$echellex+$originex;
imageline( $image, $p1xaff, $originey, $p1xaff, $hauteury, $gris);
$p1xaff = log10(50/10)/log10(2)*$echellex+$originex;
imageline( $image, $p1xaff, $originey, $p1xaff, $hauteury, $noir);
imagestring( $image, 3, $p1xaff, 8, "50", $noir);
imagestring( $image, 3, $p1xaff, 3+$hauteury, "50", $noir);
$p1xaff = log10(60/10)/log10(2)*$echellex+$originex;
imageline( $image, $p1xaff, $originey, $p1xaff, $hauteury, $gris);
$p1xaff = log10(70/10)/log10(2)*$echellex+$originex;
imageline( $image, $p1xaff, $originey, $p1xaff, $hauteury, $gris);
$p1xaff = log10(80/10)/log10(2)*$echellex+$originex;
imageline( $image, $p1xaff, $originey, $p1xaff, $hauteury, $gris);
$p1xaff = log10(90/10)/log10(2)*$echellex+$originex;
imageline( $image, $p1xaff, $originey, $p1xaff, $hauteury, $gris);
$p1xaff = log10(100/10)/log10(2)*$echellex+$originex;
imageline( $image, $p1xaff, $originey, $p1xaff, $hauteury, $noir);
imagestring( $image, 3, $p1xaff, 8, "100", $noir);
imagestring( $image, 3, $p1xaff, 3+$hauteury, "100", $noir);
$p1xaff = log10(150/10)/log10(2)*$echellex+$originex;
imageline( $image, $p1xaff, $originey, $p1xaff, $hauteury, $gris);
$p1xaff = log10(200/10)/log10(2)*$echellex+$originex;
imageline( $image, $p1xaff, $originey, $p1xaff, $hauteury, $noir);
imagestring( $image, 3, $p1xaff, 8, "200", $noir);
imagestring( $image, 3, $p1xaff, 3+$hauteury, "200", $noir);
$p1xaff = log10(300/10)/log10(2)*$echellex+$originex;
imageline( $image, $p1xaff, $originey, $p1xaff, $hauteury, $gris);
imagestring( $image, 3, $p1xaff, 8, "Hz", $noir);
imagestring( $image, 3, $p1xaff, 3+$hauteury, "Hz", $noir);
//traits horizontaux
$dbdebut = $limsupy;
$pash = ($originey-$hauteury)/$pasy;
$i = 0;
$db = $dbdebut;
while ($i <= $pasy)
{
if ($db == 10 or $db == 5 or $db == 0 or $db == -5 or $db == -10 or $db == -15)
{
imageline( $image, $originex, $originey-$i*$pash, $largeurx, $originey-$i*$pash, $noir);
if ($db <> 0)
{
imagestring( $image, 3, $originex-22, $originey-$i*$pash-5, $db, $noir);
}
else
{
imagestring( $image, 3, $originex-33, $originey-$i*$pash-5, "0 dB", $noir);
imagestring( $image, 3, $largeurx+5, $originey-$i*$pash-5, "0 dB", $noir);
}
}
else
{
imageline( $image, $originex, $originey-$i*$pash, $largeurx, $originey-$i*$pash, $gris);
}
$i++;
$db = $db-1;
}
//Courbe de réponse
$i = 0;
while($i<59)
{
$p1x = $dbabr[$i][0];
$p1y = $dbabr[$i][1];
$room1 = $dbabr[$i][2];
$champs1 = $room1+$p1y;
$p2x = $dbabr[$i+1][0];
$p2y = $dbabr[$i+1][1];
$room2 = $dbabr[$i+1][2];
$champs2 = $room2+$p2y;
$p1xaff = log10($p1x/10)/log10(2)*$echellex+$originex;
$p2xaff = log10($p2x/10)/log10(2)*$echellex+$originex;
$room1aff = log10($room1/10)/log10(2)*$echellex+$originex;
$room2aff = log10($room2/10)/log10(2)*$echellex+$originex;
$champs1aff = log10($champs1/10)/log10(2)*$echellex+$originex;
$champs2aff = log10($champs2/10)/log10(2)*$echellex+$originex;
$p1yaff = $zeroy-$p1y*$echelley;
$p2yaff = $zeroy-$p2y*$echelley;
imageline( $image, $p1xaff, $p1yaff, $p2xaff, $p2yaff, $rouge);
// imageline( $image, $room1aff, $p1yaff, $room2aff, $p2yaff, $vert);
// imageline( $image, $champs1aff, $p1yaff, $champs2aff, $p2yaff, $bleu);
$i++;
}
header("content-type: image/png");
imagepng($image);
imagedestroy($image);
?> |
Partager