blob: 8548b54f6592f2b97c433472e6a43d73b4f0733e [file] [log] [blame]
John Park91e69732019-03-03 13:12:43 -08001import cairo
2from color import Color, palette
3from constants import *
4import numpy as np
5
James Kuszmaul1c933e02020-03-07 16:17:51 -08006
John Park91e69732019-03-03 13:12:43 -08007def set_color(cr, color, a=1):
8 if color.a == 1.0:
9 cr.set_source_rgba(color.r, color.g, color.b, a)
10 else:
11 cr.set_source_rgba(color.r, color.g, color.b, color.a)
12
13
14def draw_px_cross(cr, x, y, length_px, color=palette["RED"]):
15 """Draws a cross with fixed dimensions in pixel space."""
16 set_color(cr, color)
17 cr.move_to(x, y - length_px)
18 cr.line_to(x, y + length_px)
19 cr.stroke()
20
21 cr.move_to(x - length_px, y)
22 cr.line_to(x + length_px, y)
23 cr.stroke()
24 set_color(cr, palette["WHITE"])
25
26
27def draw_px_x(cr, x, y, length_px1, color=palette["BLACK"]):
28 """Draws a x with fixed dimensions in pixel space."""
29 length_px = length_px1 / np.sqrt(2)
30 set_color(cr, color)
31 cr.move_to(x - length_px, y - length_px)
32 cr.line_to(x + length_px, y + length_px)
33 cr.stroke()
34
35 cr.move_to(x - length_px, y + length_px)
36 cr.line_to(x + length_px, y - length_px)
37 cr.stroke()
38 set_color(cr, palette["WHITE"])
39
James Kuszmaul1c933e02020-03-07 16:17:51 -080040
41def draw_circle(cr, x, y, radius, color=palette["RED"]):
John Parkcf545162020-02-23 20:07:25 -080042 set_color(cr, color)
James Kuszmaul1c933e02020-03-07 16:17:51 -080043 cr.arc(x, y, radius, 0, 2 * np.pi)
John Parkcf545162020-02-23 20:07:25 -080044 cr.fill()
45 cr.stroke()
John Park91e69732019-03-03 13:12:43 -080046
James Kuszmaul1c933e02020-03-07 16:17:51 -080047
John Park91e69732019-03-03 13:12:43 -080048def draw_control_points(cr, points, width=10, radius=4, color=palette["BLUE"]):
49 for i in range(0, len(points)):
50 draw_px_x(cr, points[i][0], points[i][1], width, color)
51 set_color(cr, color)
52 cr.arc(points[i][0], points[i][1], radius, 0, 2.0 * np.pi)
53 cr.fill()
54 set_color(cr, palette["WHITE"])
55
James Kuszmaul1c933e02020-03-07 16:17:51 -080056
John Park91e69732019-03-03 13:12:43 -080057def display_text(cr, text, widtha, heighta, widthb, heightb):
58 cr.scale(widtha, -heighta)
59 cr.show_text(text)
60 cr.scale(widthb, -heightb)
61
James Kuszmaul1c933e02020-03-07 16:17:51 -080062
Ravago Jones5f787df2021-01-23 16:26:27 -080063def draw_at_home_grid(cr):
64 field = np.zeros(shape=(5, 11), dtype=bool)
65 # field[row from bottom][column from left]
66
67 if GALACTIC_SEARCH in FIELD.tags:
68 # Galactic search start zone
69 field[1][0] = True
70 field[3][0] = True
71
72 # Galactic search end zone
73 field[1][10] = True
74 field[3][10] = True
75
76 if ARED in FIELD.tags:
77 field[4][5] = True
78 field[2][2] = True
79 field[1][4] = True
80 elif ABLUE in FIELD.tags:
81 field[0][5] = True
82 field[3][6] = True
83 field[2][8] = True
84 elif BRED in FIELD.tags:
85 field[3][2] = True
86 field[1][4] = True
87 field[3][6] = True
88 elif BBLUE in FIELD.tags:
89 field[1][5] = True
90 field[3][7] = True
91 field[1][9] = True
92 elif AUTONAV in FIELD.tags:
93 # start/end zone
94 field[1][0] = True
95 field[1][1] = True
96 field[3][0] = True
97 field[3][1] = True
98
99 if BAREL in FIELD.tags:
100 # barrels
101 field[1][4] = True
102 field[3][8] = True
103 field[1][10] = True
104 if BARREL in FIELD.tags:
105 field[1][3:8] = True # 3 to 7 inclusive
106 field[1][9] = True
107 if BOUNCE in FIELD.tags:
108 # turn on two rows
109 field[1][:11] = True
110 field[3][:11] = True
111
112 # turn off parts of rows
113 field[3][2] = False
114 field[3][5] = False
115 field[3][8] = False
116
117 field[1][3] = False
118 field[1][5] = False
119 field[1][8] = False
120
121 # markers to hit
122 field[4][2] = True
123 field[4][5] = True
124 field[4][8] = True
125
126 # Move origin to bottom left
127 xorigin = -mToPx(FIELD.width) / 2.0
128 yorigin = -mToPx(FIELD.length) / 2.0
129
130 color = palette["BLACK"]
131 # markers are at least 6.35 x 6.35 cm
132 marker_length = mToPx(0.0635)
133
134 for row, row_array in enumerate(field):
135 for column, has_marker in enumerate(row_array):
136 one_indexed_row = row + 1
137 one_indexed_column = column + 1
138
139 # 76.2 cm increments
140 pos_y = one_indexed_row * mToPx(0.762)
141 pos_x = one_indexed_column * mToPx(0.762)
142
143 if has_marker:
144 draw_px_x(cr, xorigin + pos_x, yorigin + pos_y, marker_length,
145 color)
146
147
John Parkcf545162020-02-23 20:07:25 -0800148def markers(cr):
149 SHOW_MARKERS = False
150 if SHOW_MARKERS:
151 # Shield Generator Reference
152 color = palette["BLUE"]
James Kuszmaul1c933e02020-03-07 16:17:51 -0800153 yorigin = 0 - SCREEN_SIZE / 2 # Move origin to bottom left
John Parkcf545162020-02-23 20:07:25 -0800154 # Top Left
James Kuszmaul1c933e02020-03-07 16:17:51 -0800155 draw_circle(cr, mToPx(inToM(206.625)),
156 yorigin + mToPx(inToM(212.097), True), 10, color)
John Parkcf545162020-02-23 20:07:25 -0800157 # Top Right
James Kuszmaul1c933e02020-03-07 16:17:51 -0800158 draw_circle(cr, mToPx(inToM(373.616)),
159 yorigin + mToPx(inToM(281.26), True), 10, color)
John Parkcf545162020-02-23 20:07:25 -0800160 # Bottom Right
James Kuszmaul1c933e02020-03-07 16:17:51 -0800161 draw_circle(cr, mToPx(inToM(422.625)),
162 yorigin + mToPx(inToM(124.67), True), 10, color)
John Parkcf545162020-02-23 20:07:25 -0800163 # Bottom Left
James Kuszmaul1c933e02020-03-07 16:17:51 -0800164 draw_circle(cr, mToPx(inToM(255.634)),
165 yorigin + mToPx(inToM(55.5), True), 10, color)
John Parkcf545162020-02-23 20:07:25 -0800166
167 # Trench Run Reference
168 color = palette["GREEN"]
169 # Bottom Trench Run
170 # Bottom Right
171 draw_circle(cr, mToPx(inToM(206.625)), yorigin, 10, color)
172 # Top Right
James Kuszmaul1c933e02020-03-07 16:17:51 -0800173 draw_circle(cr, mToPx(inToM(206.625)),
174 yorigin + mToPx(inToM(55.5), True), 10, color)
John Parkcf545162020-02-23 20:07:25 -0800175 # Top Left
James Kuszmaul1c933e02020-03-07 16:17:51 -0800176 draw_circle(cr, mToPx(inToM(422.625)),
177 yorigin + mToPx(inToM(55.5), True), 10, color)
John Parkcf545162020-02-23 20:07:25 -0800178 # Bottom Left
179 draw_circle(cr, mToPx(inToM(422.625)), yorigin, 10, color)
180
181 # Top Trench Run
182 # Top Right
James Kuszmaul1c933e02020-03-07 16:17:51 -0800183 draw_circle(cr, mToPx(inToM(206.625)),
184 yorigin + mToPx(inToM(323.25), True), 10, color)
John Parkcf545162020-02-23 20:07:25 -0800185 # Bottom Right
James Kuszmaul1c933e02020-03-07 16:17:51 -0800186 draw_circle(cr, mToPx(inToM(206.625)),
187 yorigin + mToPx(inToM(281.26), True), 10, color)
John Parkcf545162020-02-23 20:07:25 -0800188 # Top Left
James Kuszmaul1c933e02020-03-07 16:17:51 -0800189 draw_circle(cr, mToPx(inToM(422.625)),
190 yorigin + mToPx(inToM(281.26), True), 10, color)
John Parkcf545162020-02-23 20:07:25 -0800191 # Bottom Left
James Kuszmaul1c933e02020-03-07 16:17:51 -0800192 draw_circle(cr, mToPx(inToM(422.625)),
193 yorigin + mToPx(inToM(323.25), True), 10, color)
John Parkcf545162020-02-23 20:07:25 -0800194 cr.stroke()
195
John Parkcf545162020-02-23 20:07:25 -0800196
James Kuszmaul1c933e02020-03-07 16:17:51 -0800197def draw_init_lines(cr):
198 set_color(cr, palette["RED"])
Ravago Jones5f787df2021-01-23 16:26:27 -0800199 init_line_x = FIELD.width / 2.0 - inToM(120)
200 init_start_y = -FIELD.length / 2.0
201 init_end_y = FIELD.length / 2.0
James Kuszmaul1c933e02020-03-07 16:17:51 -0800202 cr.move_to(mToPx(init_line_x), mToPx(init_start_y))
203 cr.line_to(mToPx(init_line_x), mToPx(init_end_y))
204
205 cr.move_to(mToPx(-init_line_x), mToPx(init_start_y))
206 cr.line_to(mToPx(-init_line_x), mToPx(init_end_y))
John Parkcf545162020-02-23 20:07:25 -0800207
208 cr.stroke()
209
James Kuszmaul1c933e02020-03-07 16:17:51 -0800210
John Parkcf545162020-02-23 20:07:25 -0800211def draw_trench_run(cr):
Ravago Jones5f787df2021-01-23 16:26:27 -0800212 edge_of_field_y = FIELD.length / 2.0
James Kuszmaul1c933e02020-03-07 16:17:51 -0800213 edge_of_trench_y = edge_of_field_y - inToM(55.5)
214 trench_start_x = inToM(-108.0)
215 trench_length_x = inToM(216.0)
216 ball_line_y = edge_of_field_y - inToM(27.75)
217 ball_one_x = -inToM(72)
218 ball_two_x = -inToM(36)
219 ball_three_x = 0.0
220 # The fourth/fifth balls are referenced off of the init line...
Ravago Jones5f787df2021-01-23 16:26:27 -0800221 ball_fourfive_x = FIELD.width / 2.0 - inToM(120.0 + 130.36)
John Parkcf545162020-02-23 20:07:25 -0800222
James Kuszmaul1c933e02020-03-07 16:17:51 -0800223 for sign in [1.0, -1.0]:
224 set_color(cr, palette["GREEN"])
Ravago Jones26f7ad02021-02-05 15:45:59 -0800225 cr.rectangle(
226 mToPx(sign * trench_start_x), mToPx(sign * edge_of_field_y),
227 mToPx(sign * trench_length_x),
228 mToPx(sign * (edge_of_trench_y - edge_of_field_y)))
James Kuszmaul1c933e02020-03-07 16:17:51 -0800229 cr.stroke()
230 draw_circle(cr, mToPx(sign * ball_one_x), mToPx(sign * ball_line_y),
231 mToPx(0.1), palette["YELLOW"])
232 draw_circle(cr, mToPx(sign * ball_two_x), mToPx(sign * ball_line_y),
233 mToPx(0.1), palette["YELLOW"])
234 draw_circle(cr, mToPx(sign * ball_three_x), mToPx(sign * ball_line_y),
235 mToPx(0.1), palette["YELLOW"])
John Parkcf545162020-02-23 20:07:25 -0800236
237 cr.stroke()
238
James Kuszmaul1c933e02020-03-07 16:17:51 -0800239
John Parkcf545162020-02-23 20:07:25 -0800240def draw_shield_generator(cr):
241 set_color(cr, palette["BLUE"])
James Kuszmaul1c933e02020-03-07 16:17:51 -0800242 cr.save()
243 cr.rotate(22.5 * np.pi / 180.)
244 generator_width = mToPx(inToM(14 * 12 + 0.75))
245 generator_height = mToPx(inToM(13 * 12 + 1.5))
246 cr.rectangle(-generator_width / 2.0, -generator_height / 2.0,
247 generator_width, generator_height)
248 cr.restore()
John Parkcf545162020-02-23 20:07:25 -0800249
250 cr.stroke()
251
James Kuszmaul1c933e02020-03-07 16:17:51 -0800252
253def draw_control_panel(cr): # Base plates are not included
John Parkcf545162020-02-23 20:07:25 -0800254 set_color(cr, palette["LIGHT_GREY"])
Ravago Jones5f787df2021-01-23 16:26:27 -0800255 edge_of_field_y = FIELD.length / 2.0
James Kuszmaul1c933e02020-03-07 16:17:51 -0800256 edge_of_trench_y = edge_of_field_y - inToM(55.5)
Ravago Jones5f787df2021-01-23 16:26:27 -0800257 high_x = inToM(374.59) - FIELD.width / 2.0
James Kuszmaul1c933e02020-03-07 16:17:51 -0800258 low_x = high_x - inToM(30)
259 for sign in [1.0, -1.0]:
260 # Bottom Control Panel
261 # Top Line
262 cr.rectangle(sign * mToPx(high_x), sign * mToPx(edge_of_field_y),
263 -sign * mToPx(inToM(30)), -sign * mToPx(inToM(55.5)))
John Parkcf545162020-02-23 20:07:25 -0800264
265 cr.stroke()
John Park91e69732019-03-03 13:12:43 -0800266
James Kuszmaul1c933e02020-03-07 16:17:51 -0800267
John Park91e69732019-03-03 13:12:43 -0800268def draw_HAB(cr):
269 # BASE Constants
270 X_BASE = 0
271 Y_BASE = 0
272 R = 0.381 - .1
273 BACKWALL_X = X_BASE
274 LOADING_Y = mToPx(4.129151) - mToPx(0.696976)
275 # HAB Levels 2 and 3 called in variables backhab
276 # draw loading stations
277 cr.move_to(0, LOADING_Y)
278 cr.line_to(mToPx(0.6), LOADING_Y)
279 cr.move_to(mToPx(R), LOADING_Y)
280 cr.arc(mToPx(R), LOADING_Y, 5, 0, np.pi * 2.0)
281 cr.move_to(0, -1.0 * LOADING_Y)
282 cr.line_to(mToPx(0.6), -1.0 * LOADING_Y)
283 cr.move_to(mToPx(R), -1.0 * LOADING_Y)
284 cr.arc(mToPx(R), -1.0 * LOADING_Y, 5, 0, np.pi * 2.0)
285
286 # HAB Levels 2 and 3 called in variables backhab
287 WIDTH_BACKHAB = mToPx(1.2192)
288
289 Y_TOP_BACKHAB_BOX = Y_BASE + mToPx(0.6096)
290 BACKHAB_LV2_LENGTH = mToPx(1.016)
291
292 BACKHAB_LV3_LENGTH = mToPx(1.2192)
293 Y_LV3_BOX = Y_TOP_BACKHAB_BOX - BACKHAB_LV3_LENGTH
294
295 Y_BOTTOM_BACKHAB_BOX = Y_LV3_BOX - BACKHAB_LV2_LENGTH
296
297 # HAB LEVEL 1
298 X_LV1_BOX = BACKWALL_X + WIDTH_BACKHAB
299
300 WIDTH_LV1_BOX = mToPx(0.90805)
301 LENGTH_LV1_BOX = mToPx(1.6256)
302
303 Y_BOTTOM_LV1_BOX = Y_BASE - LENGTH_LV1_BOX
304
305 # Ramp off Level 1
306 X_RAMP = X_LV1_BOX
307
308 Y_TOP_RAMP = Y_BASE + LENGTH_LV1_BOX
309 WIDTH_TOP_RAMP = mToPx(1.20015)
310 LENGTH_TOP_RAMP = Y_BASE + mToPx(0.28306)
311
312 X_MIDDLE_RAMP = X_RAMP + WIDTH_LV1_BOX
313 Y_MIDDLE_RAMP = Y_BOTTOM_LV1_BOX
314 LENGTH_MIDDLE_RAMP = 2 * LENGTH_LV1_BOX
315 WIDTH_MIDDLE_RAMP = WIDTH_TOP_RAMP - WIDTH_LV1_BOX
316
317 Y_BOTTOM_RAMP = Y_BASE - LENGTH_LV1_BOX - LENGTH_TOP_RAMP
318
319 # Side Bars to Hold in balls
320 X_BARS = BACKWALL_X
321 WIDTH_BARS = WIDTH_BACKHAB
322 LENGTH_BARS = mToPx(0.574675)
323
324 Y_TOP_BAR = Y_TOP_BACKHAB_BOX + BACKHAB_LV2_LENGTH
325
326 Y_BOTTOM_BAR = Y_BOTTOM_BACKHAB_BOX - LENGTH_BARS
327
328 set_color(cr, palette["BLACK"])
329 cr.rectangle(BACKWALL_X, Y_TOP_BACKHAB_BOX, WIDTH_BACKHAB,
330 BACKHAB_LV2_LENGTH)
331 cr.rectangle(BACKWALL_X, Y_LV3_BOX, WIDTH_BACKHAB, BACKHAB_LV3_LENGTH)
332 cr.rectangle(BACKWALL_X, Y_BOTTOM_BACKHAB_BOX, WIDTH_BACKHAB,
333 BACKHAB_LV2_LENGTH)
334 cr.rectangle(X_LV1_BOX, Y_BASE, WIDTH_LV1_BOX, LENGTH_LV1_BOX)
335 cr.rectangle(X_LV1_BOX, Y_BOTTOM_LV1_BOX, WIDTH_LV1_BOX, LENGTH_LV1_BOX)
336 cr.rectangle(X_RAMP, Y_TOP_RAMP, WIDTH_TOP_RAMP, LENGTH_TOP_RAMP)
337 cr.rectangle(X_MIDDLE_RAMP, Y_MIDDLE_RAMP, WIDTH_MIDDLE_RAMP,
338 LENGTH_MIDDLE_RAMP)
339 cr.rectangle(X_RAMP, Y_BOTTOM_RAMP, WIDTH_TOP_RAMP, LENGTH_TOP_RAMP)
340 cr.rectangle(X_BARS, Y_TOP_BAR, WIDTH_BARS, LENGTH_BARS)
341 cr.rectangle(X_BARS, Y_BOTTOM_BAR, WIDTH_BARS, LENGTH_BARS)
342 cr.stroke()
343
344 cr.set_line_join(cairo.LINE_JOIN_ROUND)
345
346 cr.stroke()
347
348 #draw 0, 0
349 set_color(cr, palette["BLACK"])
350 cr.move_to(0, 0)
351 cr.line_to(0, 0 + mToPx(8.2296 / 2.0))
352 cr.move_to(0, 0)
353 cr.line_to(0, 0 + mToPx(-8.2296 / 2.0))
354 cr.move_to(0, 0)
355 cr.line_to(0 + mToPx(8.2296), 0)
356
357 cr.stroke()
358
359
360def draw_rockets(cr):
361 # BASE Constants
362 X_BASE = mToPx(2.41568)
363 Y_BASE = 0
364 # Robot longitudinal radius
365 R = 0.381
366 near_side_rocket_center = [
367 X_BASE + mToPx((2.89973 + 3.15642) / 2.0), Y_BASE + mToPx(
368 (3.86305 + 3.39548) / 2.0)
369 ]
370 middle_rocket_center = [
371 X_BASE + mToPx((3.15642 + 3.6347) / 2.0), Y_BASE + mToPx(
372 (3.39548 + 3.392380) / 2.0)
373 ]
374 far_side_rocket_center = [
375 X_BASE + mToPx((3.63473 + 3.89984) / 2.0), Y_BASE + mToPx(
376 (3.39238 + 3.86305) / 2.0)
377 ]
378
379 cr.move_to(near_side_rocket_center[0], near_side_rocket_center[1])
380 cr.line_to(near_side_rocket_center[0] - 0.8 * mToPx(0.866),
381 near_side_rocket_center[1] - 0.8 * mToPx(0.5))
382 cr.move_to(near_side_rocket_center[0] - R * mToPx(0.866),
383 near_side_rocket_center[1] - R * mToPx(0.5))
384 cr.arc(near_side_rocket_center[0] - R * mToPx(0.866),
385 near_side_rocket_center[1] - R * mToPx(0.5), 5, 0, np.pi * 2.0)
386
387 cr.move_to(middle_rocket_center[0], middle_rocket_center[1])
388 cr.line_to(middle_rocket_center[0], middle_rocket_center[1] - mToPx(0.8))
389 cr.move_to(middle_rocket_center[0], middle_rocket_center[1] - mToPx(R))
390 cr.arc(middle_rocket_center[0], middle_rocket_center[1] - mToPx(R), 5, 0,
391 np.pi * 2.0)
392
393 cr.move_to(far_side_rocket_center[0], far_side_rocket_center[1])
394 cr.line_to(far_side_rocket_center[0] + 0.8 * mToPx(0.866),
395 far_side_rocket_center[1] - 0.8 * mToPx(0.5))
396 cr.move_to(far_side_rocket_center[0] + R * mToPx(0.866),
397 far_side_rocket_center[1] - R * mToPx(0.5))
398 cr.arc(far_side_rocket_center[0] + R * mToPx(0.866),
399 far_side_rocket_center[1] - R * mToPx(0.5), 5, 0, np.pi * 2.0)
400
401 #print(far_side_rocket_center)
402 near_side_rocket_center = [
403 X_BASE + mToPx((2.89973 + 3.15642) / 2.0), Y_BASE - mToPx(
404 (3.86305 + 3.39548) / 2.0)
405 ]
406 middle_rocket_center = [
407 X_BASE + mToPx((3.15642 + 3.6347) / 2.0), Y_BASE - mToPx(
408 (3.39548 + 3.392380) / 2.0)
409 ]
410 far_side_rocket_center = [
411 X_BASE + mToPx((3.63473 + 3.89984) / 2.0), Y_BASE - mToPx(
412 (3.39238 + 3.86305) / 2.0)
413 ]
414
415 cr.move_to(near_side_rocket_center[0], near_side_rocket_center[1])
416 cr.line_to(near_side_rocket_center[0] - 0.8 * mToPx(0.866),
417 near_side_rocket_center[1] + 0.8 * mToPx(0.5))
418
419 cr.move_to(middle_rocket_center[0], middle_rocket_center[1])
420 cr.line_to(middle_rocket_center[0], middle_rocket_center[1] + mToPx(0.8))
421
422 cr.move_to(far_side_rocket_center[0], far_side_rocket_center[1])
423 cr.line_to(far_side_rocket_center[0] + 0.8 * mToPx(0.866),
424 far_side_rocket_center[1] + 0.8 * mToPx(0.5))
425
426 # Leftmost Line
427 cr.move_to(X_BASE + mToPx(2.89973), Y_BASE + mToPx(3.86305))
428 cr.line_to(X_BASE + mToPx(3.15642), Y_BASE + mToPx(3.39548))
429
430 # Top Line
431 cr.move_to(X_BASE + mToPx(3.15642), Y_BASE + mToPx(3.39548))
432 cr.line_to(X_BASE + mToPx(3.63473), Y_BASE + mToPx(3.39238))
433
434 #Rightmost Line
435 cr.move_to(X_BASE + mToPx(3.63473), Y_BASE + mToPx(3.39238))
436 cr.line_to(X_BASE + mToPx(3.89984), Y_BASE + mToPx(3.86305))
437
438 #Back Line
439 cr.move_to(X_BASE + mToPx(2.89973), Y_BASE + mToPx(3.86305))
440 cr.line_to(X_BASE + mToPx(3.89984), Y_BASE + mToPx(3.86305))
441
442 # Bottom Rocket
443 # Leftmost Line
444 cr.move_to(X_BASE + mToPx(2.89973), Y_BASE - mToPx(3.86305))
445 cr.line_to(X_BASE + mToPx(3.15642), Y_BASE - mToPx(3.39548))
446
447 # Top Line
448 cr.move_to(X_BASE + mToPx(3.15642), Y_BASE - mToPx(3.39548))
449 cr.line_to(X_BASE + mToPx(3.63473), Y_BASE - mToPx(3.39238))
450
451 #Rightmost Line
452 cr.move_to(X_BASE + mToPx(3.63473), Y_BASE - mToPx(3.39238))
453 cr.line_to(X_BASE + mToPx(3.89984), Y_BASE - mToPx(3.86305))
454
455 #Back Line
456 cr.move_to(X_BASE + mToPx(2.89973), Y_BASE - mToPx(3.86305))
457 cr.line_to(X_BASE + mToPx(3.89984), Y_BASE - mToPx(3.86305))
458
459 cr.stroke()
460
461
462def draw_cargo_ship(cr):
463 # BASE Constants
464 X_BASE = 0 + mToPx(5.59435)
465 Y_BASE = 0 + 0 #mToPx(4.129151)
466 R = 0.381 - 0.1
467
468 FRONT_PEG_DELTA_Y = mToPx(0.276352)
469 cr.move_to(X_BASE, Y_BASE + FRONT_PEG_DELTA_Y)
470 cr.line_to(X_BASE - mToPx(0.8), Y_BASE + FRONT_PEG_DELTA_Y)
471
472 cr.move_to(X_BASE, Y_BASE + FRONT_PEG_DELTA_Y)
473 cr.arc(X_BASE - mToPx(R), Y_BASE + FRONT_PEG_DELTA_Y, 5, 0, np.pi * 2.0)
474
475 cr.move_to(X_BASE, Y_BASE - FRONT_PEG_DELTA_Y)
476 cr.line_to(X_BASE - mToPx(0.8), Y_BASE - FRONT_PEG_DELTA_Y)
477
478 cr.move_to(X_BASE, Y_BASE - FRONT_PEG_DELTA_Y)
479 cr.arc(X_BASE - mToPx(R), Y_BASE - FRONT_PEG_DELTA_Y, 5, 0, np.pi * 2.0)
480
481 SIDE_PEG_Y = mToPx(1.41605 / 2.0)
482 SIDE_PEG_X = X_BASE + mToPx(1.148842)
483 SIDE_PEG_DX = mToPx(0.55245)
484
485 cr.move_to(SIDE_PEG_X, SIDE_PEG_Y)
486 cr.line_to(SIDE_PEG_X, SIDE_PEG_Y + mToPx(0.8))
487 cr.move_to(SIDE_PEG_X, SIDE_PEG_Y + mToPx(R))
488 cr.arc(SIDE_PEG_X, SIDE_PEG_Y + mToPx(R), 5, 0, np.pi * 2.0)
489
490 cr.move_to(SIDE_PEG_X + SIDE_PEG_DX, SIDE_PEG_Y)
491 cr.line_to(SIDE_PEG_X + SIDE_PEG_DX, SIDE_PEG_Y + mToPx(0.8))
492 cr.move_to(SIDE_PEG_X + SIDE_PEG_DX, SIDE_PEG_Y + mToPx(R))
493 cr.arc(SIDE_PEG_X + SIDE_PEG_DX, SIDE_PEG_Y + mToPx(R), 5, 0, np.pi * 2.0)
494
495 cr.move_to(SIDE_PEG_X + 2.0 * SIDE_PEG_DX, SIDE_PEG_Y)
496 cr.line_to(SIDE_PEG_X + 2.0 * SIDE_PEG_DX, SIDE_PEG_Y + mToPx(0.8))
497 cr.move_to(SIDE_PEG_X + 2.0 * SIDE_PEG_DX, SIDE_PEG_Y + mToPx(R))
498 cr.arc(SIDE_PEG_X + 2.0 * SIDE_PEG_DX, SIDE_PEG_Y + mToPx(R), 5, 0,
499 np.pi * 2.0)
500
501 cr.move_to(SIDE_PEG_X, -1.0 * SIDE_PEG_Y)
502 cr.line_to(SIDE_PEG_X, -1.0 * SIDE_PEG_Y - mToPx(0.8))
503 cr.move_to(SIDE_PEG_X, -1.0 * SIDE_PEG_Y - mToPx(R))
504 cr.arc(SIDE_PEG_X, -1.0 * SIDE_PEG_Y - mToPx(R), 5, 0, np.pi * 2.0)
505
506 cr.move_to(SIDE_PEG_X + SIDE_PEG_DX, -1.0 * SIDE_PEG_Y)
507 cr.line_to(SIDE_PEG_X + SIDE_PEG_DX, -1.0 * SIDE_PEG_Y - mToPx(0.8))
508 cr.move_to(SIDE_PEG_X + SIDE_PEG_DX, -1.0 * SIDE_PEG_Y - mToPx(R))
509 cr.arc(SIDE_PEG_X + SIDE_PEG_DX, -1.0 * SIDE_PEG_Y - mToPx(R), 5, 0,
510 np.pi * 2.0)
511
512 cr.move_to(SIDE_PEG_X + 2.0 * SIDE_PEG_DX, -1.0 * SIDE_PEG_Y)
513 cr.line_to(SIDE_PEG_X + 2.0 * SIDE_PEG_DX, -1.0 * SIDE_PEG_Y - mToPx(0.8))
514 cr.move_to(SIDE_PEG_X + 2.0 * SIDE_PEG_DX, -1.0 * SIDE_PEG_Y - mToPx(R))
515 cr.arc(SIDE_PEG_X + 2.0 * SIDE_PEG_DX, -1.0 * SIDE_PEG_Y - mToPx(R), 5, 0,
516 np.pi * 2.0)
517
518 cr.rectangle(X_BASE, Y_BASE - mToPx(1.41605 / 2.0), mToPx(2.43205),
519 mToPx(1.41605))
520 cr.stroke()
521
James Kuszmaul1c933e02020-03-07 16:17:51 -0800522
John Park91e69732019-03-03 13:12:43 -0800523def draw_points(cr, p, size):
524 for i in range(0, len(p)):
Ravago Jones26f7ad02021-02-05 15:45:59 -0800525 draw_px_cross(cr, p[i][0], p[i][1], size, Color(
526 0, np.sqrt(0.2 * i), 0))