Skip to content

Commit c68bac6

Browse files
authored
Don't draw lines and point with zero elements (#2737)
1 parent b4c2757 commit c68bac6

File tree

3 files changed

+6
-0
lines changed

3 files changed

+6
-0
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ Arcade [PyPi Release History](https://pypi.org/project/arcade/#history) page.
1010
atlas is resized or rebuilt. This way it's easy to track when texture coordinates
1111
has changed.
1212
- Added `Text.visible` (bool) property to control the visibility of text objects.
13+
- Fixed an issue causing points and lines to draw random primitives when
14+
passing in an empty list.
1315

1416
## 3.3.0
1517

arcade/draw/line.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ def draw_lines(point_list: Point2List, color: RGBOrA255, line_width: float = 1)
112112

113113
line_pos_array = array.array("f", (v for point in point_list for v in point))
114114
num_points = len(point_list)
115+
if num_points == 0:
116+
return
115117

116118
# Grow buffer until large enough to hold all our data
117119
goal_buffer_size = num_points * 3 * 4

arcade/draw/point.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ def draw_points(point_list: Point2List, color: RGBOrA255, size: float = 1.0) ->
6464

6565
# Get # of points and translate Python tuples to a C-style array
6666
num_points = len(point_list)
67+
if num_points == 0:
68+
return
6769
point_array = array.array("f", (v for point in point_list for v in point))
6870

6971
# Resize buffer

0 commit comments

Comments
 (0)