Skip to content

Commit 028d5a8

Browse files
committed
Simplify random sparkles example
1 parent f1a0ff0 commit 028d5a8

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

examples/randomsparkles.py

+6-8
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
11
from tree import RGBXmasTree
2-
from random import random
2+
import random
33

44
tree = RGBXmasTree()
55

66
def random_color():
7-
r = random()
8-
g = random()
9-
b = random()
7+
r = random.random()
8+
g = random.random()
9+
b = random.random()
1010
return (r, g, b)
1111

12-
def random_colors(n):
13-
return [random_color() for i in range(n)]
14-
1512
try:
1613
while True:
17-
tree.value = random_colors(25)
14+
pixel = random.choice(tree)
15+
pixel.color = random_color()
1816
except KeyboardInterrupt:
1917
tree.close()

0 commit comments

Comments
 (0)