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
|
<? header("Content-type: image/png"); // Paramètres : h et m
function rect($x1,$y1,$x2,$y2,$h) { global $texte,$image; global $cclock,$sclock; $a = M_PI/2 - $h*M_PI/6; $c = cos($a); $s = sin($a); $points = array(); $points[0] = 199 + (int) ($x1*$c - $y1*$s); $points[1] = 200 - (int) ($x1*$s + $y1*$c); $points[2] = 199 + (int) ($x2*$c - $y1*$s); $points[3] = 200 - (int) ($x2*$s + $y1*$c); $points[4] = 199 + (int) ($x2*$c - $y2*$s); $points[5] = 200 - (int) ($x2*$s + $y2*$c); $points[6] = 199 + (int) ($x1*$c - $y2*$s); $points[7] = 200 - (int) ($x1*$s + $y2*$c);
imagefilledpolygon($image,$points,4,$texte); }
function aiguille($h,$longueur) { $x1 = 50; $y1 = -5; $x3 = 50; $y3 = 5; global $aiguilles,$image; global $cclock,$sclock; $a = M_PI/2 - $h*M_PI/6; $c = cos($a); $s = sin($a); $points = array(); $points[0] = 199; $points[1] = 200; $points[2] = 199 + (int) ($x1*$c - $y1*$s); $points[3] = 200 - (int) ($x1*$s + $y1*$c); $points[4] = 199 + (int) ($longueur*$c); $points[5] = 200 - (int) ($longueur*$s); $points[6] = 199 + (int) ($x3*$c - $y3*$s); $points[7] = 200 - (int) ($x3*$s + $y3*$c); imagefilledpolygon($image,$points,4,$aiguilles); }
$image = imagecreate(400,400); $texte = imagecolorallocate($image,16,16,16); $aiguilles = imagecolorallocate($image,128,128,128); $fond = imagecolorallocate($image,255,255,255); imagefilledrectangle($image,0,0,400,400,$fond); imagearc($image,199,199,400,400,0,360,$texte); imagearc($image,199,199,380,380,0,360,$texte); imagefill($image,5,199,$texte); imagearc($image,199,199,40,40,0,360,$aiguilles); imagefill($image,199,199,$aiguilles); imagefilledrectangle($image,194,0,204,40,$texte); imagefilledrectangle($image,194,359,204,399,$texte); imagefilledrectangle($image,0,194,40,204,$texte); imagefilledrectangle($image,359,194,399,204,$texte); rect(170,-5,200,5,1); rect(170,-5,200,5,2); rect(170,-5,200,5,4); rect(170,-5,200,5,5); rect(170,-5,200,5,7); rect(170,-5,200,5,8); rect(170,-5,200,5,10); rect(170,-5,200,5,11);
aiguille(($h % 12)+$m/55,100); aiguille((int)$m/5,180); imagecolortransparent($image,$fond); imagepng($image); ?>
|