From 7626a7902373b862baeb6b9ef33987665e1327c1 Mon Sep 17 00:00:00 2001 From: devfred78 <97401939+devfred78@users.noreply.github.com> Date: Fri, 11 Feb 2022 18:17:00 +0100 Subject: [PATCH] add control for transparency values --- pygconsole/console.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pygconsole/console.py b/pygconsole/console.py index 3b04d55..90f9c46 100644 --- a/pygconsole/console.py +++ b/pygconsole/console.py @@ -476,8 +476,11 @@ class Console(): self.log.warning(f"{value} cannot be applied to a transparency value. The default value is kept: {self.Console.DEFAULT_ALPHA}") value_int = Console.DEFAULT_ALPHA finally: + if value_int > 255: value_int = 255 + elif value_int < 0: value_int = 0 self._font_transparency = value_int self.log.debug(f"The font transparency is set to {value_int}.") + self._render_all() @property def background_transparency(self): @@ -494,8 +497,11 @@ class Console(): self.log.warning(f"{value} cannot be applied to a transparency value. The default value is kept: {self.Console.DEFAULT_ALPHA}") value_int = Console.DEFAULT_ALPHA finally: + if value_int > 255: value_int = 255 + elif value_int < 0: value_int = 0 self._background_transparency = value_int self.log.debug(f"The background transparency is set to {value_int}.") + self._render_all() @property def italic(self):