Skip to content

Commit

Permalink
2.0.0 - Material Design 3
Browse files Browse the repository at this point in the history
Add `dynamic_color_quality` attribute.
  • Loading branch information
HeaTTheatR committed Jan 16, 2024
1 parent 2609318 commit 7d15b9b
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions kivymd/theming.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,18 @@ def build(self):
and defaults to `None`.
"""

current_color_theme = DictProperty()
dynamic_color_quality = NumericProperty(10)
"""
The quality of the generated color scheme from the system wallpaper.
.. warning::
Remember that by increasing the quality value, you also increase the
generation time of the color scheme.
:attr:`dynamic_color_quality` is an :class:`~kivy.properties.NumericProperty`
and defaults to `10`.
"""

dynamic_color = BooleanProperty(False)
"""
Expand Down Expand Up @@ -638,7 +649,9 @@ def set_colors(self, *args) -> None:
if path_to_wallpaper:
size_wallpaper = os.path.getsize(path_to_wallpaper)
if size_wallpaper != self._size_current_wallpaper:
self._size_current_wallpaper = os.path.getsize(path_to_wallpaper)
self._size_current_wallpaper = os.path.getsize(
path_to_wallpaper
)
self._set_dynamic_color(path_to_wallpaper)
else:
Logger.info(
Expand Down Expand Up @@ -673,7 +686,10 @@ def _set_dynamic_color(self, path_to_wallpaper: str) -> None:
image = Image.open(path_to_wallpaper)
pixel_len = image.width * image.height
image_data = image.getdata()
pixel_array = [image_data[_] for _ in range(0, pixel_len, 10)]
pixel_array = [
image_data[_]
for _ in range(0, pixel_len, self.dynamic_color_quality)
]
end_time = default_timer()

Logger.info(
Expand Down

0 comments on commit 7d15b9b

Please sign in to comment.