dynamic-icon-engine 1.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. dynamic_icon_engine/__init__.py +37 -0
  2. dynamic_icon_engine/_version.py +1 -0
  3. dynamic_icon_engine/animation.py +247 -0
  4. dynamic_icon_engine/appearance.py +77 -0
  5. dynamic_icon_engine/controller.py +266 -0
  6. dynamic_icon_engine/errors.py +34 -0
  7. dynamic_icon_engine/graphic_set.py +436 -0
  8. dynamic_icon_engine/renderer.py +228 -0
  9. dynamic_icon_engine/resources/__init__.py +0 -0
  10. dynamic_icon_engine/resources/default/manifest.json +84 -0
  11. dynamic_icon_engine/resources/default/symbol.png +0 -0
  12. dynamic_icon_engine/resources/default/symbol_16.png +0 -0
  13. dynamic_icon_engine/resources/default/symbol_20.png +0 -0
  14. dynamic_icon_engine/resources/default/symbol_24.png +0 -0
  15. dynamic_icon_engine/resources/default/symbol_32.png +0 -0
  16. dynamic_icon_engine/resources/default/symbol_ext.png +0 -0
  17. dynamic_icon_engine/resources/default/symbol_ext_16.png +0 -0
  18. dynamic_icon_engine/resources/default/symbol_ext_20.png +0 -0
  19. dynamic_icon_engine/resources/default/symbol_ext_24.png +0 -0
  20. dynamic_icon_engine/resources/default/symbol_ext_32.png +0 -0
  21. dynamic_icon_engine/resources/default/symbol_ext_clearance.png +0 -0
  22. dynamic_icon_engine/resources/default/symbol_ext_clearance_16.png +0 -0
  23. dynamic_icon_engine/resources/default/symbol_ext_clearance_20.png +0 -0
  24. dynamic_icon_engine/resources/default/symbol_ext_clearance_24.png +0 -0
  25. dynamic_icon_engine/resources/default/symbol_ext_clearance_32.png +0 -0
  26. dynamic_icon_engine/testlab/__init__.py +4 -0
  27. dynamic_icon_engine/testlab/__main__.py +87 -0
  28. dynamic_icon_engine/testlab/palette.py +96 -0
  29. dynamic_icon_engine/testlab/window.py +417 -0
  30. dynamic_icon_engine-1.0.0.dist-info/METADATA +176 -0
  31. dynamic_icon_engine-1.0.0.dist-info/RECORD +35 -0
  32. dynamic_icon_engine-1.0.0.dist-info/WHEEL +5 -0
  33. dynamic_icon_engine-1.0.0.dist-info/entry_points.txt +2 -0
  34. dynamic_icon_engine-1.0.0.dist-info/licenses/LICENSE +21 -0
  35. dynamic_icon_engine-1.0.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,84 @@
1
+ {
2
+ "format": "dynamic-icon-engine.graphic-set",
3
+ "format_version": 1,
4
+ "name": "default",
5
+ "description": "Neutrales Standard-Grafikset: Symbol, optionale Erweiterungsebene und Freistellmaske.",
6
+ "safety_margin": 0.0625,
7
+ "layers": {
8
+ "symbol": {
9
+ "file": "symbol.png",
10
+ "sizes": {
11
+ "16": "symbol_16.png",
12
+ "20": "symbol_20.png",
13
+ "24": "symbol_24.png",
14
+ "32": "symbol_32.png"
15
+ }
16
+ },
17
+ "symbol_ext": {
18
+ "file": "symbol_ext.png",
19
+ "sizes": {
20
+ "16": "symbol_ext_16.png",
21
+ "20": "symbol_ext_20.png",
22
+ "24": "symbol_ext_24.png",
23
+ "32": "symbol_ext_32.png"
24
+ }
25
+ },
26
+ "symbol_ext_clearance": {
27
+ "file": "symbol_ext_clearance.png",
28
+ "sizes": {
29
+ "16": "symbol_ext_clearance_16.png",
30
+ "20": "symbol_ext_clearance_20.png",
31
+ "24": "symbol_ext_clearance_24.png",
32
+ "32": "symbol_ext_clearance_32.png"
33
+ }
34
+ }
35
+ },
36
+ "provenance": {
37
+ "tool": "tools/derive_default_graphic_set.py",
38
+ "note": "Eigene, selbst gestaltete Originalgrafik des Projekturhebers (MIT-freigegeben, siehe LICENSE); nur der Alphakanal wird verwendet. Die Originale bleiben privat und sind nicht Teil dieses Pakets; die SHA-256-Werte beziehen sich auf diese privaten Originale.",
39
+ "sources": {
40
+ "symbol": {
41
+ "file": "private-original-symbol.png",
42
+ "sha256": "96dcb25e3edfc7c942c75b79da52d185060de2a74e6a2912368aabcae0dda7f0"
43
+ },
44
+ "symbol_ext": {
45
+ "file": "private-original-symbol-ext.png",
46
+ "sha256": "1c3d3a5e29c9f8996a81e0dbf22370e6c867c32170d6784b51d3c6986714a9cb"
47
+ }
48
+ },
49
+ "common_alpha_bounds_px": [
50
+ 305,
51
+ 216,
52
+ 643,
53
+ 797
54
+ ],
55
+ "master_size_px": 512,
56
+ "master_gap_px": 20,
57
+ "tuned_sizes": {
58
+ "16": {
59
+ "symbol_thickening_px": 0.22,
60
+ "ext_thickening_px": 0.32,
61
+ "gap_px": 1.0,
62
+ "gap_one_sided": true
63
+ },
64
+ "20": {
65
+ "symbol_thickening_px": 0.18,
66
+ "ext_thickening_px": 0.28,
67
+ "gap_px": 1.0,
68
+ "gap_one_sided": true
69
+ },
70
+ "24": {
71
+ "symbol_thickening_px": 0.14,
72
+ "ext_thickening_px": 0.22,
73
+ "gap_px": 1.05,
74
+ "gap_one_sided": true
75
+ },
76
+ "32": {
77
+ "symbol_thickening_px": 0.08,
78
+ "ext_thickening_px": 0.12,
79
+ "gap_px": 1.1,
80
+ "gap_one_sided": false
81
+ }
82
+ }
83
+ }
84
+ }
@@ -0,0 +1,4 @@
1
+ """Standalone PySide6 test lab for the dynamic icon engine (demo only, not the engine core).
2
+
3
+ Start: ``python -m dynamic_icon_engine.testlab`` (or ``dynamic-icon-testlab``).
4
+ """
@@ -0,0 +1,87 @@
1
+ """Entry point of the test lab.
2
+
3
+ Options:
4
+ --color-scheme {system,light,dark} default: follow the system colour scheme
5
+ --smoke run through all reference cases, then quit (exit code 0 = ok)
6
+ --screenshot DIR with --smoke: save window screenshots into DIR
7
+ --duration-ms N with --smoke: dwell time per step (default 250)
8
+ """
9
+
10
+ from __future__ import annotations
11
+
12
+ import argparse
13
+ import sys
14
+ import traceback
15
+ from pathlib import Path
16
+
17
+ from PySide6.QtCore import Qt, QTimer
18
+ from PySide6.QtWidgets import QApplication
19
+
20
+
21
+ def _parse(argv: list[str]) -> argparse.Namespace:
22
+ parser = argparse.ArgumentParser(prog="dynamic-icon-testlab", description="Dynamic Icon Engine – Testlabor")
23
+ parser.add_argument("--color-scheme", choices=("system", "light", "dark"), default="system")
24
+ parser.add_argument("--smoke", action="store_true")
25
+ parser.add_argument("--screenshot", type=Path)
26
+ parser.add_argument("--duration-ms", type=int, default=250)
27
+ return parser.parse_args(argv)
28
+
29
+
30
+ def main(argv: list[str] | None = None) -> int:
31
+ args = _parse(sys.argv[1:] if argv is None else argv)
32
+ app = QApplication.instance() or QApplication(sys.argv[:1])
33
+ if args.color_scheme != "system":
34
+ scheme = Qt.ColorScheme.Light if args.color_scheme == "light" else Qt.ColorScheme.Dark
35
+ app.styleHints().setColorScheme(scheme)
36
+
37
+ from .palette import TEST_CASES
38
+ from .window import TestLabWindow
39
+
40
+ window = TestLabWindow()
41
+ window.resize(1180, 760)
42
+ window.show()
43
+ if not args.smoke:
44
+ return app.exec()
45
+
46
+ failures: list[str] = []
47
+ steps = list(range(len(TEST_CASES)))
48
+ shot_dir = args.screenshot
49
+ if shot_dir:
50
+ shot_dir.mkdir(parents=True, exist_ok=True)
51
+
52
+ def step() -> None:
53
+ try:
54
+ if steps:
55
+ index = steps.pop(0)
56
+ window.apply_case(index)
57
+ if window.controller.appearance != TEST_CASES[index].appearance():
58
+ failures.append(f"Testfall {TEST_CASES[index].name} nicht übernommen")
59
+ if shot_dir and index in (0, 3, 12):
60
+ window.grab().save(str(shot_dir / f"testlab_{args.color_scheme}_case{index:02d}.png"))
61
+ QTimer.singleShot(args.duration_ms, step)
62
+ return
63
+ window.apply_custom_definition()
64
+ if not window.controller.is_animating:
65
+ failures.append("custom-Animation läuft nicht")
66
+ if shot_dir:
67
+ window.tabs.setCurrentIndex(1)
68
+ app.processEvents()
69
+ window.grab().save(str(shot_dir / f"testlab_{args.color_scheme}_vergleich.png"))
70
+ window.close()
71
+ if window.controller.is_animating or not window.controller.is_disposed:
72
+ failures.append("Controller nach Schließen nicht sauber beendet")
73
+ app.quit()
74
+ except Exception: # pragma: no cover - smoke diagnostics
75
+ failures.append(traceback.format_exc())
76
+ app.quit()
77
+
78
+ QTimer.singleShot(200, step)
79
+ app.exec()
80
+ for failure in failures:
81
+ print("SMOKE-FEHLER:", failure, file=sys.stderr)
82
+ print(f"testlab smoke: {'OK' if not failures else 'FEHLER'} ({len(TEST_CASES)} Testfälle)")
83
+ return 1 if failures else 0
84
+
85
+
86
+ if __name__ == "__main__":
87
+ raise SystemExit(main())
@@ -0,0 +1,96 @@
1
+ """External test data for the test lab and visual evidence - NOT part of the engine core.
2
+
3
+ The colour candidates and the case table are host reference data used only for
4
+ visual checks. Names describe a later host's situation; the engine itself never
5
+ sees or interprets them.
6
+ """
7
+
8
+ from __future__ import annotations
9
+
10
+ from dataclasses import dataclass
11
+
12
+ from dynamic_icon_engine import IconAppearance
13
+
14
+ #: Candidate colours (not finalized).
15
+ CANDIDATES: dict[str, str] = {
16
+ "dunkelblau": "#103C85",
17
+ "hellblau": "#36B9F5",
18
+ "dunkelgrün": "#087A38",
19
+ "hellgrün": "#58EE75",
20
+ "weiß": "#FFFFFF",
21
+ "gelb": "#FFDD32",
22
+ "rot": "#CE2028",
23
+ "hellgrau": "#C7CCD2",
24
+ "dunkel": "#202020",
25
+ }
26
+
27
+ #: Typical tray/taskbar surroundings used for previews.
28
+ SURROUNDINGS: dict[str, str] = {"hell": "#F3F3F3", "dunkel": "#202020"}
29
+
30
+
31
+ @dataclass(frozen=True)
32
+ class TestCase:
33
+ __test__ = False # not a pytest class
34
+
35
+ name: str
36
+ background: str
37
+ symbol: str
38
+ symbol_ext: bool
39
+ animation: str
40
+
41
+ def appearance(self) -> IconAppearance:
42
+ return IconAppearance(CANDIDATES[self.background], CANDIDATES[self.symbol], self.symbol_ext, self.animation)
43
+
44
+
45
+ #: Host reference table (visual checks only).
46
+ TEST_CASES: tuple[TestCase, ...] = (
47
+ TestCase("Blau Ruhe", "dunkelblau", "weiß", False, "none"),
48
+ TestCase("Blau Warten", "hellblau", "dunkelgrün", False, "none"),
49
+ TestCase("Blau Aufnahme", "hellblau", "hellgrün", False, "none"),
50
+ TestCase("Blau Nachlauf", "dunkelblau", "dunkelgrün", False, "blink_fast"),
51
+ TestCase("Grün Ruhe", "dunkelgrün", "weiß", False, "none"),
52
+ TestCase("Grün Warten", "hellgrün", "dunkelblau", False, "none"),
53
+ TestCase("Grün Aufnahme", "hellgrün", "hellblau", False, "none"),
54
+ TestCase("Grün Nachlauf", "dunkelgrün", "dunkelblau", False, "blink_fast"),
55
+ TestCase("Wiederverbindung", "gelb", "dunkel", False, "pulse_slow"),
56
+ TestCase("Wieder betriebsbereit (blau)", "dunkelblau", "weiß", False, "blink_triple"),
57
+ TestCase("Wieder betriebsbereit (grün)", "dunkelgrün", "weiß", False, "blink_triple"),
58
+ TestCase("Fatal", "rot", "weiß", False, "none"),
59
+ TestCase("Deaktiviert", "hellgrau", "rot", True, "none"),
60
+ )
61
+
62
+
63
+ def relative_luminance(color: str) -> float:
64
+ """WCAG 2.x relative luminance of ``#RRGGBB``."""
65
+ def channel(value: int) -> float:
66
+ c = value / 255.0
67
+ return c / 12.92 if c <= 0.04045 else ((c + 0.055) / 1.055) ** 2.4
68
+
69
+ r, g, b = (int(color[i:i + 2], 16) for i in (1, 3, 5))
70
+ return 0.2126 * channel(r) + 0.7152 * channel(g) + 0.0722 * channel(b)
71
+
72
+
73
+ def contrast_ratio(a: str, b: str) -> float:
74
+ """WCAG contrast ratio (1 .. 21). A luminance measure only - says nothing about hue."""
75
+ la, lb = sorted((relative_luminance(a), relative_luminance(b)), reverse=True)
76
+ return (la + 0.05) / (lb + 0.05)
77
+
78
+
79
+ #: Colour optimisation proposals (meaning unchanged: light stays light, dark stays dark).
80
+ PROPOSALS: tuple[tuple[str, str], ...] = (
81
+ ("Blau/Grün Aufnahme (hell auf hell, Kontrast 1,48)",
82
+ "Zwei helle Farben erreichen kaum mehr als ~2:1 Luminanzkontrast; die Unterscheidung trägt fast nur der "
83
+ "Farbton. Vorschlag: hellblau etwas satter #2BA8E6 und hellgrün etwas heller #7CF79A (1,99:1). "
84
+ "Bei 16 px bleibt das Symbol dennoch schwach - Alternative im späteren Host: neutrale dunkle Kontur im "
85
+ "Grafikset (nicht umgesetzt, da nicht zwingend)."),
86
+ ("Blau Nachlauf (dunkelgrün auf dunkelblau, 1,92)",
87
+ "Symbol leicht aufhellen, bleibt dunkelgrün: #12A150 (3,11:1). Während blink_fast sinkt die Hintergrund-"
88
+ "deckkraft auf 40 %; auf dunkler Taskleiste wird das Symbol dann vom Umfeld getragen."),
89
+ ("Grün Nachlauf (dunkelblau auf dunkelgrün, 1,92)",
90
+ "Symbol dunkler: #0A2E6E (2,36:1). Mehr ist ohne Bedeutungswechsel (dunkel/dunkel) kaum erreichbar."),
91
+ ("Deaktiviert (rot auf hellgrau, 3,37)",
92
+ "Rot etwas dunkler #B0141C (4,39:1) verbessert die Balkenlesbarkeit bei 16 px."),
93
+ ("Wiederverbindung / Grün Warten auf heller Taskleiste",
94
+ "gelb (#FFDD32) und hellgrün haben zur hellen Taskleiste nur 1,2-1,4:1; das vollflächige Quadrat hebt "
95
+ "sich dort fast nur über den Farbton ab. Kein Handlungsbedarf, aber beim Host-Test beachten."),
96
+ )