function graphics($out, $w, $h, $bit, $c, $tx) { $im = imagecreate($w, $h); list($white, $black, $red, $green, $blue, $yel) = imgclr_pack($im); $clr = imgclr($im, $c); imagecolortransparent($im, $white); if ($bit) { $maxdac = max($bit); $nb_bars = count($bit); if ($nb_bars < $w / 2) { $esp = 2; } $ecart = $w / $nb_bars; if ($ecart < 10) { $tx = "off"; } $x1 = 0; $y1 = $h - 7; foreach ($bit as $k => $v) { $x2 = $x1 + $ecart; $vac = $v / $maxdac * $y1; //round ImageFilledRectangle($im, $x1, $y1 - $vac, $x2 - $esp, $y1, $clr); if ($tx == "yes") { imagestring($im, 1, $x2 - $ecart, $y1, substr($k, 2), $red); imagestring($im, 1, $x2 - $ecart, $y1 - $vac, $v, $yel); } $x1 += $ecart; } } imagepng($im, $out); }
function ums_draw($out, $r, $rk, $w) { $h = $w; $im = imagecreate($w, $h); //p($r); list($white, $black, $red, $green, $blue, $yellow) = imgclr_pack($im); $whit5 = imagecolorallocatealpha($im, 0, 0, 0, 30); //imagecolortransparent($im,$white); $font = imageloadfont('gdf/Fixedsys.gdf'); ImageFilledRectangle($im, 0, 0, $w, $h, $white); $max = max($r); $n = count($r); $ratio = $w / $max; $ctr = $w / 2; $rb = ums_clr($r); $rb = array_reverse($rb); //pr($rb); //pr($r); //verbose(array($max,$n,$w,$ratio)); foreach ($r as $k => $v) { $val = ceil($v * $ratio) - 1; $vlb = $val / 2; //mise à l'échelle $bis = $rk[$k] == $ta ? 1 : 0; $ta = $rk[$k]; $t = $ta . ' ' . $v; //titres if (!$bis) { ums_dots($im, $vald, $val, $ta, $ctr, $white, $black); } //planètes if ($bis) { $alpha = 20; } else { $alpha = 40; } $clr = imagecolorallocatealpha($im, $rb[$k][0], $rb[$k][1], $rb[$k][2], $alpha); //verbose(array($v,$max,$val,$ctr,$x,$y)); imagefilledellipse($im, $ctr, $ctr, $val, $val, $clr); imageellipse($im, $ctr, $ctr, $val, $val, $black); if ($bis) { $cl = $red; } else { $cl = $yellow; } ImageFilledRectangle($im, $ctr - 5, $ctr - $vlb + 2, $ctr + 5, $ctr - $vlb, $cl); imagestring($im, $font, $ctr - 5, $ctr - $vlb, $t, $black); if (!$bis) { $vald = $val; } } imagefilledellipse($im, $ctr, $ctr, 10, 10, $white); imageellipse($im, $ctr, $ctr, 10, 10, $black); imagepng($im, $out); return image('/' . $out . '?' . randid()); }