Skip to content

Commit bd70870

Browse files
committed
Added a thickness parameter to the grid line creation to draw lines thicker based on scale.
1 parent 27269db commit bd70870

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

graphics/graphics_grid.py

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -129,20 +129,24 @@ def __create_grid_objects(self):
129129
y_middle = (max_y_coord + min_y_coord) / 2
130130
z_middle = (max_z_coord + min_z_coord) / 2
131131

132+
line_thickness = min(max(self.__scale / 25, 0.01), 5) # 0.01 -> 5
133+
132134
# XZ plane
133135
for x_point in x_coords:
134136
# Draw a line across for each x coord, along the same y-axis, from min to max z coord
135137
xz_lines.append(create_line(
136138
vector(x_point, y_origin, min_z_coord),
137139
vector(x_point, y_origin, max_z_coord),
138-
self.__scene
140+
self.__scene,
141+
thickness=line_thickness
139142
))
140143
for z_point in z_coords:
141144
# Draw a line across each z coord, along the same y-axis, from min to max z coord
142145
xz_lines.append(create_line(
143146
vector(min_x_coord, y_origin, z_point),
144147
vector(max_x_coord, y_origin, z_point),
145-
self.__scene
148+
self.__scene,
149+
thickness=line_thickness
146150
))
147151

148152
# XY plane
@@ -151,14 +155,16 @@ def __create_grid_objects(self):
151155
xy_lines.append(create_line(
152156
vector(x_point, min_y_coord, z_origin),
153157
vector(x_point, max_y_coord, z_origin),
154-
self.__scene
158+
self.__scene,
159+
thickness=line_thickness
155160
))
156161
for y_point in y_coords:
157162
# Draw a line across each y coord, along the same z-axis, from min to max x coord
158163
xy_lines.append(create_line(
159164
vector(min_x_coord, y_point, z_origin),
160165
vector(max_x_coord, y_point, z_origin),
161-
self.__scene
166+
self.__scene,
167+
thickness=line_thickness
162168
))
163169

164170
# YZ plane
@@ -167,14 +173,16 @@ def __create_grid_objects(self):
167173
yz_lines.append(create_line(
168174
vector(x_origin, y_point, min_z_coord),
169175
vector(x_origin, y_point, max_z_coord),
170-
self.__scene
176+
self.__scene,
177+
thickness=line_thickness
171178
))
172179
for z_point in z_coords:
173180
# Draw a line across each z coord, along the same x-axis, from min to max y coord
174181
yz_lines.append(create_line(
175182
vector(x_origin, min_y_coord, z_point),
176183
vector(x_origin, max_y_coord, z_point),
177-
self.__scene
184+
self.__scene,
185+
thickness=line_thickness
178186
))
179187

180188
# Compound the lines together into respective objects
@@ -261,19 +269,12 @@ def __move_grid_objects(self):
261269
y_middle = (max_y_coord + min_y_coord) / 2
262270
z_middle = (max_z_coord + min_z_coord) / 2
263271

264-
print("x", min_x_coord, x_middle, max_x_coord)
265-
print("y", min_y_coord, y_middle, max_y_coord)
266-
print("z", min_z_coord, z_middle, max_z_coord)
267-
print("pos", self.grid_object[self.__planes_idx][self.__xy_plane_idx])
268-
269272
# XY Plane
270273
if camera_axes.z < 0:
271274
self.grid_object[self.__planes_idx][self.__xy_plane_idx].pos = vector(x_middle, y_middle, min_z_coord)
272275
else:
273276
self.grid_object[self.__planes_idx][self.__xy_plane_idx].pos = vector(x_middle, y_middle, max_z_coord)
274277

275-
print("pos", self.grid_object[self.__planes_idx][self.__xy_plane_idx])
276-
277278
# XZ Plane
278279
if camera_axes.y < 0:
279280
self.grid_object[self.__planes_idx][self.__xz_plane_idx].pos = vector(x_middle, min_y_coord, z_middle)
@@ -372,6 +373,8 @@ def set_relative(self, is_relative):
372373

373374
def set_scale(self, value):
374375
"""
376+
Set the scale and redraw the grid
377+
375378
:param value: The value to set the scale to
376379
:type value: `float`
377380
"""

0 commit comments

Comments
 (0)