הרשם שאלות ותשובות רשימת חברים לוח שנה הודעות מהיום

חזור   הוסטס - פורום אחסון האתרים הגדול בישראל > עיצוב גראפי, תכנות על כל שפותיו וקידום ושיווק אתרים > פורום תיכנות

   
|!|

 
 
כלים לאשכול תצורת הצגה
Prev הודעה קודמת   הודעה הבאה Next
ישן 25-10-05, 02:29   # 1
יונתן
חבר בקהילה
 
יונתן's Avatar
 
מיני פרופיל
תאריך הצטרפות: Oct 2005
הודעות: 342
Send a message via Skype™ to יונתן

יונתן לא מחובר  

קלאס גראף עוגה למערכות סקרים\סטסטיקות

סיימתי את זה לפני כמה שעות
הקוד:
PHP קוד:
<?
#class by Yonatan Rab - yonatan.rab@gmail.com - 72329528
#all rights reseved

class graph
{

var    
$Graph;
var 
$Image;
var 
$Angels;
var 
$SliceCount;
var 
$Slice;
var 
$Colors;

    function 
graph($width,$height)
    {
        
$this->Graph["title"]=$title;
        
$this->Graph["width"]=$width;
        
$this->Graph["height"]=$height;
        
header("Content-type: image/png");
        
$this->Image = @imagecreate($width$height) or die("Cannot Initialize new GD image");
    }

    function 
makeTitle($title,$font) {
        
$width=imagefontwidth($font);
        
$height=imagefontheight($font);
        
imagefilledpolygon($this->Image,
                 array (
                    
656,
                    
65, (6+$height),
                 (
65+($width*strlen($title))+4), (6+$height),
                    (
65+($width*strlen($title))+4), 6
                 
),
                 
4,
                 
$this->Colors["white"]);
        
imagepolygon($this->Image,
                 array (
                    
656,
                    
65, (6+$height),
                 (
65+($width*strlen($title))+4), (6+$height),
                    (
65+($width*strlen($title))+4), 6
                 
),
                 
4,
                 
$this->Colors["black"]);
        
imagestring($this->Image$font686$title$this->Colors["black"]);
    }
    function 
addVote($num,$vote,$r,$g,$b)
    {
        
$this->Angels[$num]=$vote;
        
$this->Colors[$num]=imagecolorallocate($this->Image$r$g$b);
    }
    function 
graphBG($r,$g,$b)
    {
        
$this->Colors[0]=imagecolorallocate($this->Image$r$g$b);
        
$this->Colors["black"] = imagecolorallocate($this->Image000);
        
$this->Colors["white"] = imagecolorallocate($this->Image255255255);
    }
    function 
makeAngels()
    {
        
$this->SliceCount=count($this->Angels);
        
$ar_num_count=0;
        for (
$i=1;$i<=$this->SliceCount;$i++) {
            
$ar_num_count=$ar_num_count+$this->Angels[$i];
        }
        
$this->Slice=360/$ar_num_count;
        
$count=0;
    }


    function 
makeDeatils()
    {
        
$x=10;
        
$y=10;
        
$z=0;

        for (
$i=1;$i<=$this->SliceCount;$i++) {
            
$ar_num_count=$ar_num_count+$this->Angels[$i];
        }

        
//÷åôñà âãåìä
        
imagefilledpolygon($this->Image,
             array (
                
66,
                
5, (9+(15*$this->SliceCount)),
                
61, (9+(15*$this->SliceCount)),
                
616
             
),
             
4,
             
$this->Colors["white"]);
        
imagepolygon($this->Image,
             array (
                
66,
                
6, (9+(15*$this->SliceCount)),
                
61, (9+(15*$this->SliceCount)),
                
616
             
),
             
4,
             
$this->Colors["black"]);

        
//÷åôñàåú ÷èðåú
        
for ($i=1;$i<=$this->SliceCount;$i++)
        {
            
imagefilledpolygon($this->Image,
                 array (
                    
$x$y+$z,
                    
$x, ($y+10+$z),
                    (
$x+10), ($y+10+$z),
                    (
$x+10), $y+$z
                 
),
                 
4,
                 
$this->Colors[$i]);
            
imagepolygon($this->Image,
                 array (
                    
$x$y+$z,
                    
$x, ($y+10+$z),
                    (
$x+10), ($y+10+$z),
                    (
$x+10), $y+$z
                 
),
                 
4,
                 
$this->Colors["black"]);

            
$num=$this->Angels[$i]*100/$ar_num_count;
         
imagestring($this->Image2, ($x+14), ($y+$z-1), round($num2)."%"$this->Colors["black"]);

            
$y+=10;
            
$z+=5;
        }
    }


    function 
drawAngels()
    {
        
$c=0;
        for (
$i=1;$i<=$this->SliceCount;$i++) {
            
$x=$this->Slice*$this->Angels[$i]+$c;
         
imagefilledarc($this->Image$this->Graph["width"]/2$this->Graph["height"]/2$this->Graph["width"]*0.8$this->Graph["height"]*0.8$c$x$this->Colors[$i], IMG_ARC_PIE);
            
$c=$x;
        }
        
imageellipse($this->Image$this->Graph["width"]/2$this->Graph["height"]/2$this->Graph["width"]*0.8$this->Graph["height"]*0.8$this->Colors["black"]);
    }
    
    function 
finish ()
    {
        
imagepng($this->Image);
        
imagedestroy($this->Image);
    }

}

$bla=new graph(400,400);
$bla->graphBG(255,255,200);
$bla->makeTitle("What do you say about the site?",2);
$bla->addVote(12325500);
$bla->addVote(22400255);
$bla->addVote(32502550);
$bla->addVote(4262550255);
$bla->addVote(5155150150150);
$bla->makeAngels();
$bla->drawAngels();
$bla->makeDeatils();
$bla->finish();

?>
אם מישהו רוצה לראות את זה www.yonatan.co.il/graph.php
קצת הסברים

PHP קוד:
<?

$bla
=new graph(400,400);
//יוצר גראף חדש בגודל 400 על 400
$bla->graphBG(255,255,200);
//קובע את צבע הרקע של הגראף
$bla->makeTitle("What do you say about the site?",2);
//כותרת לגראף - לא חובה
$bla->addVote(12325500);
//מוסיף הצבעה חדשה
//1=מספר התוצאה
//23=מספר התשובות
//255, 0, 0= צבע
$bla->addVote(22400255);
$bla->addVote(32502550);
$bla->addVote(4262550255);
$bla->addVote(5155150150150);
$bla->makeAngels();
//מחשב זוויות וכ'ו...
$bla->drawAngels();
//מצייר את הגראף
$bla->makeDeatils();
//יוצר את הריבוע הקטן עם הפרטים - לא חובה
$bla->finish();
//מסיים את הגראף

?>
אשמח לשמוע ביקורות, איך הייתי יכול לשפר מה לא טוב וכ'ו...
  Reply With Quote
 

חברים פעילים הצופים באשכול זה: 1 (0 חברים ו- 1 אורחים)
 


חוקי פירסום
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is מופעל
סמיילים הם מופעל
[IMG] קוד מופעל
קוד HTML מכובה

קפיצה לפורום


כל הזמנים הם GMT +2. הזמן כעת הוא 06:58.

מופעל באמצעות VBulletin גרסה 3.8.6
כל הזכויות שמורות ©
כל הזכויות שמורות לסולל יבוא ורשתות (1997) בע"מ