Apply suggestions from code review of branch snake-scan
Co-authored-by: Julian Stirling <julian@julianstirling.co.uk>
This commit is contained in:
parent
7413aa57f8
commit
1c17b27c05
1 changed files with 7 additions and 16 deletions
|
|
@ -691,20 +691,11 @@ def create_rectangular_scan_path(
|
||||||
|
|
||||||
# Populate grid with coordinates in a regular grid
|
# Populate grid with coordinates in a regular grid
|
||||||
for y_index in range(y_count): # rows
|
for y_index in range(y_count): # rows
|
||||||
coords.append([])
|
row = [
|
||||||
for x_index in range(x_count): # cols
|
(starting_pos[0] + x_index * dx, starting_pos[1] + y_index * dy)
|
||||||
# Create a coordinate tuple
|
for x_index in range(x_count)
|
||||||
coord = (
|
]
|
||||||
starting_pos[0] + x_index * dx,
|
if style == "snake" and y_index % 2 == 1:
|
||||||
starting_pos[1] + y_index * dy,
|
row.reverse()
|
||||||
)
|
coords.append(row)
|
||||||
# Append coordinate array to position grid
|
|
||||||
coords[y_index].append(coord)
|
|
||||||
|
|
||||||
# If style is snake, reverse every second row
|
|
||||||
if style == "snake":
|
|
||||||
for i, line in enumerate(coords):
|
|
||||||
if i % 2 != 0:
|
|
||||||
# Reverse the list of coordinates
|
|
||||||
line.reverse()
|
|
||||||
return coords
|
return coords
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue