crystalwindow 3.8.4__tar.gz → 3.8.6__tar.gz

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 (44) hide show
  1. {crystalwindow-3.8.4/crystalwindow.egg-info → crystalwindow-3.8.6}/PKG-INFO +1 -1
  2. {crystalwindow-3.8.4 → crystalwindow-3.8.6}/crystalwindow/__init__.py +2 -1
  3. crystalwindow-3.8.6/crystalwindow/color_handler.py +123 -0
  4. {crystalwindow-3.8.4 → crystalwindow-3.8.6}/crystalwindow/gui.py +0 -4
  5. {crystalwindow-3.8.4 → crystalwindow-3.8.6}/crystalwindow/gui_ext.py +34 -16
  6. {crystalwindow-3.8.4 → crystalwindow-3.8.6/crystalwindow.egg-info}/PKG-INFO +1 -1
  7. {crystalwindow-3.8.4 → crystalwindow-3.8.6}/crystalwindow.egg-info/SOURCES.txt +1 -0
  8. {crystalwindow-3.8.4 → crystalwindow-3.8.6}/setup.py +1 -1
  9. {crystalwindow-3.8.4 → crystalwindow-3.8.6}/LICENSE +0 -0
  10. {crystalwindow-3.8.4 → crystalwindow-3.8.6}/MANIFEST.in +0 -0
  11. {crystalwindow-3.8.4 → crystalwindow-3.8.6}/README.md +0 -0
  12. {crystalwindow-3.8.4 → crystalwindow-3.8.6}/crystalwindow/FileHelper.py +0 -0
  13. {crystalwindow-3.8.4 → crystalwindow-3.8.6}/crystalwindow/Icons/default_icon.png +0 -0
  14. {crystalwindow-3.8.4 → crystalwindow-3.8.6}/crystalwindow/animation.py +0 -0
  15. {crystalwindow-3.8.4 → crystalwindow-3.8.6}/crystalwindow/assets.py +0 -0
  16. {crystalwindow-3.8.4 → crystalwindow-3.8.6}/crystalwindow/camera.py +0 -0
  17. {crystalwindow-3.8.4 → crystalwindow-3.8.6}/crystalwindow/clock.py +0 -0
  18. {crystalwindow-3.8.4 → crystalwindow-3.8.6}/crystalwindow/collision.py +0 -0
  19. {crystalwindow-3.8.4 → crystalwindow-3.8.6}/crystalwindow/crystal3d.py +0 -0
  20. {crystalwindow-3.8.4 → crystalwindow-3.8.6}/crystalwindow/docs/getting_started.md +0 -0
  21. {crystalwindow-3.8.4 → crystalwindow-3.8.6}/crystalwindow/docs/index.md +0 -0
  22. {crystalwindow-3.8.4 → crystalwindow-3.8.6}/crystalwindow/draw_helpers.py +0 -0
  23. {crystalwindow-3.8.4 → crystalwindow-3.8.6}/crystalwindow/draw_rects.py +0 -0
  24. {crystalwindow-3.8.4 → crystalwindow-3.8.6}/crystalwindow/draw_text_helper.py +0 -0
  25. {crystalwindow-3.8.4 → crystalwindow-3.8.6}/crystalwindow/draw_tool.py +0 -0
  26. {crystalwindow-3.8.4 → crystalwindow-3.8.6}/crystalwindow/fun_helpers.py +0 -0
  27. {crystalwindow-3.8.4 → crystalwindow-3.8.6}/crystalwindow/gametests/3dsquare.py +0 -0
  28. {crystalwindow-3.8.4 → crystalwindow-3.8.6}/crystalwindow/gametests/__init__.py +0 -0
  29. {crystalwindow-3.8.4 → crystalwindow-3.8.6}/crystalwindow/gametests/__main__.py +0 -0
  30. {crystalwindow-3.8.4 → crystalwindow-3.8.6}/crystalwindow/gametests/gravitytest.py +0 -0
  31. {crystalwindow-3.8.4 → crystalwindow-3.8.6}/crystalwindow/gametests/guitesting.py +0 -0
  32. {crystalwindow-3.8.4 → crystalwindow-3.8.6}/crystalwindow/gametests/sandbox.py +0 -0
  33. {crystalwindow-3.8.4 → crystalwindow-3.8.6}/crystalwindow/gametests/squaremove.py +0 -0
  34. {crystalwindow-3.8.4 → crystalwindow-3.8.6}/crystalwindow/gametests/windowtesting.py +0 -0
  35. {crystalwindow-3.8.4 → crystalwindow-3.8.6}/crystalwindow/gravity.py +0 -0
  36. {crystalwindow-3.8.4 → crystalwindow-3.8.6}/crystalwindow/math.py +0 -0
  37. {crystalwindow-3.8.4 → crystalwindow-3.8.6}/crystalwindow/player.py +0 -0
  38. {crystalwindow-3.8.4 → crystalwindow-3.8.6}/crystalwindow/sprites.py +0 -0
  39. {crystalwindow-3.8.4 → crystalwindow-3.8.6}/crystalwindow/tilemap.py +0 -0
  40. {crystalwindow-3.8.4 → crystalwindow-3.8.6}/crystalwindow/ver_warner.py +0 -0
  41. {crystalwindow-3.8.4 → crystalwindow-3.8.6}/crystalwindow/window.py +0 -0
  42. {crystalwindow-3.8.4 → crystalwindow-3.8.6}/crystalwindow.egg-info/dependency_links.txt +0 -0
  43. {crystalwindow-3.8.4 → crystalwindow-3.8.6}/crystalwindow.egg-info/top_level.txt +0 -0
  44. {crystalwindow-3.8.4 → crystalwindow-3.8.6}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: crystalwindow
3
- Version: 3.8.4
3
+ Version: 3.8.6
4
4
  Summary: A Tkinter powered window + GUI toolkit made by Crystal (MEEEEEE)! Easier apps, smoother UI and all-in-one helpers!
5
5
  Home-page: https://pypi.org/project/crystalwindow/
6
6
  Author: CrystalBallyHereXD
@@ -44,6 +44,7 @@ from .draw_tool import CrystalDraw
44
44
  # === Misc Helpers ===
45
45
  from .fun_helpers import random_name, DebugOverlay
46
46
  from .camera import Camera
47
+ from .color_handler import Colors, Color
47
48
 
48
49
  # === 3D Engine ===
49
50
  from .crystal3d import CW3D
@@ -81,7 +82,7 @@ __all__ = [
81
82
  "gradient_rect", "CameraShake", "DrawHelper", "DrawTextManager", "CrystalDraw",
82
83
 
83
84
  # --- Misc ---
84
- "random_name", "DebugOverlay", "Camera",
85
+ "random_name", "DebugOverlay", "Camera", "Colors", "Color",
85
86
 
86
87
  # --- 3D ---
87
88
  "CW3D",
@@ -0,0 +1,123 @@
1
+ # --------------------------------------
2
+ # CrystalWindow Color System v2.0
3
+ # --------------------------------------
4
+
5
+ class Colors:
6
+ # BASIC COLORS
7
+ Black = (0, 0, 0)
8
+ White = (255, 255, 255)
9
+ Red = (255, 0, 0)
10
+ Green = (0, 255, 0)
11
+ Blue = (0, 0, 255)
12
+ Yellow = (255, 255, 0)
13
+ Cyan = (0, 255, 255)
14
+ Magenta = (255, 0, 255)
15
+ Gray = (120, 120, 120)
16
+ DarkGray = (40, 40, 40)
17
+
18
+ # CRYSTALWINDOW CUSTOM
19
+ CrystalBlue = (87, 199, 255)
20
+ Accent = (87, 199, 255)
21
+ Success = (76, 255, 111)
22
+ Error = (255, 68, 68)
23
+ Transparent = (0, 0, 0, 0) # full alpha
24
+
25
+
26
+ class Color:
27
+ COLOR_NAMES = {name.lower(): value for name, value in Colors.__dict__.items()
28
+ if not name.startswith("__")}
29
+
30
+ def __init__(self, r=None, g=None, b=None, a=255, hex_value=None):
31
+ # -------------------------------------------------
32
+ # 1) raw tuple variable: Color(Blue)
33
+ # -------------------------------------------------
34
+ if isinstance(r, (tuple, list)):
35
+ if len(r) == 3: # rgb
36
+ self.r, self.g, self.b = r
37
+ self.a = a
38
+ elif len(r) == 4: # rgba
39
+ self.r, self.g, self.b, self.a = r
40
+ return
41
+
42
+ # -------------------------------------------------
43
+ # 2) name string: Color("blue")
44
+ # -------------------------------------------------
45
+ if isinstance(r, str):
46
+ name = r.lower()
47
+ if name not in self.COLOR_NAMES:
48
+ raise ValueError(f"unknown color name: {r}")
49
+ data = self.COLOR_NAMES[name]
50
+ if len(data) == 4:
51
+ self.r, self.g, self.b, self.a = data
52
+ else:
53
+ self.r, self.g, self.b = data
54
+ self.a = a
55
+ return
56
+
57
+ # -------------------------------------------------
58
+ # 3) HEX input
59
+ # -------------------------------------------------
60
+ if hex_value is not None:
61
+ self.r, self.g, self.b, self.a = self.hex_to_rgba(hex_value)
62
+ return
63
+
64
+ # -------------------------------------------------
65
+ # 4) manual RGB
66
+ # -------------------------------------------------
67
+ self.r = r or 0
68
+ self.g = g or 0
69
+ self.b = b or 0
70
+ self.a = a
71
+
72
+ # convert hex -> rgba
73
+ @staticmethod
74
+ def hex_to_rgba(hex_value: str):
75
+ hex_value = hex_value.replace("#", "")
76
+ if len(hex_value) == 6:
77
+ r = int(hex_value[0:2], 16)
78
+ g = int(hex_value[2:4], 16)
79
+ b = int(hex_value[4:6], 16)
80
+ a = 255
81
+ elif len(hex_value) == 8:
82
+ r = int(hex_value[0:2], 16)
83
+ g = int(hex_value[2:4], 16)
84
+ b = int(hex_value[4:6], 16)
85
+ a = int(hex_value[6:8], 16)
86
+ else:
87
+ raise ValueError("bad hex bruh")
88
+ return r, g, b, a
89
+
90
+ # return pygame-friendly color tuple
91
+ def to_tuple(self):
92
+ return (self.r, self.g, self.b, self.a)
93
+
94
+ # rgba -> hex
95
+ def to_hex(self):
96
+ return "#{:02X}{:02X}{:02X}{:02X}".format(self.r, self.g, self.b, self.a)
97
+
98
+ # quick alpha edit
99
+ def set_alpha(self, a):
100
+ self.a = max(0, min(255, a))
101
+ return self
102
+
103
+ # color math
104
+ def brighten(self, amt=30):
105
+ self.r = min(255, self.r + amt)
106
+ self.g = min(255, self.g + amt)
107
+ self.b = min(255, self.b + amt)
108
+ return self
109
+
110
+ def darken(self, amt=30):
111
+ self.r = max(0, self.r - amt)
112
+ self.g = max(0, self.g - amt)
113
+ self.b = max(0, self.b - amt)
114
+ return self
115
+
116
+ @staticmethod
117
+ def lerp(c1, c2, t: float):
118
+ """blend between two colors"""
119
+ r = c1.r + (c2.r - c1.r) * t
120
+ g = c1.g + (c2.g - c1.g) * t
121
+ b = c1.b + (c2.b - c1.b) * t
122
+ a = c1.a + (c2.a - c1.a) * t
123
+ return Color(int(r), int(g), int(b), int(a))
@@ -9,10 +9,6 @@ def hex_to_rgb(hex_str):
9
9
  hex_str = hex_str.lstrip("#")
10
10
  return tuple(int(hex_str[i:i+2], 16) for i in (0, 2, 4))
11
11
 
12
- def random_color():
13
- """Return a random RGB color"""
14
- return (random.randint(0,255), random.randint(0,255), random.randint(0,255))
15
-
16
12
  def lerp_color(c1, c2, t):
17
13
  """Linearly interpolate between two colors"""
18
14
  return tuple(int(a + (b-a)*t) for a,b in zip(c1,c2))
@@ -3,35 +3,48 @@ from .window import Window
3
3
  from .assets import load_image
4
4
  from .sprites import Sprite
5
5
  from .gui import Button
6
+ from .color_handler import Colors, Color
7
+
8
+ def parse_color(c):
9
+ if isinstance(c, tuple):
10
+ return c
11
+ if isinstance(c, Color):
12
+ return c.to_tuple()
13
+ if isinstance(c, str):
14
+ if hasattr(Colors, c):
15
+ return getattr(Colors, c).to_tuple()
16
+ return (255,255,255)
17
+ return (255,255,255)
6
18
 
7
19
  class Toggle:
8
- def __init__(self, rect, value=False, color=(200,200,200), hover_color=(255,255,255), cooldown=0.1):
9
- # rect = (x, y, w, h)
20
+ def __init__(self, rect, value=False, color="gray", hover_color="white", cooldown=0.1):
10
21
  self.rect = rect
11
22
  self.value = value
12
- self.color = color
13
- self.hover_color = hover_color
23
+
24
+ self.color = parse_color(color)
25
+ self.hover_color = parse_color(hover_color)
26
+
14
27
  self.hovered = False
15
28
  self.cooldown = cooldown
16
- self._last_toggle = 0 # last time it was toggled
29
+ self._last_toggle = 0
17
30
 
18
31
  def update(self, win: Window):
19
32
  mx, my = win.mouse_pos
20
33
  x, y, w, h = self.rect
21
34
  self.hovered = x <= mx <= x + w and y <= my <= y + h
22
35
 
23
- # check cooldown timer
24
36
  now = time.time()
25
37
  can_toggle = now - self._last_toggle >= self.cooldown
26
38
 
27
39
  if self.hovered and win.mouse_pressed(1) and can_toggle:
28
40
  self.value = not self.value
29
- self._last_toggle = now # reset cooldown timer
41
+ self._last_toggle = now
30
42
 
31
43
  def draw(self, win: Window):
32
44
  draw_color = self.hover_color if self.hovered else self.color
33
45
  win.draw_rect(draw_color, self.rect)
34
- # lil inner "ON" glow thingy
46
+
47
+ # ON glow
35
48
  if self.value:
36
49
  inner = (
37
50
  self.rect[0] + 4,
@@ -43,13 +56,15 @@ class Toggle:
43
56
 
44
57
 
45
58
  class Slider:
46
- def __init__(self, rect, min_val=0, max_val=100, value=50, color=(150,150,150), handle_radius=10):
47
- # rect = (x, y, w, h)
59
+ def __init__(self, rect, min_val=0, max_val=100, value=50, color="lightgray", handle_color="red", handle_radius=10):
48
60
  self.rect = rect
49
61
  self.min_val = min_val
50
62
  self.max_val = max_val
51
63
  self.value = value
52
- self.color = color
64
+
65
+ self.color = parse_color(color)
66
+ self.handle_color = parse_color(handle_color)
67
+
53
68
  self.handle_radius = handle_radius
54
69
  self.dragging = False
55
70
 
@@ -60,21 +75,24 @@ class Slider:
60
75
  handle_x = x + ((self.value - self.min_val) / (self.max_val - self.min_val)) * w
61
76
  handle_y = y + h // 2
62
77
 
63
- # start drag if mouse clicks inside slider bar area
64
78
  if win.mouse_pressed(1):
65
79
  if not self.dragging and (x <= mx <= x+w and y <= my <= y+h):
66
80
  self.dragging = True
67
81
  else:
68
- self.dragging = False # stop drag when released
82
+ self.dragging = False
69
83
 
70
- # update value while dragging
71
84
  if self.dragging:
72
- rel_x = max(0, min(mx - x, w)) # clamp
85
+ rel_x = max(0, min(mx - x, w))
73
86
  self.value = self.min_val + (rel_x / w) * (self.max_val - self.min_val)
74
87
 
75
88
  def draw(self, win: Window):
76
89
  x, y, w, h = self.rect
90
+
91
+ # bar
77
92
  win.draw_rect(self.color, (x, y + h//2 - 2, w, 4))
93
+
94
+ # handle
78
95
  handle_x = x + ((self.value - self.min_val) / (self.max_val - self.min_val)) * w
79
96
  handle_y = y + h // 2
80
- win.draw_circle((255, 0, 0), (int(handle_x), int(handle_y)), self.handle_radius)
97
+
98
+ win.draw_circle(self.handle_color, (int(handle_x), int(handle_y)), self.handle_radius)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: crystalwindow
3
- Version: 3.8.4
3
+ Version: 3.8.6
4
4
  Summary: A Tkinter powered window + GUI toolkit made by Crystal (MEEEEEE)! Easier apps, smoother UI and all-in-one helpers!
5
5
  Home-page: https://pypi.org/project/crystalwindow/
6
6
  Author: CrystalBallyHereXD
@@ -9,6 +9,7 @@ crystalwindow/assets.py
9
9
  crystalwindow/camera.py
10
10
  crystalwindow/clock.py
11
11
  crystalwindow/collision.py
12
+ crystalwindow/color_handler.py
12
13
  crystalwindow/crystal3d.py
13
14
  crystalwindow/draw_helpers.py
14
15
  crystalwindow/draw_rects.py
@@ -7,7 +7,7 @@ with open("README.md", encoding="utf-8") as f:
7
7
 
8
8
  setup(
9
9
  name="crystalwindow",
10
- version="3.8.4", # Force metadata refresh
10
+ version="3.8.6", # Force metadata refresh
11
11
  packages=find_packages(include=["crystalwindow", "crystalwindow.*"]),
12
12
 
13
13
  include_package_data=True, # include package_data files
File without changes
File without changes
File without changes
File without changes