G
G
Gildars2015-01-24 21:05:03
PHP
Gildars, 2015-01-24 21:05:03

How to draw a polygon in PHP?

Good afternoon! I had a problem when I decided to change the rectangle script
exp.php
to this image.
exp.gif
Here is the script code itself:

<?
define('PROTECTOR', 1);

@include('files/path.php');
@include($path.'files/db.php');
@include($path.'files/auth.php');
@include($path.'files/func.php');
@include($path.'files/core.php');
@include($path.'files/lvl.php');
$nlvl = $op-$udata[exp];
if($nlvl==0){$nlvl=1;}
$proc=round((($udata[exp]-$ol)/($op-$ol))*100,2);
$max = $op-$ol;
$now = $udata[exp]-$ol;
if($now==0){$now=1;}
$health = 150 / ($max / $now);


$img="pic/exp.gif";
$pic = ImageCreateFromgif($img);
header('Content-Type: image/gif');
$black = imagecolorallocate($pic, 999, 999, 999);
$white = imagecolorallocate($pic, 000, 000, 888);
imagefilledpolygon($pic, array(255,0, 0,24, $health,24, $health,0), 4, $black);
imagestring($pic, 1, 3, 2, ''.$proc.' % ', $white);
imagepolygon($pic, array(0,0, 0,11, 149,11, 149,0), 4, $white);
ob_end_clean();
imagegif($pic);

?>

PS PHP has recently started to study, so I don’t know much, I will be very happy if you explain what needs to be changed in the code.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
M
Max Payne, 2015-01-24
@YardalGedal

Before asking a question here, it was necessary to think - do you really need to draw a polygon in PHP? :)

Z
zooks, 2015-01-25
@zooks

Why mess around and draw a button in PHP? You can make it in a graphical editor and then work with it in PHP - overlay labels and so on.

L
Lev Kekish, 2015-01-25
@levik200

Rectangle in php? - OK..

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question