לוגו אתר Fresh          
 
 
  אפשרות תפריט  ראשי     אפשרות תפריט  צ'אט     אפשרות תפריט  מבזקים     אפשרות תפריט  צור קשר     חץ שמאלה ‎print ‎"Hello World!"; if‎ ‎not rules.‎know ‎then rules.‎read(); חץ ימינה  

לך אחורה   לובי הפורומים > מחשבים > תכנות ובניית אתרים
שמור לעצמך קישור לדף זה באתרי שמירת קישורים חברתיים
תגובה
 
כלי אשכול חפש באשכול זה



  #1  
ישן 02-08-2008, 13:52
צלמית המשתמש של tnadav1
  משתמש זכר tnadav1 tnadav1 אינו מחובר  
 
חבר מתאריך: 02.10.05
הודעות: 2,355
שלח הודעה דרך MSN אל tnadav1
מחלקה פשוטה ליצירת עוגייה תלת מימדית שכתבתי

בתמונה היוצאת יש רק את העוגה ללא מקרא, עקב זה שהעוגייה הייתה מיועדת לאתר שקיים במספר שפות, והוחלט לשים את המקרא ב- HTML עקב קשיים בקידוד.

נתרם לפורום ללא רישיון, תשתמשו לזה למה שאתם רוצים, תשנו את זה כמה שבא לכם, ואם בא לכם, שימו בקוד קרדיט, אף אחד לא יתבע אתכם אם לא תעשו את זה
קוד PHP:
<?php
<?php
/*-----------------------------------------*\
| TeneView System, 2007 (C)                    |
| Developed by Nadav Tenenbaum                |
| Version 1.0 Beta                            |
| ----------------------------------------    |
| File: pieGraph.class.php                    |
| gdLib Appliction  who drew a pie graph    |
\*-----------------------------------------*/

class pie {
    var 
$slices;
    var 
$width;
    var 
$height;
    var 
$image;
    var 
$colors;
    var 
$depth;
    var 
$plate;
    var 
$colorNumber;
    
    function 
pie($height$width$depth){
        
// Class variable Set
        
$this->colorNumber    0;
        
$this->height        $height;
        
$this->width        $width;
        
$this->depth        $depth;
        
        
$this->image         imagecreatetruecolor($this->width$this->height);
        
imagefill($this->image00imagecolortransparent($this->image$this->createColor('#FFFFFF''transparent')));
        
$this->createColor('#000000''black');
    }
    
    function 
loadPlate($plate) {
        
$this->plate $plate;
    }
    
    function 
makeColor() {
        return 
$this->plate[$this->colorNumber++];
    }
    
    function 
addSlice($percent$color '') {
        if(empty(
$color))
            
$color $this->makeColor();
        
        
$this->slices[] = array('percent' => $percent'oColor' => $color,'color' => $this->createColor($color), 
                        
'shadowColor' => $this->createColor($this->mixColors($color'#000000'75)));
    }
    
    function 
getColor($color) {
        if(
is_array($color)) return $color;
        
        return 
sscanf($color'#%2x%2x%2x');
    }
    
    function 
mixColors($colorA$colorB$opacity) {
        
$returnVal = array();
        
        
$opacity /= 100;
        
        
$colorA $this->getColor($colorA);
        
$colorB $this->getColor($colorB);
        
        
// Mixing red
        
if($colorA[0] > $colorB[0])
            
$returnVal[0] = $colorB[0] + ($colorA[0]*$opacity);
        else
            
$returnVal[0] = $colorA[0] + ($colorB[0]*$opacity);    
        
        
// Mixing green
        
if($colorA[1] > $colorB[1])
            
$returnVal[1] = $colorB[1] + ($colorA[1]*$opacity);
        else
            
$returnVal[1] = $colorA[1] + ($colorB[1]*$opacity);    
        
        
// Mixing blue
        
if($colorA[2] > $colorB[2])
            
$returnVal[2] = $colorB[2] + ($colorA[2]*$opacity);
        else
            
$returnVal[2] = $colorA[2] + ($colorB[2]*$opacity);    
            
        return 
$returnVal;
    }
    
    function 
createColor($color$key 0) {
        if(!
$key$key count($this->slices) + 1;
        
        
$color $this->getColor($color);
        
        
$this->colors[$key] = imagecolorallocate($this->image$color[0], $color[1], $color[2]);
        
        return 
$this->colors[$key];
    }
    
    function 
execute() {
        
$lastPoint 0;
        
$sliceDegrees 0;
        
        foreach(
$this->slices AS $slice) {
            
$sliceDegrees round(($slice['percent'] * 360) / 100);
            
            for(
$i $this->height/2$i <= $this->height/$this->depth$i++) {
                
imagefilledarc($this->image$this->width/2$i$this->width$this->height/2
                                
$lastPoint$lastPoint+$sliceDegrees$slice['shadowColor'], IMG_ARC_NOFILL);
            }
            
$lastPoint += $sliceDegrees;
        }
        
$lastPoint 0;
        foreach(
$this->slices AS $slice) {
            
$sliceDegrees round(($slice['percent'] * 360) / 100);
            
            
imagefilledarc($this->image$this->width/2$this->height/2$this->width$this->height/2
                            
$lastPoint$lastPoint+$sliceDegrees$slice['color'], IMG_ARC_PIE);
            
imagefilledarc($this->image$this->width/2$this->height/2$this->width$this->height/2
                            
$lastPoint$lastPoint+$sliceDegrees$this->colors['black'], IMG_ARC_NOFILL);
            
            
$lastPoint += $sliceDegrees;
        }
    }
    
    function 
output() {
        
header("Content-type: image/png");
        
        
imagepng($this->image);
        
imagedestroy($this->image);
    }
}
?>

דוגמא לשימוש במחלקה:
קוד PHP:
<?php
require_once('core/pieGraph.class.php');

if(empty(
$_GET['width']))
    
$_GET['width'] = '299';
if(empty(
$_GET['height']))
    
$_GET['height'] = '299';
if(empty(
$_GET['depth']))
    
$_GET['depth'] = '20';
    
$pie = new pie($_GET['height'], $_GET['width'], $_GET['depth']);

$pie->addSlice(50'#FEFEFE');
$pie->addSlice(25, array('30''120''230'));
$pie->addSlice(25, array('120''20''190'));

$pie->execute();
$pie->output();
?>

אני לא אחראי על הצבעים המזעזעים שיש בדוגמא, אפילו לא בדקתי אותם.
אני לא אחראי על באגים שיש בתוכנה שיצרו בעיות, ועל נזקים שייגרמו בעת שימוש במחלקה הזאת

הסיבה שאני מפרסם את המחלקה הזאת, למרות ש- Vadim פירסם עכשיו משהו דומה זה ש-
א'. סיימתי עכשיו לכתוב את המחלקה , אני מתכנן את זה הרבה זמן.
ב'. למישהו שמחפש משהו יותר פשוט, ולא "מפלצת" שיודעת לעשות המון דברים.
ג'. יש לכם אישור ממני לעשות עם זה מה שבא לכם
_____________________________________



נערך לאחרונה ע"י tnadav1 בתאריך 02-08-2008 בשעה 13:59.
תגובה ללא ציטוט תגובה עם ציטוט חזרה לפורום
תגובה

כלי אשכול חפש באשכול זה
חפש באשכול זה:

חיפוש מתקדם
מצבי תצוגה דרג אשכול זה
דרג אשכול זה:

מזער את תיבת המידע אפשרויות משלוח הודעות
אתה לא יכול לפתוח אשכולות חדשים
אתה לא יכול להגיב לאשכולות
אתה לא יכול לצרף קבצים
אתה לא יכול לערוך את ההודעות שלך

קוד vB פעיל
קוד [IMG] פעיל
קוד HTML כבוי
מעבר לפורום



כל הזמנים המוצגים בדף זה הם לפי איזור זמן GMT +2. השעה כעת היא 20:52

הדף נוצר ב 0.06 שניות עם 12 שאילתות

הפורום מבוסס על vBulletin, גירסא 3.0.6
כל הזכויות לתוכנת הפורומים שמורות © 2024 - 2000 לחברת Jelsoft Enterprises.
כל הזכויות שמורות ל Fresh.co.il ©

צור קשר | תקנון האתר