This repository has been archived by the owner on Feb 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvyplnovani-scan-line.php
120 lines (83 loc) · 1.87 KB
/
vyplnovani-scan-line.php
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
<?php
require_once('fce.php');
$pic = vytvorObrazek();
//nastaveni barvy
$barva = array();
$barva["cerna"] = ImageColorAllocate ($pic, 0, 0, 0);
$barva["bila"] = ImageColorAllocate($pic, 255, 255, 255);
$barva["zelena"] = ImageColorAllocate ($pic, 34, 177, 76);
$barva["cervena"] = ImageColorAllocate ($pic, 255, 0, 0);
//souradnice uplneho lomenne cary
$bodX = array(50,70,50,10,50);
$bodY = array(2,50,30,50,2);
$velikostPole = sizeof($bodyY);
//hranice
//zapis obecne primky
sort($bodY); //Seradime od min po max hodnotu
$min=$bodY[0];
$max=$bodY[4];
$bodX = array(50,70,50,10,50);
$bodY = array(2,50,30,50,2);
for($i=0; $i<4; $i++) {
$tmp = $i+1;
$zx[$i]=$bodX[$i];
$zy[$i]=$bodY[$i];
$kx[$i]=$bodX[$tmp];
$ky[$i]=$bodY[$tmp];
/*
//uplna lomenna cara
$xp=$zy-$ky;
$yp=$kx-$zx;
$cp=$zx*$ky-$kx*$zy;
if ($zy > $ky){
$apom=$zy;
$zy=$ky;
$ky=$apom;
}
*/
$xp[$i] = $zy[$i]-$ky[$i];
$yp[$i] = $kx[$i]-$zx[$i];
$cp[$i] = $zx[$i]*$ky[$i]-$kx[$i]*$zy[$i];
if ($zy[$i] > $ky[$i]) {
$apom = $zy[$i];
$zy[$i] = $ky[$i];
$ky[$i] = $apom;
}
}
for($y=$min; $y<$max; $y++) {
$pocet=0;
for($a=0;$a<4;$a++) {
if ( $y> $zy[$a]-1 and $y<$ky[$a]+1) {
//for($y=2;$y<15;$y++){
$pom=0-($yp[$a]*$y);
$x[$a]=ceil(($pom - $cp[$a])/$xp[$a]);
$pocet++;
} else {
$x[$a]=1000;
}
}
if($pocet<>1) {
if($pocet==4) {
sort($x);
if($x[0]<>$x[1]) {
nakresliUseckuBres($x[0],$y,$x[1],$y,$barva["cervena"]);
nakresliUseckuBres($x[2],$y,$x[3],$y,$barva["cervena"]);
} else {
nakresliUseckuBres($x[0],$y,$x[3],$y,$barva["cervena"]);
}
} else {
if($pocet==3) {
sort($x);
nakresliUseckuBres($x[0],$y,$x[2],$y,$barva["cervena"]);
} else {
if ($pocet==2) {
sort($x);
nakresliUseckuBres($x[0],$y,$x[1],$y,$barva["cervena"]);
}
}
}
}//if
}//for
ImagePNG ($pic);
imagedestroy($pic);
?>