웹마스터 팁

미리보기 : http://sjbiz.net/house/a.php

phpschool에서 어떤분이 3차원 그래프를 올려 놓으셨길래 함 따라해 봤어여 ^^;
( 그분이 소스를 안 올려 주셔서 ㅡ.ㅜ )
디자인은 그분꺼 그대루...
이거 근데 생각보다 디게 노가대 네여
무려 8시간이나 ㅡ.,ㅡ;;
내용은 매월 수익과 지출을 그래프로 나타낸 겁니다.
디비와 연결 없이 for 로 난수를 적용하여 그래프 만든겁니다 ^^;
그럼...

<?
header("Content-Type : image/png");
function printPolygon($num, $color, $x1,$y1,$x2,$y2,$x3=0,$y3=0,$x4=0,$y4=0,$x5=0,$y5=0,$x6=0,$y6=0){
        global $im;

        $points[0]=$x1; $points[1]=$y1;
        $points[2]=$x2; $points[3]=$y2;
        $points[4]=$x3; $points[5]=$y3;
        $points[6]=$x4; $points[7]=$y4;
        $points[8]=$x5; $points[9]=$y5;
        $points[10]=$x6; $points[11]=$y6;

        ImageFilledPolygon($im,$points,$num,$color);
}

$im=ImageCreate(663,403);
$black=ImageColorAllocate($im,0,0,0);
$white=ImageColorAllocate($im,255,255,255);
$fb1=ImageColorAllocate($im,192,192,192);
$fb2=ImageColorAllocate($im,130,130,130);
$fb3=ImageColorAllocate($im,240,240,240);
$g1=ImageColorAllocate($im,0,153,51);
$g2=ImageColorAllocate($im,0,115,39);
$g3=ImageColorAllocate($im,0,77,26);
$gr1=ImageColorAllocate($im,153,0,0);
$gr2=ImageColorAllocate($im,115,0,0);
$gr3=ImageColorAllocate($im,77,0,0);

printPolygon(4,$white,2,2,657,2,657,397,2,397); //배경 만들기
imagefilledrectangle($im,0,400,5,403,$white); //왼쪽 아래 조그만 흰색 사각형
imagefilledrectangle($im,660,0,663,5,$white); //오른쪽 상단 조그만 흰색 사각형

//실제 그래프 모양 만들기
printPolygon(6,$fb1,65,25,630,25,630,265,610,285,45,285,45,45); //배경 다각형
printPolygon(6,$fb2,630,25,630,265,610,285,610,277,625,261,625,30); //오른쪽 모서리 다각형
printPolygon(6,$fb3,45,45,51,45,51,277,610,277,610,285,45,285); //축 배경
printPolygon(4,$fb2,52,45,67,29,67,262,52,276); //Y축 배경 안쪽
printPolygon(4,$fb3,68,30,624,30,624,261,68,261); //배경 다각형 안쪽 배경

//축 기준 값들 (점선)
for ($i=52; $i<242; $i+=21) imageLine($im,68,$i,624,$i,$black);
for ($i=52; $i<242; $i+=21) imageLine($im,52,$i+15,67,$i,$fb3);
for ($i=68; $i<258; $i+=21) imageLine($im,45,$i,50,$i,$black);



for ($i=20; $i<466; $i+=15){
        if(!$j)$j=1;
        imageLine($im,$i+93,277,$i+93,285,$black);

        $y=rand(100,276);
        imagefilledrectangle($im,$i+80,$y,$i+90,276,$g1); //값 표면
        printPolygon(4,$g2,$i+80,$y,$i+95,$y-15,$i+105,$y-15,$i+90,$y); //값 안쪽
        printPolygon(4,$g3,$i+90,$y,$i+105,$y-15,$i+105,261,$i+90,276); //값 오른쪽

        $y=rand(100,276);
        $i+=15;
        imagefilledrectangle($im,$i+80,$y,$i+90,276,$gr1); //값 표면
        printPolygon(4,$gr2,$i+80,$y,$i+95,$y-15,$i+105,$y-15,$i+90,$y); //값 안쪽
        printPolygon(4,$gr3,$i+90,$y,$i+105,$y-15,$i+105,261,$i+90,276); //값 오른쪽

        $i+=10;

        Imagestring($im,2,$i+66,286,$j,$black);
        $j++;
}

imagefilledrectangle($im,440,320,632,372,$fb2); //주석 상자 테두리
imagefilledrectangle($im,442,322,630,370,$white); //주석 상자
imagefilledrectangle($im,450,332,460,342,$g1); //수입 상자
imagefilledrectangle($im,450,352,460,362,$gr1); //지출 상자
Imagestring($im,2,470,330,': the amount of imports.'+ ',$black);
Imagestring($im,2,470,350,': the amount disbursed.',$black);

Imagestring($im,5,150,7,'2002 Year, monthly expenses graph.',$black); //타이틀 적기

$file="per_day.png";

ImageInterlace($im,1);
Imagepng($im);
//Imagepng($im,$file);
ImageDestroy($im);
?>