GetDotted Domains

Viewing Thread:
"Creating filled polygons with PHP"

The "Freeola Customer Forum" forum, which includes Retro Game Reviews, has been archived and is now read-only. You cannot post here or create a new thread or review on this forum.

Fri 12/09/03 at 13:30
Regular
"Pouch Ape"
Posts: 14,499
Hi. I ripped and edited this code from the PHP.net site to make a filled polygon from a set of variables posted through a form:

$values = array(
0 => $a_x, // x1
1 => $a_y, // y1
2 => $b_x, // x2
3 => $b_y, // y2
4 => $c_x, // x3
5 => $c_y, // y3
6 => $d_x, // x4
7 => $d_y, // y4
);
$im = imagecreate(500, 500);
$bg = imagecolorallocate($im, 255, 255, 255);
$blue = imagecolorallocate($im, 0, 0, 255);
imagefilledpolygon($im, $values, 4, $blue );
?>

But surprise, surprise, it doesn't work for me. I don't get any error messages though. Any ideas?
Fri 12/09/03 at 17:03
Regular
"Devil in disguise"
Posts: 3,151
The output you showed suggests you're utilising the code incorrectly.
The snippet you posted does work, but remember you need to set

header ("Content-type: image/gif");

at the start of the php code. And of course, make sure you're calling the php script from within an image tag.
Fri 12/09/03 at 16:53
Regular
Posts: 10,437
I had problems with creating images in PHP when I first had a try. Strangely, I tried running the script and it failed for no apparent reason, then I added a PHP Mail script (which I didn't use) and it worked fine.

Although that was just regular squares, so it's much simpler.
Fri 12/09/03 at 15:49
Regular
"Pouch Ape"
Posts: 14,499
gd
GD Support - enabled
GD Version - 2.0 or higher
FreeType Support - enabled
FreeType Linkage - with freetype
GIF Read Support - enabled
GIF Create Support - enabled
JPG Support - enabled
PNG Support - enabled
WBMP Support - enabled

Yip, it's all there.
Fri 12/09/03 at 15:40
Regular
"bing bang bong"
Posts: 3,040
That is pretty strange. Those functions you are calling are part of the GD module for PHP, and if the web-server does not have that installed then they won't work. If you create a page that just calls and view it, that will generate a page of php status information related to the webserver. If you don't see any reference to GD there, then it's not installed and you can't use those functions.
Fri 12/09/03 at 14:57
Regular
"Pouch Ape"
Posts: 14,499
...like this:

PNG  IHDRMPLTEx<IDATx
ձm0P%*Tjl&Q,p{O-_||c
-_#[Dp_o, > X
wK=SGXJ21#Z@0r x֒
k*] D)QV~KK]z h8
]W"sjR@ʽ{[*?^a̭? 
Very strange. I hope that big mess doesn't hold any valuable information!
Fri 12/09/03 at 14:54
Regular
"Pouch Ape"
Posts: 14,499
Development!"

OK, it now looks like this:

$values = array(
0 => $a_x, // x1
1 => $a_y, // y1
2 => $b_x, // x2
3 => $b_y, // y2
4 => $c_x, // x3
5 => $c_y, // y3
6 => $d_x, // x4
7 => $d_y, // y4
);
$im = Imagecreate(500, 500);
$bg = ImageColorAllocate($im, 255, 255, 255);
$blue = ImageColorAllocate($im, 0, 0, 255);
ImageFilledPolygon($im, $values, 4, $blue );
ImagePng ($im);
ImageDestroy ($im);
?>

But all I get is a load of gibberish code.
Fri 12/09/03 at 13:33
Regular
"Pouch Ape"
Posts: 14,499
By the way, the valuse for the variables come from this:

http://www.pocketmonkey.co.uk/3D_box/

It's not *true* 3D, but it gives the impresion pretty good. And it only works in IE because of the layers and stuff.
Fri 12/09/03 at 13:30
Regular
"Pouch Ape"
Posts: 14,499
Hi. I ripped and edited this code from the PHP.net site to make a filled polygon from a set of variables posted through a form:

$values = array(
0 => $a_x, // x1
1 => $a_y, // y1
2 => $b_x, // x2
3 => $b_y, // y2
4 => $c_x, // x3
5 => $c_y, // y3
6 => $d_x, // x4
7 => $d_y, // y4
);
$im = imagecreate(500, 500);
$bg = imagecolorallocate($im, 255, 255, 255);
$blue = imagecolorallocate($im, 0, 0, 255);
imagefilledpolygon($im, $values, 4, $blue );
?>

But surprise, surprise, it doesn't work for me. I don't get any error messages though. Any ideas?

Freeola & GetDotted are rated 5 Stars

Check out some of our customer reviews below:

Many thanks!
You were 100% right - great support!
LOVE it....
You have made it so easy to build & host a website!!!
Gemma

View More Reviews

Need some help? Give us a call on 01376 55 60 60

Go to Support Centre

It appears you are using an old browser, as such, some parts of the Freeola and Getdotted site will not work as intended. Using the latest version of your browser, or another browser such as Google Chrome, Mozilla Firefox, or Opera will provide a better, safer browsing experience for you.