Skip to content

Commit 9896ff6

Browse files
committed
fix is_transparent
1 parent ffc8174 commit 9896ff6

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/textual/color.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ def inverse(self) -> Color:
209209
@property
210210
def is_transparent(self) -> bool:
211211
"""Is the color transparent (i.e. has 0 alpha)?"""
212-
return self.a == 0 and self.ansi is not None
212+
return self.a == 0 and self.ansi is None
213213

214214
@property
215215
def clamped(self) -> Color:

tests/test_color.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,3 +256,12 @@ def test_gradient():
256256
assert gradient.get_color(1.2) == Color(0, 255, 0)
257257
assert gradient.get_color(0.5) == Color(0, 0, 255)
258258
assert gradient.get_color(0.7) == Color(0, 101, 153)
259+
260+
261+
def test_is_transparent():
262+
"""Check is_transparent is reporting correctly."""
263+
assert Color(0, 0, 0, 0).is_transparent
264+
assert Color(20, 20, 30, 0).is_transparent
265+
assert not Color(20, 20, 30, a=0.01).is_transparent
266+
assert not Color(20, 20, 30, a=1).is_transparent
267+
assert not Color(20, 20, 30, 0, ansi=1).is_transparent

0 commit comments

Comments
 (0)