Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- error_reporting(E_ALL);
- $h = array();
- for ($i=0;$i<24;$i++)
- {
- $h[$i] = rand(0,1000);
- }
- $w=550;
- $h=350;
- //DEFINE('MARGIN_LEFT',20);
- //DEFINE('MARGIN_TOP',5);
- //DEFINE('MARGIN_RIGHT',6);
- //DEFINE('MARGIN_BOTTOM',30);
- DEFINE('MARGIN_LEFT',100);
- DEFINE('MARGIN_TOP',100);
- DEFINE('MARGIN_RIGHT',100);
- DEFINE('MARGIN_BOTTOM',100);
- $l = MARGIN_LEFT;
- $r = $w - MARGIN_RIGHT;
- $t = MARGIN_TOP;
- $b = $h - MARGIN_BOTTOM;
- // setup
- $image = imagecreatetruecolor($w,$h);
- imagealphablending($image, true);
- // Allocate some colors
- $clr_bg = imagecolorallocate($image, 0xdd, 0xdd, 0xdd);
- $clr_black = imagecolorallocate($image, 0x00, 0x00, 0x00);
- $clr_gray = imagecolorallocatealpha($image, 0xaa, 0xaa, 0xaa,0x10);
- $clr_blue = imagecolorallocate($image, 0x49, 0xbd, 0xd6);
- $clr_sky = imagecolorallocate($image, 0x2e, 0x69, 0xd6);
- // font
- $font = 'OpenSansCondensed-Light.ttf';
- $font_size = 12;
- // fill bg
- imagefilledrectangle($image,0,0,$w,$h,$clr_bg);
- // 25% lines + text
- for ($i=0;$i<5;$i++)
- {
- $y = $t + ($b-$t)/4*$i;
- imageline($image,$l,$y,$r,$y,$clr_gray);
- $txt = sprintf('%d%%',(4-$i)*25);
- $text_size = imagettftext ( $image , $font_size , 0 ,0 , 0 , $clr_black , $font ,$txt );
- $tx = $l - $text_size[4]-3;
- $ty = $y - $text_size[5]/2;
- imagettftext($image,$font_size,0,$tx,$ty, $clr_black, $font, $txt);
- }
- // chart outline
- imagerectangle($image, $l, $t, $r, $b, $clr_black);
- /*
- // hour nums
- $rct_w =$w-MARGIN_LEFT-MARGIN_RIGHT;
- $rct_w_24 = $rct_w/24;
- for ($i=0;$i<24;$i++)
- {
- $txt = sprintf('%d',$i);
- $text_size = imagettftext ( $image , $font_size , 0 ,0 , 0 , $clr_black , $font ,$txt );
- $tx = MARGIN_LEFT + $rct_w_24*$i + ($rct_w_24-$text_size[4])/2;
- $ty = $h-MARGIN_BOTTOM+5-$text_size[5];
- imagettftext($image,$font_size,0,$tx,$ty, $clr_black, $font, $txt);
- imagefilledrectangle($image,
- MARGIN_LEFT+$rct_w_24*$i+1,$h-MARGIN_BOTTOM-($h[$i]),
- MARGIN_LEFT+$rct_w_24*($i+1)-1,$h-MARGIN_BOTTOM,
- $clr_blue);
- //imagerectangle($image, MARGIN_LEFT, MARGIN_TOP, $w-MARGIN_RIGHT, $h-MARGIN_BOTTOM, $clr_black);
- }
- */
- // Flush the image
- header('Content-type: image/png');
- imagepng($image);
- imagedestroy($image);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement