<?php
$number
=
$_POST
[
"number"
];
$name
=
$_POST
[
"name"
];
$length
=
$_POST
[
"length"
];
$width
=
$_POST
[
"width"
];
header(
"Content-type: image/png"
);
$im
= imagecreatetruecolor(
$length
,
$width
);
$bgcolor
= ImageColorAllocate (
$im
, 153, 204, 255);
imagefill(
$im
, 0, 0,
$bgcolor
);
$black
= ImageColorAllocate (
$im
, 0, 0, 0);
$thick
= 20;
$margin
= 40;
$startx
= 0 +
$margin
;
$starty
= 0 +
$margin
;
$endx
=
$length
-
$margin
;
$endy
=
$starty
;
imagelinethick(
$im
,
$startx
,
$starty
,
$endx
,
$endy
,
$black
,
$thick
);
$string
=
"Number:"
.
$number
.
"\nName:"
.
$name
;
$font
=
"fireflysung.ttf"
;
ImageTTFText(
$im
, 20, 0, (
$length
/2)-40,(
$width
/2)-10,
$black
,
$font
,
$string
);
$red
= ImageColorAllocate (
$im
, 255, 0, 0);
arrow(
$im
, 150,150, 350,150,
$length
/50,
$width
/50,
$red
);
imagepng(
$im
);
imagedestroy(
$im
);
function
imagelinethick(
$image
,
$x1
,
$y1
,
$x2
,
$y2
,
$color
,
$thick
= 1)
{
if
(
$thick
== 1) {
return
imageline(
$image
,
$x1
,
$y1
,
$x2
,
$y2
,
$color
);
}
$t
=
$thick
/ 2 - 0.5;
if
(
$x1
==
$x2
||
$y1
==
$y2
) {
return
imagefilledrectangle(
$image
,
round
(min(
$x1
,
$x2
) -
$t
),
round
(min(
$y1
,
$y2
) -
$t
),
round
(max(
$x1
,
$x2
) +
$t
),
round
(max(
$y1
,
$y2
) +
$t
),
$color
);
}
$k
= (
$y2
-
$y1
) / (
$x2
-
$x1
);
$a
=
$t
/ sqrt(1 + pow(
$k
, 2));
$points
=
array
(
round
(
$x1
- (1+
$k
)*
$a
),
round
(
$y1
+ (1-
$k
)*
$a
),
round
(
$x1
- (1-
$k
)*
$a
),
round
(
$y1
- (1+
$k
)*
$a
),
round
(
$x2
+ (1+
$k
)*
$a
),
round
(
$y2
- (1-
$k
)*
$a
),
round
(
$x2
+ (1-
$k
)*
$a
),
round
(
$y2
+ (1+
$k
)*
$a
),
);
imagefilledpolygon(
$image
,
$points
, 4,
$color
);
return
imagepolygon(
$image
,
$points
, 4,
$color
);
}
function
arrow(
$im
,
$x1
,
$y1
,
$x2
,
$y2
,
$alength
,
$awidth
,
$color
) {
$distance
= sqrt(pow(
$x1
-
$x2
, 2) + pow(
$y1
-
$y2
, 2));
$dx
=
$x2
+ (
$x1
-
$x2
) *
$alength
/
$distance
;
$dy
=
$y2
+ (
$y1
-
$y2
) *
$alength
/
$distance
;
$k
=
$awidth
/
$alength
;
$x2o
=
$x2
-
$dx
;
$y2o
=
$dy
-
$y2
;
$x3
=
$y2o
*
$k
+
$dx
;
$y3
=
$x2o
*
$k
+
$dy
;
$x4
=
$dx
-
$y2o
*
$k
;
$y4
=
$dy
-
$x2o
*
$k
;
imagelinethick(
$im
,
$x1
,
$y1
,
$dx
,
$dy
,
$color
,3);
imagefilledpolygon(
$im
,
array
(
$x2
,
$y2
,
$x3
,
$y3
,
$x4
,
$y4
), 3,
$color
);
}
?>