blob: 332f37e655bc9c1f1b6dbe2ef0c5bacbef4d8a77 [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
John Parkcf545162020-02-23 20:07:25 -080063def markers(cr):
64 SHOW_MARKERS = False
65 if SHOW_MARKERS:
66 # Shield Generator Reference
67 color = palette["BLUE"]
James Kuszmaul1c933e02020-03-07 16:17:51 -080068 yorigin = 0 - SCREEN_SIZE / 2 # Move origin to bottom left
John Parkcf545162020-02-23 20:07:25 -080069 # Top Left
James Kuszmaul1c933e02020-03-07 16:17:51 -080070 draw_circle(cr, mToPx(inToM(206.625)),
71 yorigin + mToPx(inToM(212.097), True), 10, color)
John Parkcf545162020-02-23 20:07:25 -080072 # Top Right
James Kuszmaul1c933e02020-03-07 16:17:51 -080073 draw_circle(cr, mToPx(inToM(373.616)),
74 yorigin + mToPx(inToM(281.26), True), 10, color)
John Parkcf545162020-02-23 20:07:25 -080075 # Bottom Right
James Kuszmaul1c933e02020-03-07 16:17:51 -080076 draw_circle(cr, mToPx(inToM(422.625)),
77 yorigin + mToPx(inToM(124.67), True), 10, color)
John Parkcf545162020-02-23 20:07:25 -080078 # Bottom Left
James Kuszmaul1c933e02020-03-07 16:17:51 -080079 draw_circle(cr, mToPx(inToM(255.634)),
80 yorigin + mToPx(inToM(55.5), True), 10, color)
John Parkcf545162020-02-23 20:07:25 -080081
82 # Trench Run Reference
83 color = palette["GREEN"]
84 # Bottom Trench Run
85 # Bottom Right
86 draw_circle(cr, mToPx(inToM(206.625)), yorigin, 10, color)
87 # Top Right
James Kuszmaul1c933e02020-03-07 16:17:51 -080088 draw_circle(cr, mToPx(inToM(206.625)),
89 yorigin + mToPx(inToM(55.5), True), 10, color)
John Parkcf545162020-02-23 20:07:25 -080090 # Top Left
James Kuszmaul1c933e02020-03-07 16:17:51 -080091 draw_circle(cr, mToPx(inToM(422.625)),
92 yorigin + mToPx(inToM(55.5), True), 10, color)
John Parkcf545162020-02-23 20:07:25 -080093 # Bottom Left
94 draw_circle(cr, mToPx(inToM(422.625)), yorigin, 10, color)
95
96 # Top Trench Run
97 # Top Right
James Kuszmaul1c933e02020-03-07 16:17:51 -080098 draw_circle(cr, mToPx(inToM(206.625)),
99 yorigin + mToPx(inToM(323.25), True), 10, color)
John Parkcf545162020-02-23 20:07:25 -0800100 # Bottom Right
James Kuszmaul1c933e02020-03-07 16:17:51 -0800101 draw_circle(cr, mToPx(inToM(206.625)),
102 yorigin + mToPx(inToM(281.26), True), 10, color)
John Parkcf545162020-02-23 20:07:25 -0800103 # Top Left
James Kuszmaul1c933e02020-03-07 16:17:51 -0800104 draw_circle(cr, mToPx(inToM(422.625)),
105 yorigin + mToPx(inToM(281.26), True), 10, color)
John Parkcf545162020-02-23 20:07:25 -0800106 # Bottom Left
James Kuszmaul1c933e02020-03-07 16:17:51 -0800107 draw_circle(cr, mToPx(inToM(422.625)),
108 yorigin + mToPx(inToM(323.25), True), 10, color)
John Parkcf545162020-02-23 20:07:25 -0800109 cr.stroke()
110
John Parkcf545162020-02-23 20:07:25 -0800111
James Kuszmaul1c933e02020-03-07 16:17:51 -0800112def draw_init_lines(cr):
113 set_color(cr, palette["RED"])
114 init_line_x = WIDTH_OF_FIELD_IN_METERS / 2.0 - inToM(120)
115 init_start_y = -LENGTH_OF_FIELD_IN_METERS / 2.0
116 init_end_y = LENGTH_OF_FIELD_IN_METERS / 2.0
117 cr.move_to(mToPx(init_line_x), mToPx(init_start_y))
118 cr.line_to(mToPx(init_line_x), mToPx(init_end_y))
119
120 cr.move_to(mToPx(-init_line_x), mToPx(init_start_y))
121 cr.line_to(mToPx(-init_line_x), mToPx(init_end_y))
John Parkcf545162020-02-23 20:07:25 -0800122
123 cr.stroke()
124
James Kuszmaul1c933e02020-03-07 16:17:51 -0800125
John Parkcf545162020-02-23 20:07:25 -0800126def draw_trench_run(cr):
James Kuszmaul1c933e02020-03-07 16:17:51 -0800127 edge_of_field_y = LENGTH_OF_FIELD_IN_METERS / 2.0
128 edge_of_trench_y = edge_of_field_y - inToM(55.5)
129 trench_start_x = inToM(-108.0)
130 trench_length_x = inToM(216.0)
131 ball_line_y = edge_of_field_y - inToM(27.75)
132 ball_one_x = -inToM(72)
133 ball_two_x = -inToM(36)
134 ball_three_x = 0.0
135 # The fourth/fifth balls are referenced off of the init line...
136 ball_fourfive_x = WIDTH_OF_FIELD_IN_METERS / 2.0 - inToM(120.0 + 130.36)
John Parkcf545162020-02-23 20:07:25 -0800137
James Kuszmaul1c933e02020-03-07 16:17:51 -0800138 for sign in [1.0, -1.0]:
139 set_color(cr, palette["GREEN"])
140 cr.rectangle(mToPx(sign * trench_start_x),
141 mToPx(sign * edge_of_field_y),
142 mToPx(sign * trench_length_x),
143 mToPx(sign * (edge_of_trench_y - edge_of_field_y)))
144 cr.stroke()
145 draw_circle(cr, mToPx(sign * ball_one_x), mToPx(sign * ball_line_y),
146 mToPx(0.1), palette["YELLOW"])
147 draw_circle(cr, mToPx(sign * ball_two_x), mToPx(sign * ball_line_y),
148 mToPx(0.1), palette["YELLOW"])
149 draw_circle(cr, mToPx(sign * ball_three_x), mToPx(sign * ball_line_y),
150 mToPx(0.1), palette["YELLOW"])
John Parkcf545162020-02-23 20:07:25 -0800151
152 cr.stroke()
153
James Kuszmaul1c933e02020-03-07 16:17:51 -0800154
John Parkcf545162020-02-23 20:07:25 -0800155def draw_shield_generator(cr):
156 set_color(cr, palette["BLUE"])
James Kuszmaul1c933e02020-03-07 16:17:51 -0800157 cr.save()
158 cr.rotate(22.5 * np.pi / 180.)
159 generator_width = mToPx(inToM(14 * 12 + 0.75))
160 generator_height = mToPx(inToM(13 * 12 + 1.5))
161 cr.rectangle(-generator_width / 2.0, -generator_height / 2.0,
162 generator_width, generator_height)
163 cr.restore()
John Parkcf545162020-02-23 20:07:25 -0800164
165 cr.stroke()
166
James Kuszmaul1c933e02020-03-07 16:17:51 -0800167
168def draw_control_panel(cr): # Base plates are not included
John Parkcf545162020-02-23 20:07:25 -0800169 set_color(cr, palette["LIGHT_GREY"])
James Kuszmaul1c933e02020-03-07 16:17:51 -0800170 edge_of_field_y = LENGTH_OF_FIELD_IN_METERS / 2.0
171 edge_of_trench_y = edge_of_field_y - inToM(55.5)
172 high_x = inToM(374.59) - WIDTH_OF_FIELD_IN_METERS / 2.0
173 low_x = high_x - inToM(30)
174 for sign in [1.0, -1.0]:
175 # Bottom Control Panel
176 # Top Line
177 cr.rectangle(sign * mToPx(high_x), sign * mToPx(edge_of_field_y),
178 -sign * mToPx(inToM(30)), -sign * mToPx(inToM(55.5)))
John Parkcf545162020-02-23 20:07:25 -0800179
180 cr.stroke()
John Park91e69732019-03-03 13:12:43 -0800181
James Kuszmaul1c933e02020-03-07 16:17:51 -0800182
John Park91e69732019-03-03 13:12:43 -0800183def draw_HAB(cr):
184 # BASE Constants
185 X_BASE = 0
186 Y_BASE = 0
187 R = 0.381 - .1
188 BACKWALL_X = X_BASE
189 LOADING_Y = mToPx(4.129151) - mToPx(0.696976)
190 # HAB Levels 2 and 3 called in variables backhab
191 # draw loading stations
192 cr.move_to(0, LOADING_Y)
193 cr.line_to(mToPx(0.6), LOADING_Y)
194 cr.move_to(mToPx(R), LOADING_Y)
195 cr.arc(mToPx(R), LOADING_Y, 5, 0, np.pi * 2.0)
196 cr.move_to(0, -1.0 * LOADING_Y)
197 cr.line_to(mToPx(0.6), -1.0 * LOADING_Y)
198 cr.move_to(mToPx(R), -1.0 * LOADING_Y)
199 cr.arc(mToPx(R), -1.0 * LOADING_Y, 5, 0, np.pi * 2.0)
200
201 # HAB Levels 2 and 3 called in variables backhab
202 WIDTH_BACKHAB = mToPx(1.2192)
203
204 Y_TOP_BACKHAB_BOX = Y_BASE + mToPx(0.6096)
205 BACKHAB_LV2_LENGTH = mToPx(1.016)
206
207 BACKHAB_LV3_LENGTH = mToPx(1.2192)
208 Y_LV3_BOX = Y_TOP_BACKHAB_BOX - BACKHAB_LV3_LENGTH
209
210 Y_BOTTOM_BACKHAB_BOX = Y_LV3_BOX - BACKHAB_LV2_LENGTH
211
212 # HAB LEVEL 1
213 X_LV1_BOX = BACKWALL_X + WIDTH_BACKHAB
214
215 WIDTH_LV1_BOX = mToPx(0.90805)
216 LENGTH_LV1_BOX = mToPx(1.6256)
217
218 Y_BOTTOM_LV1_BOX = Y_BASE - LENGTH_LV1_BOX
219
220 # Ramp off Level 1
221 X_RAMP = X_LV1_BOX
222
223 Y_TOP_RAMP = Y_BASE + LENGTH_LV1_BOX
224 WIDTH_TOP_RAMP = mToPx(1.20015)
225 LENGTH_TOP_RAMP = Y_BASE + mToPx(0.28306)
226
227 X_MIDDLE_RAMP = X_RAMP + WIDTH_LV1_BOX
228 Y_MIDDLE_RAMP = Y_BOTTOM_LV1_BOX
229 LENGTH_MIDDLE_RAMP = 2 * LENGTH_LV1_BOX
230 WIDTH_MIDDLE_RAMP = WIDTH_TOP_RAMP - WIDTH_LV1_BOX
231
232 Y_BOTTOM_RAMP = Y_BASE - LENGTH_LV1_BOX - LENGTH_TOP_RAMP
233
234 # Side Bars to Hold in balls
235 X_BARS = BACKWALL_X
236 WIDTH_BARS = WIDTH_BACKHAB
237 LENGTH_BARS = mToPx(0.574675)
238
239 Y_TOP_BAR = Y_TOP_BACKHAB_BOX + BACKHAB_LV2_LENGTH
240
241 Y_BOTTOM_BAR = Y_BOTTOM_BACKHAB_BOX - LENGTH_BARS
242
243 set_color(cr, palette["BLACK"])
244 cr.rectangle(BACKWALL_X, Y_TOP_BACKHAB_BOX, WIDTH_BACKHAB,
245 BACKHAB_LV2_LENGTH)
246 cr.rectangle(BACKWALL_X, Y_LV3_BOX, WIDTH_BACKHAB, BACKHAB_LV3_LENGTH)
247 cr.rectangle(BACKWALL_X, Y_BOTTOM_BACKHAB_BOX, WIDTH_BACKHAB,
248 BACKHAB_LV2_LENGTH)
249 cr.rectangle(X_LV1_BOX, Y_BASE, WIDTH_LV1_BOX, LENGTH_LV1_BOX)
250 cr.rectangle(X_LV1_BOX, Y_BOTTOM_LV1_BOX, WIDTH_LV1_BOX, LENGTH_LV1_BOX)
251 cr.rectangle(X_RAMP, Y_TOP_RAMP, WIDTH_TOP_RAMP, LENGTH_TOP_RAMP)
252 cr.rectangle(X_MIDDLE_RAMP, Y_MIDDLE_RAMP, WIDTH_MIDDLE_RAMP,
253 LENGTH_MIDDLE_RAMP)
254 cr.rectangle(X_RAMP, Y_BOTTOM_RAMP, WIDTH_TOP_RAMP, LENGTH_TOP_RAMP)
255 cr.rectangle(X_BARS, Y_TOP_BAR, WIDTH_BARS, LENGTH_BARS)
256 cr.rectangle(X_BARS, Y_BOTTOM_BAR, WIDTH_BARS, LENGTH_BARS)
257 cr.stroke()
258
259 cr.set_line_join(cairo.LINE_JOIN_ROUND)
260
261 cr.stroke()
262
263 #draw 0, 0
264 set_color(cr, palette["BLACK"])
265 cr.move_to(0, 0)
266 cr.line_to(0, 0 + mToPx(8.2296 / 2.0))
267 cr.move_to(0, 0)
268 cr.line_to(0, 0 + mToPx(-8.2296 / 2.0))
269 cr.move_to(0, 0)
270 cr.line_to(0 + mToPx(8.2296), 0)
271
272 cr.stroke()
273
274
275def draw_rockets(cr):
276 # BASE Constants
277 X_BASE = mToPx(2.41568)
278 Y_BASE = 0
279 # Robot longitudinal radius
280 R = 0.381
281 near_side_rocket_center = [
282 X_BASE + mToPx((2.89973 + 3.15642) / 2.0), Y_BASE + mToPx(
283 (3.86305 + 3.39548) / 2.0)
284 ]
285 middle_rocket_center = [
286 X_BASE + mToPx((3.15642 + 3.6347) / 2.0), Y_BASE + mToPx(
287 (3.39548 + 3.392380) / 2.0)
288 ]
289 far_side_rocket_center = [
290 X_BASE + mToPx((3.63473 + 3.89984) / 2.0), Y_BASE + mToPx(
291 (3.39238 + 3.86305) / 2.0)
292 ]
293
294 cr.move_to(near_side_rocket_center[0], near_side_rocket_center[1])
295 cr.line_to(near_side_rocket_center[0] - 0.8 * mToPx(0.866),
296 near_side_rocket_center[1] - 0.8 * mToPx(0.5))
297 cr.move_to(near_side_rocket_center[0] - R * mToPx(0.866),
298 near_side_rocket_center[1] - R * mToPx(0.5))
299 cr.arc(near_side_rocket_center[0] - R * mToPx(0.866),
300 near_side_rocket_center[1] - R * mToPx(0.5), 5, 0, np.pi * 2.0)
301
302 cr.move_to(middle_rocket_center[0], middle_rocket_center[1])
303 cr.line_to(middle_rocket_center[0], middle_rocket_center[1] - mToPx(0.8))
304 cr.move_to(middle_rocket_center[0], middle_rocket_center[1] - mToPx(R))
305 cr.arc(middle_rocket_center[0], middle_rocket_center[1] - mToPx(R), 5, 0,
306 np.pi * 2.0)
307
308 cr.move_to(far_side_rocket_center[0], far_side_rocket_center[1])
309 cr.line_to(far_side_rocket_center[0] + 0.8 * mToPx(0.866),
310 far_side_rocket_center[1] - 0.8 * mToPx(0.5))
311 cr.move_to(far_side_rocket_center[0] + R * mToPx(0.866),
312 far_side_rocket_center[1] - R * mToPx(0.5))
313 cr.arc(far_side_rocket_center[0] + R * mToPx(0.866),
314 far_side_rocket_center[1] - R * mToPx(0.5), 5, 0, np.pi * 2.0)
315
316 #print(far_side_rocket_center)
317 near_side_rocket_center = [
318 X_BASE + mToPx((2.89973 + 3.15642) / 2.0), Y_BASE - mToPx(
319 (3.86305 + 3.39548) / 2.0)
320 ]
321 middle_rocket_center = [
322 X_BASE + mToPx((3.15642 + 3.6347) / 2.0), Y_BASE - mToPx(
323 (3.39548 + 3.392380) / 2.0)
324 ]
325 far_side_rocket_center = [
326 X_BASE + mToPx((3.63473 + 3.89984) / 2.0), Y_BASE - mToPx(
327 (3.39238 + 3.86305) / 2.0)
328 ]
329
330 cr.move_to(near_side_rocket_center[0], near_side_rocket_center[1])
331 cr.line_to(near_side_rocket_center[0] - 0.8 * mToPx(0.866),
332 near_side_rocket_center[1] + 0.8 * mToPx(0.5))
333
334 cr.move_to(middle_rocket_center[0], middle_rocket_center[1])
335 cr.line_to(middle_rocket_center[0], middle_rocket_center[1] + mToPx(0.8))
336
337 cr.move_to(far_side_rocket_center[0], far_side_rocket_center[1])
338 cr.line_to(far_side_rocket_center[0] + 0.8 * mToPx(0.866),
339 far_side_rocket_center[1] + 0.8 * mToPx(0.5))
340
341 # Leftmost Line
342 cr.move_to(X_BASE + mToPx(2.89973), Y_BASE + mToPx(3.86305))
343 cr.line_to(X_BASE + mToPx(3.15642), Y_BASE + mToPx(3.39548))
344
345 # Top Line
346 cr.move_to(X_BASE + mToPx(3.15642), Y_BASE + mToPx(3.39548))
347 cr.line_to(X_BASE + mToPx(3.63473), Y_BASE + mToPx(3.39238))
348
349 #Rightmost Line
350 cr.move_to(X_BASE + mToPx(3.63473), Y_BASE + mToPx(3.39238))
351 cr.line_to(X_BASE + mToPx(3.89984), Y_BASE + mToPx(3.86305))
352
353 #Back Line
354 cr.move_to(X_BASE + mToPx(2.89973), Y_BASE + mToPx(3.86305))
355 cr.line_to(X_BASE + mToPx(3.89984), Y_BASE + mToPx(3.86305))
356
357 # Bottom Rocket
358 # Leftmost Line
359 cr.move_to(X_BASE + mToPx(2.89973), Y_BASE - mToPx(3.86305))
360 cr.line_to(X_BASE + mToPx(3.15642), Y_BASE - mToPx(3.39548))
361
362 # Top Line
363 cr.move_to(X_BASE + mToPx(3.15642), Y_BASE - mToPx(3.39548))
364 cr.line_to(X_BASE + mToPx(3.63473), Y_BASE - mToPx(3.39238))
365
366 #Rightmost Line
367 cr.move_to(X_BASE + mToPx(3.63473), Y_BASE - mToPx(3.39238))
368 cr.line_to(X_BASE + mToPx(3.89984), Y_BASE - mToPx(3.86305))
369
370 #Back Line
371 cr.move_to(X_BASE + mToPx(2.89973), Y_BASE - mToPx(3.86305))
372 cr.line_to(X_BASE + mToPx(3.89984), Y_BASE - mToPx(3.86305))
373
374 cr.stroke()
375
376
377def draw_cargo_ship(cr):
378 # BASE Constants
379 X_BASE = 0 + mToPx(5.59435)
380 Y_BASE = 0 + 0 #mToPx(4.129151)
381 R = 0.381 - 0.1
382
383 FRONT_PEG_DELTA_Y = mToPx(0.276352)
384 cr.move_to(X_BASE, Y_BASE + FRONT_PEG_DELTA_Y)
385 cr.line_to(X_BASE - mToPx(0.8), Y_BASE + FRONT_PEG_DELTA_Y)
386
387 cr.move_to(X_BASE, Y_BASE + FRONT_PEG_DELTA_Y)
388 cr.arc(X_BASE - mToPx(R), Y_BASE + FRONT_PEG_DELTA_Y, 5, 0, np.pi * 2.0)
389
390 cr.move_to(X_BASE, Y_BASE - FRONT_PEG_DELTA_Y)
391 cr.line_to(X_BASE - mToPx(0.8), Y_BASE - FRONT_PEG_DELTA_Y)
392
393 cr.move_to(X_BASE, Y_BASE - FRONT_PEG_DELTA_Y)
394 cr.arc(X_BASE - mToPx(R), Y_BASE - FRONT_PEG_DELTA_Y, 5, 0, np.pi * 2.0)
395
396 SIDE_PEG_Y = mToPx(1.41605 / 2.0)
397 SIDE_PEG_X = X_BASE + mToPx(1.148842)
398 SIDE_PEG_DX = mToPx(0.55245)
399
400 cr.move_to(SIDE_PEG_X, SIDE_PEG_Y)
401 cr.line_to(SIDE_PEG_X, SIDE_PEG_Y + mToPx(0.8))
402 cr.move_to(SIDE_PEG_X, SIDE_PEG_Y + mToPx(R))
403 cr.arc(SIDE_PEG_X, SIDE_PEG_Y + mToPx(R), 5, 0, np.pi * 2.0)
404
405 cr.move_to(SIDE_PEG_X + SIDE_PEG_DX, SIDE_PEG_Y)
406 cr.line_to(SIDE_PEG_X + SIDE_PEG_DX, SIDE_PEG_Y + mToPx(0.8))
407 cr.move_to(SIDE_PEG_X + SIDE_PEG_DX, SIDE_PEG_Y + mToPx(R))
408 cr.arc(SIDE_PEG_X + SIDE_PEG_DX, SIDE_PEG_Y + mToPx(R), 5, 0, np.pi * 2.0)
409
410 cr.move_to(SIDE_PEG_X + 2.0 * SIDE_PEG_DX, SIDE_PEG_Y)
411 cr.line_to(SIDE_PEG_X + 2.0 * SIDE_PEG_DX, SIDE_PEG_Y + mToPx(0.8))
412 cr.move_to(SIDE_PEG_X + 2.0 * SIDE_PEG_DX, SIDE_PEG_Y + mToPx(R))
413 cr.arc(SIDE_PEG_X + 2.0 * SIDE_PEG_DX, SIDE_PEG_Y + mToPx(R), 5, 0,
414 np.pi * 2.0)
415
416 cr.move_to(SIDE_PEG_X, -1.0 * SIDE_PEG_Y)
417 cr.line_to(SIDE_PEG_X, -1.0 * SIDE_PEG_Y - mToPx(0.8))
418 cr.move_to(SIDE_PEG_X, -1.0 * SIDE_PEG_Y - mToPx(R))
419 cr.arc(SIDE_PEG_X, -1.0 * SIDE_PEG_Y - mToPx(R), 5, 0, np.pi * 2.0)
420
421 cr.move_to(SIDE_PEG_X + SIDE_PEG_DX, -1.0 * SIDE_PEG_Y)
422 cr.line_to(SIDE_PEG_X + SIDE_PEG_DX, -1.0 * SIDE_PEG_Y - mToPx(0.8))
423 cr.move_to(SIDE_PEG_X + SIDE_PEG_DX, -1.0 * SIDE_PEG_Y - mToPx(R))
424 cr.arc(SIDE_PEG_X + SIDE_PEG_DX, -1.0 * SIDE_PEG_Y - mToPx(R), 5, 0,
425 np.pi * 2.0)
426
427 cr.move_to(SIDE_PEG_X + 2.0 * SIDE_PEG_DX, -1.0 * SIDE_PEG_Y)
428 cr.line_to(SIDE_PEG_X + 2.0 * SIDE_PEG_DX, -1.0 * SIDE_PEG_Y - mToPx(0.8))
429 cr.move_to(SIDE_PEG_X + 2.0 * SIDE_PEG_DX, -1.0 * SIDE_PEG_Y - mToPx(R))
430 cr.arc(SIDE_PEG_X + 2.0 * SIDE_PEG_DX, -1.0 * SIDE_PEG_Y - mToPx(R), 5, 0,
431 np.pi * 2.0)
432
433 cr.rectangle(X_BASE, Y_BASE - mToPx(1.41605 / 2.0), mToPx(2.43205),
434 mToPx(1.41605))
435 cr.stroke()
436
James Kuszmaul1c933e02020-03-07 16:17:51 -0800437
John Park91e69732019-03-03 13:12:43 -0800438def draw_points(cr, p, size):
439 for i in range(0, len(p)):
440 draw_px_cross(cr, p[i][0], p[i][1], size,
441 Color(0, np.sqrt(0.2 * i), 0))