Repository navigation
Expand file tree
/
Copy pathpatch.diff
More file actions
42 lines (42 loc) · 2.08 KB
/
Copy pathpatch.diff
File metadata and controls
42 lines (42 loc) · 2.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
@@
- if self._bg_source_image is not None and bg_kind in {"path", "generated"}:
- try:
- stats = ImageStat.Stat(self._bg_source_image)
- mean = stats.mean[:3]
- def clamp(val):
- return max(0, min(255, int(round(val))))
- base_rgb = tuple(clamp(v) for v in mean)
- luminance = 0.2126 * base_rgb[0] + 0.7152 * base_rgb[1] + 0.0722 * base_rgb[2]
- fg = "#101010" if luminance > 155 else "#f5f7fb"
- def mix(rgb, factor, offset=0.0):
- return tuple(clamp(rgb[i] * factor + offset) for i in range(3))
- def rgb_hex(rgb):
- return "#%02x%02x%02x" % rgb
- bg = rgb_hex(base_rgb)
- panel_bg = rgb_hex(mix(base_rgb, 0.75, 18))
- btn_bg = rgb_hex(mix(base_rgb, 0.6, 12))
- entry_bg = rgb_hex(mix(base_rgb, 0.85, 18))
- night = luminance <= 155
- self.nightmode.set(night)
- except Exception:
- pass
+ translucent_layers = False
+ if self._bg_source_image is not None and bg_kind in {"path", "generated"}:
+ translucent_layers = True
+ try:
+ stats = ImageStat.Stat(self._bg_source_image)
+ mean = stats.mean[:3]
+ def clamp(val):
+ return max(0, min(255, int(round(val))))
+ base_rgb = tuple(clamp(v) for v in mean)
+ luminance = 0.2126 * base_rgb[0] + 0.7152 * base_rgb[1] + 0.0722 * base_rgb[2]
+ fg = "#101010" if luminance > 155 else "#f5f7fb"
+ panel_bg = self._rgba_hex(base_rgb, 0.08, "#1a1a1a")
+ btn_bg = self._rgba_hex(base_rgb, 0.35, "#2a2a2a")
+ entry_bg = self._rgba_hex(base_rgb, 0.18, "#1f1f1f")
+ night = luminance <= 155
+ self.nightmode.set(night)
+ except Exception:
+ translucent_layers = False
+ if translucent_layers:
+ bg = "#000000"