Skip to content

Commit 8d7a49b

Browse files
committed
Use proper inspect.getmembers call to get Colors in lines_buffered example
1 parent f78c495 commit 8d7a49b

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

arcade/examples/lines_buffered.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
ShapeElementList,
1111
create_line_strip,
1212
)
13+
from inspect import getmembers
14+
from arcade.types import Color
15+
1316
# Do the math to figure out our screen dimensions
1417
SCREEN_WIDTH = 800
1518
SCREEN_HEIGHT = 600
@@ -37,11 +40,13 @@ def __init__(self, width, height, title):
3740
(-50, 0),
3841
(-10, 10),
3942
(0, 50))
43+
44+
# Filter out anything other than a Color, such as imports and
45+
# helper functions.
4046
colors = [
41-
getattr(arcade.color, color)
42-
for color in dir(arcade.color)
43-
if not color.startswith("__")
44-
]
47+
color for name, color in
48+
getmembers(arcade.color, lambda c: isinstance(c, Color))]
49+
4550
for i in range(200):
4651
x = SCREEN_WIDTH // 2 - random.randrange(SCREEN_WIDTH)
4752
y = SCREEN_HEIGHT // 2 - random.randrange(SCREEN_HEIGHT)

0 commit comments

Comments
 (0)