function angle first last height image for if first xa ya break last u

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
function angle(&$first, &$last, &$height, &$w, $image) {
$x = 0;
$y = 0;
for ($i = 0; $i < $w[0]; $i++) {
if ($first[$i][0] == 0) {
$xa = "$i";
$ya = "0";
break;
}
}
$last = up_tool(array_values($last), $height, 16, $count);
for ($i = 15; $i > 0; $i--) {
if ($last[$i][0] == 0) {
$xb = "$i" + $w[2];
$yb = $count;
break;
}
}
$h2 = $yb - $ya;
$w2 = abs($xb - $xa);
$a = atan($h2/$w2);
return imagerotate($image, rad2deg($a), imagecolorallocate($image, 255, 255, 255));
}