diff --git a/arcade/application.py b/arcade/application.py index 061eb7ee9..eb8142d11 100644 --- a/arcade/application.py +++ b/arcade/application.py @@ -17,6 +17,7 @@ from arcade import get_display_size from arcade import set_viewport from arcade import set_window +from arcade.color import TRANSPARENT_BLACK from arcade.context import ArcadeContext from arcade.arcade_types import Color from arcade import SectionManager @@ -176,7 +177,7 @@ def __init__( self._ctx: ArcadeContext = ArcadeContext(self, gc_mode=gc_mode, gl_api=gl_api) set_viewport(0, self.width, 0, self.height) - self._background_color: Color = (0, 0, 0, 0) + self._background_color: Color = TRANSPARENT_BLACK # See if we should center the window if center_window: diff --git a/arcade/color/__init__.py b/arcade/color/__init__.py index 0cb6ca296..feb3b74e4 100644 --- a/arcade/color/__init__.py +++ b/arcade/color/__init__.py @@ -923,6 +923,7 @@ TROLLEY_GREY = (128, 128, 128, 255) TROPICAL_RAIN_FOREST = (0, 117, 94, 255) TRUE_BLUE = (0, 115, 207, 255) +TRANSPARENT_BLACK = (0, 0, 0, 0) TUFTS_BLUE = (65, 125, 193, 255) TULIP = (255, 135, 141, 255) TUMBLEWEED = (222, 170, 136, 255) diff --git a/arcade/examples/bloom_defender.py b/arcade/examples/bloom_defender.py index 9577ae7e2..c4c2cc04e 100644 --- a/arcade/examples/bloom_defender.py +++ b/arcade/examples/bloom_defender.py @@ -240,7 +240,7 @@ def on_draw(self): # Draw to the 'bloom' layer self.bloom_screen.use() - self.bloom_screen.clear((0, 0, 0, 0)) + self.bloom_screen.clear(arcade.color.TRANSPARENT_BLACK) arcade.set_viewport(self.view_left, SCREEN_WIDTH + self.view_left, diff --git a/arcade/experimental/bloom_multilayer_defender.py b/arcade/experimental/bloom_multilayer_defender.py index e24d8c255..475f311b2 100644 --- a/arcade/experimental/bloom_multilayer_defender.py +++ b/arcade/experimental/bloom_multilayer_defender.py @@ -250,7 +250,7 @@ def on_draw(self): # Draw to the 'slight bloom' layer self.slight_bloom_screen.use() - self.slight_bloom_screen.clear((0, 0, 0, 0)) + self.slight_bloom_screen.clear(arcade.color.TRANSPARENT_BLACK) arcade.set_viewport(self.view_left, SCREEN_WIDTH + self.view_left, @@ -262,7 +262,7 @@ def on_draw(self): # # Draw to the 'intense bloom' layer self.intense_bloom_screen.use() - self.intense_bloom_screen.clear((0, 0, 0, 0)) + self.intense_bloom_screen.clear(arcade.color.TRANSPARENT_BLACK) arcade.set_viewport(self.view_left, SCREEN_WIDTH + self.view_left, diff --git a/arcade/gui/surface.py b/arcade/gui/surface.py index 309494102..2a39f60d7 100644 --- a/arcade/gui/surface.py +++ b/arcade/gui/surface.py @@ -3,6 +3,7 @@ import arcade from arcade import Texture +from arcade.color import TRANSPARENT_BLACK from arcade.gl import Framebuffer from arcade.gl import geometry from arcade.gui.nine_patch import NinePatchTexture @@ -102,7 +103,7 @@ def width(self) -> int: def height(self) -> int: return self._size[1] - def clear(self, color: arcade.Color = (0, 0, 0, 0)): + def clear(self, color: arcade.Color = TRANSPARENT_BLACK): """Clear the surface""" self.fbo.clear(color=color) diff --git a/arcade/gui/widgets/__init__.py b/arcade/gui/widgets/__init__.py index b6e8b2f78..99791caca 100644 --- a/arcade/gui/widgets/__init__.py +++ b/arcade/gui/widgets/__init__.py @@ -16,6 +16,7 @@ import arcade from arcade import Sprite, get_window, Texture +from arcade.color import TRANSPARENT_BLACK from arcade.gui.events import ( UIEvent, UIMouseMovementEvent, @@ -829,7 +830,7 @@ def on_update(self, dt): def do_render(self, surface: Surface): self.prepare_render(surface) - surface.clear(color=(0, 0, 0, 0)) + surface.clear(color=TRANSPARENT_BLACK) surface.draw_sprite(0, 0, self.width, self.height, self._sprite) @@ -887,7 +888,7 @@ def __init__( y=0, width=100, height=100, - color=(0, 0, 0, 0), + color=TRANSPARENT_BLACK, size_hint=None, size_hint_min=None, size_hint_max=None, diff --git a/arcade/texture.py b/arcade/texture.py index 13a8d23a5..bcc2953db 100644 --- a/arcade/texture.py +++ b/arcade/texture.py @@ -17,6 +17,7 @@ calculate_hit_box_points_simple, calculate_hit_box_points_detailed, ) +from arcade.color import TRANSPARENT_BLACK from arcade.resources import resolve_resource_path from arcade.cache.hit_box import HitBoxCache from arcade.cache.image import WeakImageCache @@ -206,7 +207,7 @@ def create_empty(cls, name: str, size: Tuple[int, int]) -> "Texture": """ return Texture( name, - image=PIL.Image.new("RGBA", size, (0, 0, 0, 0)), + image=PIL.Image.new("RGBA", size, TRANSPARENT_BLACK), hit_box_algorithm=None, ) @@ -707,7 +708,7 @@ def make_circle_texture(diameter: int, color: Color, name: Optional[str] = None) "circle_texture", diameter, color[0], color[1], color[2] ) - bg_color = (0, 0, 0, 0) # fully transparent + bg_color = TRANSPARENT_BLACK # fully transparent img = PIL.Image.new("RGBA", (diameter, diameter), bg_color) draw = PIL.ImageDraw.Draw(img) draw.ellipse((0, 0, diameter - 1, diameter - 1), fill=color) @@ -745,7 +746,7 @@ def make_soft_circle_texture( outer_alpha, ) # name must be unique for caching - bg_color = (0, 0, 0, 0) # fully transparent + bg_color = TRANSPARENT_BLACK img = PIL.Image.new("RGBA", (diameter, diameter), bg_color) draw = PIL.ImageDraw.Draw(img) max_radius = int(diameter // 2) @@ -789,7 +790,7 @@ def make_soft_square_texture( "gradientsquare", size, color, center_alpha, outer_alpha ) - bg_color = (0, 0, 0, 0) # fully transparent + bg_color = TRANSPARENT_BLACK img = PIL.Image.new("RGBA", (size, size), bg_color) draw = PIL.ImageDraw.Draw(img) half_size = int(size // 2) diff --git a/tests/unit/test_color.py b/tests/unit/test_color.py index 0a3b3960b..27860dc26 100644 --- a/tests/unit/test_color.py +++ b/tests/unit/test_color.py @@ -2,4 +2,4 @@ def test_colors(): from arcade import color names = color.__dict__.keys() - assert 1012 == len(names) + assert 1013 == len(names)