# Buggy code
def calculate_colors():
    self._sprite_color_data = array.array("B")
    for sprite in self.sprite_list:
        self._sprite_color_data.append(sprite.color[0])
        self._sprite_color_data.append(sprite.color[1])
        self._sprite_color_data.append(sprite.color[2])
        self._sprite_color_data.append(sprite.alpha)

    self._sprite_color_buf = shader.buffer(
        self._sprite_color_data.tobytes(), usage=usage
    )
    variables = ["in_color"]
    self._sprite_color_desc = shader.BufferDescription(
        self._sprite_color_buf, "4B", variables, normalized=["in_color"], instanced=True
    )
    self._sprite_color_changed = False


# Traceback (TypeError)
$ python -m arcade.examples.particle_fireworks
Traceback (most recent call last):
File "C:\Users\scott\AppData\Local\Programs\Python\Python37\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "C:\Users\scott\AppData\Local\Programs\Python\Python37\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\cache\repo\arcade\arcade\examples\particle_fireworks.py", line 357, in <module>
arcade.run()
File "C:\cache\repo\arcade\arcade\window_commands.py", line 246, in run
pyglet.app.run()
File "C:\cache\venv\arcadedev\lib\site-packages\pyglet\app\__init__.py", line 144, in run
event_loop.run()
File "C:\cache\venv\arcadedev\lib\site-packages\pyglet\app\base.py", line 175, in run
self._run()
File "C:\cache\venv\arcadedev\lib\site-packages\pyglet\app\base.py", line 187, in _run
timeout = self.idle()
File "C:\cache\venv\arcadedev\lib\site-packages\pyglet\app\base.py", line 314, in idle
window.dispatch_event('on_draw')
File "C:\cache\venv\arcadedev\lib\site-packages\pyglet\window\__init__.py", line 1330, in dispatch_event
if EventDispatcher.dispatch_event(self, *args) != False:
File "C:\cache\venv\arcadedev\lib\site-packages\pyglet\event.py", line 428, in dispatch_event
self._raise_dispatch_exception(event_type, args, getattr(self, event_type), exception)
File "C:\cache\venv\arcadedev\lib\site-packages\pyglet\event.py", line 482, in _raise_dispatch_exception
raise exception
File "C:\cache\venv\arcadedev\lib\site-packages\pyglet\event.py", line 423, in dispatch_event
if getattr(self, event_type)(*args):
File "C:\cache\repo\arcade\arcade\examples\particle_fireworks.py", line 332, in on_draw
e.draw()
File "C:\cache\repo\arcade\arcade\emitter.py", line 167, in draw
self._particles.draw()
File "C:\cache\repo\arcade\arcade\sprite_list.py", line 803, in draw
self._calculate_sprite_buffer()
File "C:\cache\repo\arcade\arcade\sprite_list.py", line 619, in _calculate_sprite_buffer
calculate_colors()
File "C:\cache\repo\arcade\arcade\sprite_list.py", line 490, in calculate_colors
self._sprite_color_data.append(sprite.alpha)
TypeError: integer argument expected, got float
Error in sys.excepthook:

Original exception was:

# Fixed code
def calculate_colors():
    self._sprite_color_data = array.array("B")
    for sprite in self.sprite_list:
        self._sprite_color_data.append(int(sprite.color[0]))
        self._sprite_color_data.append(int(sprite.color[1]))
        self._sprite_color_data.append(int(sprite.color[2]))
        self._sprite_color_data.append(int(sprite.alpha))

    self._sprite_color_buf = shader.buffer(
        self._sprite_color_data.tobytes(), usage=usage
    )
    variables = ["in_color"]
    self._sprite_color_desc = shader.BufferDescription(
        self._sprite_color_buf, "4B", variables, normalized=["in_color"], instanced=True
    )
    self._sprite_color_changed = False