forked from rahulyhg/astro-11
-
Notifications
You must be signed in to change notification settings - Fork 0
/
synastry_aspect_grid.php
297 lines (244 loc) · 8.51 KB
/
synastry_aspect_grid.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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
<?php
include("constants.php");
$rx1 = safeEscapeString($_GET["rx1"]);
$rx2 = safeEscapeString($_GET["rx2"]);
if (get_magic_quotes_gpc())
{
$longitude1 = unserialize(stripslashes($_GET["p1"]));
$hc1 = unserialize(stripslashes($_GET["hc1"]));
$longitude2 = unserialize(stripslashes($_GET["p2"]));
$hc2 = unserialize(stripslashes($_GET["hc2"]));
}
else
{
$longitude1 = unserialize($_GET["p1"]);
$hc1 = unserialize($_GET["hc1"]);
$longitude2 = unserialize($_GET["p2"]);
$hc2 = unserialize($_GET["hc2"]);
}
$longitude1[LAST_PLANET + 1] = $hc1[1];
$longitude1[LAST_PLANET + 2] = $hc1[10];
$longitude2[LAST_PLANET + 1] = $hc2[1];
$longitude2[LAST_PLANET + 2] = $hc2[10];
// set the content-type
header("Content-type: image/png");
// create the blank image
$overall_size = 475; //add a planet
$extra_width = 255 + 100; //in order to make total width = 705 + 125
$margins = 20; //left and right margins on the background graphic
$im = @imagecreatetruecolor($overall_size + $extra_width, $overall_size) or die("Cannot initialize new GD image stream");
// specify the colors
$white = imagecolorallocate($im, 255, 255, 255);
$red = imagecolorallocate($im, 255, 0, 0);
$blue = imagecolorallocate($im, 0, 0, 255);
$magenta = imagecolorallocate($im, 255, 0, 255);
$yellow = imagecolorallocate($im, 255, 255, 0);
$cyan = imagecolorallocate($im, 0, 255, 255);
$green = imagecolorallocate($im, 0, 224, 0);
$grey = imagecolorallocate($im, 127, 127, 127);
$black = imagecolorallocate($im, 0, 0, 0);
$lavender = imagecolorallocate($im, 160, 0, 255);
$orange = imagecolorallocate($im, 255, 127, 0);
$light_blue = imagecolorallocate($im, 239, 255, 255);
$pl_name[0] = "Sun";
$pl_name[1] = "Moon";
$pl_name[2] = "Mercury";
$pl_name[3] = "Venus";
$pl_name[4] = "Mars";
$pl_name[5] = "Jupiter";
$pl_name[6] = "Saturn";
$pl_name[7] = "Uranus";
$pl_name[8] = "Neptune";
$pl_name[9] = "Pluto";
$pl_name[10] = "Chiron";
$pl_name[11] = "Lilith"; //add a planet
$pl_name[12] = "True Node";
$pl_name[13] = "P. of Fortune";
$pl_name[14] = "Vertex";
$pl_name[15] = "Ascendant";
$pl_name[16] = "Midheaven";
$pl_glyph[0] = 81;
$pl_glyph[1] = 87;
$pl_glyph[2] = 69;
$pl_glyph[3] = 82;
$pl_glyph[4] = 84;
$pl_glyph[5] = 89;
$pl_glyph[6] = 85;
$pl_glyph[7] = 73;
$pl_glyph[8] = 79;
$pl_glyph[9] = 80;
$pl_glyph[10] = 77;
$pl_glyph[11] = 96; //add a planet
$pl_glyph[12] = 141;
$pl_glyph[13] = 60;
$pl_glyph[14] = 109; //Vertex
$pl_glyph[15] = 90; //Ascendant
$pl_glyph[16] = 88; //Midheaven
$asp_color[1] = $blue;
$asp_color[2] = $red;
$asp_color[3] = $green;
$asp_color[4] = $magenta;
$asp_color[5] = $cyan;
$asp_color[6] = $orange;
$asp_glyph[1] = 113; // 0 deg
$asp_glyph[2] = 119; //180 deg
$asp_glyph[3] = 101; //120 deg
$asp_glyph[4] = 114; // 90 deg
$asp_glyph[5] = 111; //150 deg
$asp_glyph[6] = 116; // 60 deg
$sign_glyph[1] = 97;
$sign_glyph[2] = 115;
$sign_glyph[3] = 100;
$sign_glyph[4] = 102;
$sign_glyph[5] = 103;
$sign_glyph[6] = 104;
$sign_glyph[7] = 106;
$sign_glyph[8] = 107;
$sign_glyph[9] = 108;
$sign_glyph[10] = 122;
$sign_glyph[11] = 120;
$sign_glyph[12] = 99;
$cell_width = 25;
$cell_height = 25;
$last_planet_num = 16; //add a planet
$num_planets = $last_planet_num + 1;
$left_margin_planet_table = ($num_planets + 0.5) * $cell_width;
// ------------------------------------------
// create rectangle on blank image
imagefilledrectangle($im, 0, 0, $overall_size + $extra_width, $overall_size, $white); //705 x 475 - add a planet
// MUST BE HERE - I DO NOT KNOW WHY - MAYBE TO PRIME THE PUMP
imagettftext($im, 10, 0, 0, 0, $black, ARIAL_TTF, " ");
// ------------------------------------------
// draw the grid - horizontal lines
for ($i = 0; $i <= $last_planet_num + 1; $i++)
{
imageline($im, $margins, $cell_height * ($i + 1), $margins + $cell_width * $num_planets, $cell_height * ($i + 1), $black);
}
// draw the grid - vertical lines
for ($i = 0; $i <= $last_planet_num + 1; $i++)
{
imageline($im, $margins + $cell_width * $i, $cell_height * ($num_planets + 1), $margins + $cell_width * $i, $cell_height, $black);
}
// ------------------------------------------
// draw in the planet glyphs
for ($i = 0; $i <= $last_planet_num; $i++)
{
drawboldtext($im, 18, 0, $margins + $i * $cell_width, $cell_height, $black, HAMBURG_TTF, chr($pl_glyph[$i]), 0); //across the top
// display planet data in the right-hand table
drawboldtext($im, 16, 0, $margins + $left_margin_planet_table, $cell_height + $cell_height * ($i + 1), $red, HAMBURG_TTF, chr($pl_glyph[$i]), 0);
imagettftext($im, 10, 0, $margins + $left_margin_planet_table + $cell_width * 2, $cell_height + $cell_height * ($i + 1) - 3, $blue, ARIAL_TTF, $pl_name[$i]);
$sign_num1 = floor($longitude1[$i] / 30) + 1;
drawboldtext($im, 14, 0, $margins + $left_margin_planet_table + $cell_width * 5, $cell_height + $cell_height * ($i + 1), $black, HAMBURG_TTF, chr($sign_glyph[$sign_num1]), 0);
imagettftext($im, 10, 0, $margins + $left_margin_planet_table + $cell_width * 6, $cell_height + $cell_height * ($i + 1) - 3, $blue, ARIAL_TTF, Convert_Longitude($longitude1[$i]) . " " . $rx1[$i]);
$sign_num2 = floor($longitude2[$i] / 30) + 1;
drawboldtext($im, 14, 0, $margins + $left_margin_planet_table + $cell_width * 10, $cell_height + $cell_height * ($i + 1), $red, HAMBURG_TTF, chr($sign_glyph[$sign_num2]), 0);
imagettftext($im, 10, 0, $margins + $left_margin_planet_table + $cell_width * 11, $cell_height + $cell_height * ($i + 1) - 3, $blue, ARIAL_TTF, Convert_Longitude($longitude2[$i]) . " " . $rx2[$i]);
}
// ------------------------------------------
// display the aspect glyphs in the aspect grid
for ($i = 0; $i <= $last_planet_num; $i++)
{
for ($j = 0; $j <= $last_planet_num; $j++)
{
$q = 0;
$da = Abs($longitude1[$i] - $longitude2[$j]);
if ($da > 180)
{
$da = 360 - $da;
}
// set orb - 8 if Sun or Moon, 6 if not Sun or Moon
if ($i == 0 Or $i == 1 Or $j == 0 Or $j == 1)
{
$orb = 8;
}
else
{
$orb = 6;
}
// is there an aspect within orb?
if ($da <= $orb)
{
$q = 1;
}
elseif (($da <= (60 + $orb)) And ($da >= (60 - $orb)))
{
$q = 6;
}
elseif (($da <= (90 + $orb)) And ($da >= (90 - $orb)))
{
$q = 4;
}
elseif (($da <= (120 + $orb)) And ($da >= (120 - $orb)))
{
$q = 3;
}
elseif (($da <= (150 + $orb)) And ($da >= (150 - $orb)))
{
$q = 5;
}
elseif ($da >= (180 - $orb))
{
$q = 2;
}
if ($q > 0)
{
drawboldtext($im, 14, 0, $margins + $cell_width * ($i + 0.15), $cell_height + $cell_height * ($j + 1 - 0.20), $asp_color[$q], HAMBURG_TTF, chr($asp_glyph[$q]), 0);
}
}
}
// draw the image in png format - using imagepng() results in clearer text compared with imagejpeg()
imagepng($im);
imagedestroy($im);
exit();
Function safeEscapeString($string)
{
// replace HTML tags '<>' with '[]'
$temp1 = str_replace("<", "[", $string);
$temp2 = str_replace(">", "]", $temp1);
// but keep <br> or <br />
// turn <br> into <br /> so later it will be turned into ""
// using just <br> will add extra blank lines
$temp1 = str_replace("[br]", "<br />", $temp2);
$temp2 = str_replace("[br /]", "<br />", $temp1);
if (get_magic_quotes_gpc())
{
return $temp2;
}
else
{
return mysql_escape_string($temp2);
}
}
Function Convert_Longitude($longitude)
{
$signs = array (0 => 'Ari', 'Tau', 'Gem', 'Can', 'Leo', 'Vir', 'Lib', 'Sco', 'Sag', 'Cap', 'Aqu', 'Pis');
$sign_num = floor($longitude / 30);
$pos_in_sign = $longitude - ($sign_num * 30);
$deg = floor($pos_in_sign);
$full_min = ($pos_in_sign - $deg) * 60;
$min = floor($full_min);
$full_sec = round(($full_min - $min) * 60);
if ($deg < 10)
{
$deg = "0" . $deg;
}
if ($min < 10)
{
$min = "0" . $min;
}
if ($full_sec < 10)
{
$full_sec = "0" . $full_sec;
}
return $deg . " " . $signs[$sign_num] . " " . $min . "' " . $full_sec . chr(34);
}
Function drawboldtext($image, $size, $angle, $x_cord, $y_cord, $clr_to_use, $fontfile, $text, $boldness)
{
$_x = array(1, 0, 1, 0, -1, -1, 1, 0, -1);
$_y = array(0, -1, -1, 0, 0, -1, 1, 1, 1);
for($n = 0; $n <= $boldness; $n++)
{
ImageTTFText($image, $size, $angle, $x_cord+$_x[$n], $y_cord+$_y[$n], $clr_to_use, $fontfile, $text);
}
}
?>