GD2 artefact

    Date: 10/30/06 (PHP Community)    Keywords: no keywords

    This code is supposed to draw arcs, but I keep getting that line at the bottom. Can anyone tell me what that is and how to get rid of it?

    Here's the buggy code:


     1)
        {
            $iwborder = $arcwidth - $border;
            $ihborder = $archeight - $border;
            
            // The border
            imagefilledarc($crv, $arcdata[0], $arcdata[1], $arcwidth, $archeight,
                           $arcdata[2], $arcdata[3], $arc_color, IMG_ARC_PIE);
            
            // The filled arc
            imagefilledarc($crv, $arcdata[0], $arcdata[1], $iwborder, $ihborder,
                           $arcdata[2], $arcdata[3], $foreground_color, IMG_ARC_PIE);        
        }
        
        // The 'border' arc if the width is just 1
        else
        {
            // The filled arc
            imagefilledarc($crv, $arcdata[0], $arcdata[1], $arcwidth, $archeight,
                           $arcdata[2], $arcdata[3], $foreground_color, IMG_ARC_PIE);
            
            // The border    
            imagearc($crv, $arcdata[0], $arcdata[1], $arcwidth, $archeight,
                     $arcdata[2], $arcdata[3], $arc_color);
        }
    }
    
    // Displays the image based $imagetype
    switch ($imagetype)
    {
        // Displays the image as a JPEG
        case 1:
            header("Content-type: image/jpeg"); 
            imagejpeg($crv);
            break;
        
        // Displays the image as a PNG
        case 2:
            header("Content-type: image/png"); 
            imagepng($crv);
            break;
        
        // Displays the image as a GIF
        case 3:
            header("Content-type: image/gif"); 
            imagegif($crv);
            break;  
    }
    
    // Destroys the image
    imagedestroy($crv);
    
    // Ends the program
    exit;
    
    
    // ---------- Functions ----------
    
    // Given $corner, $bwidth, and $bheight this returns an array with values
    // to draw an arc
    function create_arc($corner, $w, $h)
    {
        $arc_ret = array();
        
        switch ($corner)
        {
            // top, left
            case "tl":
                $arc_ret = array($w, $h, 180, 270);
                break;
            
            // top, right
            case "tr":
                $arc_ret = array(0, $h, 270, 360);
                break;
            
            // bottom, left
            case "bl":
                $arc_ret = array($w, 0, 90, 180);
                break;
            
            // bottom, right
            case "br":
                $arc_ret = array(0, 0, 0, 90);
                break;
        }
        
        return($arc_ret);
    }
    
    // Error out
    function error_out($message)
    {
        if (@$message != "")
        {
            echo($message);
            exit;
        }
        else
        {
            error_out("Your error message needs a message.");
        }
    }
    
    ?>

    Source: http://community.livejournal.com/php/506796.html

« brain fart.. || PHP script being run twice... »


antivirus | apache | asp | blogging | browser | bugtracking | cms | crm | css | database | ebay | ecommerce | google | hosting | html | java | jsp | linux | microsoft | mysql | offshore | offshoring | oscommerce | php | postgresql | programming | rss | security | seo | shopping | software | spam | spyware | sql | technology | templates | tracker | virus | web | xml | yahoo | home