MCPcopy Create free account
hub / github.com/BIT-MCS/DRL-eFresh / Draw

Class Draw

common/image/draw_util.py:2–69  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1
2class Draw:
3 def __init__(self, sg):
4 self.sg = sg
5 self.__width = self.sg.V['OBSER_X'] #80
6 self.__height = self.sg.V['OBSER_Y'] #80
7 def draw_border(self, map):
8 border_value = self.sg.V['BORDER_VALUE']
9 border_width = self.sg.V['BORDER_WIDTH']
10 for j in range(0, 80, 1):
11 for i in range(80 - border_width, 80, 1):
12 self.draw_sqr(i, j, 1, 1, border_value, map)
13 for i in range(0, border_width, 1):
14 self.draw_sqr(i, j, 1, 1, border_value, map)
15 for i in range(0, 80, 1):
16 for j in range(0, border_width, 1):
17 self.draw_sqr(i, j, 1, 1, border_value, map)
18 for j in range(80 - border_width, 80, 1):
19 self.draw_sqr(i, j, 1, 1, border_value, map)
20
21 def get_value(self, x, y, map):
22 x, y = self.__trans(x, y)
23 return map[x][y]
24
25 def __trans(self, x, y):
26 return int(4 * x + 8), int(y * 4 + 8)
27
28 def draw_obstacle(self, x, y, width, height, map):
29 # self.clear_cell(x, y, map)
30 x, y = self.__trans(x, y)
31 self.draw_sqr(x, y, width * 4, height * 4, self.sg.V['BORDER_VALUE'], map)
32
33 # def draw_chargestation(self, x, y, map):
34 # self.clear_cell(x, y, map)
35 # x, y = self.__trans(x, y)
36 # self.draw_sqr(x, y + 1, 4, 2, 1, map)
37 # self.draw_sqr(x + 1, y, 2, 4, 1, map)
38
39 def draw_point(self, x, y, value, map):
40 # self.clear_cell(x, y, map)
41 x, y = self.__trans(x, y)
42 self.draw_sqr(x, y, 2, 2, value, map)
43
44 def clear_point(self, x, y, map):
45 x, y = self.__trans(x, y)
46 self.draw_sqr(x, y, 2, 2, 0, map)
47
48 def clear_uav(self, x, y, map):
49 self.clear_cell(x, y, map)
50
51 def draw_UAV(self, x, y, value, map):
52 x = -1 if x < -1 else self.sg.V['MAP_X'] if x > self.sg.V['MAP_X'] else x
53 y = -1 if y < -1 else self.sg.V['MAP_Y'] if y > self.sg.V['MAP_Y'] else y
54 self.clear_cell(x, y, map)
55 x, y = self.__trans(x, y)
56 # self.draw_sqr(x, y + 1, 4, 2, value, map)
57 # self.draw_sqr(x + 1, y, 2, 4, value, map)
58 # value = self.get_value(x, y)
59 self.draw_sqr(x, y, 4, 4, value, map)
60

Callers 1

__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected