@@ -11,19 +11,21 @@ def __init__(self, window_w=1765, window_h=400):
11
11
self .color_group = pyglet .graphics .OrderedGroup (1 )
12
12
self .alive = 1
13
13
def draw_LEDs (self , led_number ):
14
+ led_img = pyglet .image .load ('ws2812b.png' )
15
+ circle_img = pyglet .image .load ('circle.png' )
14
16
for led in range (led_number ):
15
- img = pyglet .image .load ('ws2812b.png' )
16
- self .sprites .append (pyglet .sprite .Sprite (img = img ,batch = self .batch , x = (led - 50 * (led // 50 ))* 35 , y = self .height - 34 - ((led // 50 )* 34 ), group = self .led_group ))
17
- self .color_sprites .append (pyglet .sprite .Sprite (img = pyglet .image .load ('circle.png' ),batch = self .batch ,x = (led - 50 * (led // 50 ))* 35 ,y = self .height - 34 - ((led // 50 )* 34 )- 5 ,group = self .color_group ))
17
+ self .sprites .append (pyglet .sprite .Sprite (img = led_img ,batch = self .batch , x = (led - 50 * (led // 50 ))* 35 , y = self .height - 34 - ((led // 50 )* 34 ), group = self .led_group ))
18
+ self .color_sprites .append (pyglet .sprite .Sprite (img = circle_img ,batch = self .batch ,x = (led - 50 * (led // 50 ))* 35 ,y = self .height - 34 - ((led // 50 )* 34 )- 5 ,group = self .color_group ))
18
19
self .sprites [led ].scale = .1
19
20
self .color_sprites [led ].color = (0 ,0 ,0 )
20
21
#print(self.sprites[led].position)
21
22
def draw_LED_matrix (self , width , height ):
23
+ led_img = pyglet .image .load ('ws2812b.png' )
24
+ circle_img = pyglet .image .load ('circle.png' )
22
25
for y in range (height ):
23
26
for x in range (width ):
24
- img = pyglet .image .load ('ws2812b.png' )
25
- self .sprites .append (pyglet .sprite .Sprite (img = img ,batch = self .batch , x = x * 35 , y = self .height - 34 - (y * 34 ), group = self .led_group ))
26
- self .color_sprites .append (pyglet .sprite .Sprite (img = pyglet .image .load ('circle.png' ),batch = self .batch ,x = x * 35 ,y = self .height - 34 - (y * 34 )- 5 ,group = self .color_group ))
27
+ self .sprites .append (pyglet .sprite .Sprite (img = led_img ,batch = self .batch , x = x * 35 , y = self .height - 34 - (y * 34 ), group = self .led_group ))
28
+ self .color_sprites .append (pyglet .sprite .Sprite (img = circle_img ,batch = self .batch ,x = x * 35 ,y = self .height - 34 - (y * 34 )- 5 ,group = self .color_group ))
27
29
self .sprites [y * width + x ].scale = .1
28
30
self .color_sprites [y * width + x ].color = (0 ,0 ,0 )
29
31
def map (self ,input_val ,in_min ,in_max ,out_min ,out_max ):
0 commit comments