php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #41717 Problem with imagethickness() and imagepolygon()
Submitted: 2007-06-16 23:50 UTC Modified: 2007-06-17 10:58 UTC
From: c dot bezemer at student dot tudelft dot nl Assigned: pajoye (profile)
Status: Closed Package: GD related
PHP Version: 5.2.3 OS: windows and linux
Private report: No CVE-ID: None
 [2007-06-16 23:50 UTC] c dot bezemer at student dot tudelft dot nl
Description:
------------
When drawing a polygon with the default thickness everything is fine; but when setting the thickness of the line > 1, I get strange results. It looks as if certain lines of the polygons are not being drawn with the correct thickness.

Reproduce code:
---------------
function getPolygon($width, $border_width, $sides)
{
    $xcen = $width; $ycen = $width; $incr = 360/$sides;
    $angle = 180; $k = 0; $max_height = 0;
    for($j = 0; $j < $sides; $j++)
    {
        $points[$k] = $xcen + $width * sin(deg2rad($angle)) + $border_width;
        $k++;
        $points[$k] = $ycen + $width * cos(deg2rad($angle)) + $border_width;
        $max_height = max($max_height, $points[$k]);
        $k++;
        $angle += $incr;
    }
    $img = imagecreatetruecolor(2*$width+10, $max_height+$border_width+10);
    $bg = imagecolorallocate($img,255,255,255);
    ImageFill($img, 0, 0, $bg);
    imagecolorallocate($img, 255, 255, 255);
    $black = imagecolorallocate($img,0,0,0);
    imagesetthickness($img,$border_width);
    imagepolygon($img,$points,$sides,$black);
    header("Content-type: image/gif"); imagegif ($img); imagedestroy($img);
}
getPolygon(100, 5, 9);

Expected result:
----------------
For 9 sides, it should be like http://www.gabber.nl/cp/geometry_1px.gif with a thicker line. 

Actual result:
--------------
The output is http://www.gabber.nl/cp/geometry_5px.gif . This happens for most values of sides.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-06-17 10:58 UTC] pajoye@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.

Thanks for this report!
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 08:01:29 2024 UTC