PlayPy 0.3.0__tar.gz → 0.3.1__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: PlayPy
3
- Version: 0.3.0
3
+ Version: 0.3.1
4
4
  Summary: PlayPy is a lightweight Python library for creating simple games and interactive applications with ease. It provides a straightforward API for handling graphics, input, and basic game mechanics, making it ideal for beginners and those looking to quickly prototype their ideas.
5
5
  Author-email: angel <angyv2861@gmail.com>
6
6
  Requires-Python: >=3.14
@@ -10,7 +10,7 @@ Requires-Dist: pygame-ce>=2.5.6
10
10
  Requires-Dist: colorama>=0.4.6
11
11
  Dynamic: license-file
12
12
 
13
- # PlayPy (0.3.0)
13
+ # PlayPy (0.3.1)
14
14
 
15
15
  PlayPy is a lightweight Python library for creating games, tools, and interactive applications using a retained-mode UI and scene system built on top of pygame. It focuses on rapid prototyping, composable rendering, and simple but powerful layout primitives.
16
16
 
@@ -1,4 +1,4 @@
1
- # PlayPy (0.3.0)
1
+ # PlayPy (0.3.1)
2
2
 
3
3
  PlayPy is a lightweight Python library for creating games, tools, and interactive applications using a retained-mode UI and scene system built on top of pygame. It focuses on rapid prototyping, composable rendering, and simple but powerful layout primitives.
4
4
 
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "PlayPy"
7
- version = "0.3.0"
7
+ version = "0.3.1"
8
8
  description = "PlayPy is a lightweight Python library for creating simple games and interactive applications with ease. It provides a straightforward API for handling graphics, input, and basic game mechanics, making it ideal for beginners and those looking to quickly prototype their ideas."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.14"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: PlayPy
3
- Version: 0.3.0
3
+ Version: 0.3.1
4
4
  Summary: PlayPy is a lightweight Python library for creating simple games and interactive applications with ease. It provides a straightforward API for handling graphics, input, and basic game mechanics, making it ideal for beginners and those looking to quickly prototype their ideas.
5
5
  Author-email: angel <angyv2861@gmail.com>
6
6
  Requires-Python: >=3.14
@@ -10,7 +10,7 @@ Requires-Dist: pygame-ce>=2.5.6
10
10
  Requires-Dist: colorama>=0.4.6
11
11
  Dynamic: license-file
12
12
 
13
- # PlayPy (0.3.0)
13
+ # PlayPy (0.3.1)
14
14
 
15
15
  PlayPy is a lightweight Python library for creating games, tools, and interactive applications using a retained-mode UI and scene system built on top of pygame. It focuses on rapid prototyping, composable rendering, and simple but powerful layout primitives.
16
16
 
@@ -1,5 +1,5 @@
1
1
  r'''
2
- # PlayPy (0.3.0)
2
+ # PlayPy (0.3.1)
3
3
 
4
4
  PlayPy is a lightweight Python library for creating games, tools, and interactive applications using a retained-mode UI and scene system built on top of pygame. It focuses on rapid prototyping, composable rendering, and simple but powerful layout primitives.
5
5
 
@@ -74,9 +74,9 @@ class Scrollable(Camera):
74
74
  self.scroll_speed = scroll_speed
75
75
 
76
76
  def scroll_x(self, amt: int, min_scroll: int, max_scroll: int):
77
- self.x += amt * self.scroll_speed
77
+ self.x -= amt * self.scroll_speed
78
78
  self.x = max(min_scroll, min(max_scroll, self.x))
79
79
 
80
80
  def scroll_y(self, amt: int, min_scroll: int, max_scroll: int):
81
- self.y += amt * self.scroll_speed
81
+ self.y -= amt * self.scroll_speed
82
82
  self.y = max(min_scroll, min(max_scroll, self.y))
@@ -16,7 +16,7 @@ import colorama as clr
16
16
 
17
17
  clr.init()
18
18
 
19
- __version__ = "0.3.0"
19
+ __version__ = "0.3.1"
20
20
 
21
21
  DATA_DIR = Path(__file__).resolve().parent / "data"
22
22
  DEFAULT_ICON_PATH = DATA_DIR / "default_icon.ppm"
@@ -190,38 +190,42 @@ class Workspace:
190
190
  def get_element_rect(self, element: Element) -> pg.Rect:
191
191
  parent = element.parent
192
192
  if isinstance(parent, Element):
193
- base_rect = self.get_element_rect(parent)
194
- camera = parent.get_component(Camera)
195
- if camera is not None:
196
- base_rect.x -= int(camera.x)
197
- base_rect.y -= int(camera.y)
198
-
199
- scrollable = parent.get_component(Scrollable)
200
- if scrollable is not None:
201
- base_rect.x -= int(scrollable.x)
202
- base_rect.y -= int(scrollable.y)
193
+ parent_rect = self.get_element_rect(parent)
194
+ layout_rect = parent_rect.copy()
195
+
196
+ if not element.ignores_environment:
197
+ camera = parent.get_component(Camera)
198
+ if camera is not None:
199
+ layout_rect.x -= int(camera.x)
200
+ layout_rect.y -= int(camera.y)
201
+
202
+ scrollable = parent.get_component(Scrollable)
203
+ if scrollable is not None:
204
+ layout_rect.x -= int(scrollable.x)
205
+ layout_rect.y -= int(scrollable.y)
203
206
  else:
204
- base_rect = pg.Rect((0, 0), self.size)
207
+ parent_rect = pg.Rect((0, 0), self.size)
208
+ layout_rect = parent_rect.copy()
205
209
 
206
210
  padding = element.parent.get_component(Padding) if isinstance(element.parent, Element) and not element.ignores_environment else None
207
211
 
208
- rect_x = round(element.scale.x * base_rect.w) + element.offset.x + base_rect.x
209
- rect_y = round(element.scale.y * base_rect.h) + element.offset.y + base_rect.y
210
- rect_w = round(element.scale.w * base_rect.w) + element.offset.w
211
- rect_h = round(element.scale.h * base_rect.h) + element.offset.h
212
+ rect_x = round(element.scale.x * layout_rect.w) + element.offset.x + layout_rect.x
213
+ rect_y = round(element.scale.y * layout_rect.h) + element.offset.y + layout_rect.y
214
+ rect_w = round(element.scale.w * layout_rect.w) + element.offset.w
215
+ rect_h = round(element.scale.h * layout_rect.h) + element.offset.h
212
216
 
213
217
  rect = pg.Rect(rect_x, rect_y, rect_w, rect_h)
214
218
 
215
219
  if padding:
216
- pad_x = round(padding.scale * base_rect.w) + padding.offset
217
- pad_y = round(padding.scale * base_rect.h) + padding.offset
220
+ pad_x = round(padding.scale * parent_rect.w) + padding.offset
221
+ pad_y = round(padding.scale * parent_rect.h) + padding.offset
218
222
 
219
- inner_rect = base_rect.inflate(-pad_x * 2, -pad_y * 2)
223
+ inner_rect = parent_rect.inflate(-pad_x * 2, -pad_y * 2)
220
224
 
221
225
  # Left side
222
226
  dist = None
223
- if rect.x < base_rect.x:
224
- dist = inner_rect.x - base_rect.x
227
+ if rect.x < parent_rect.x:
228
+ dist = inner_rect.x - parent_rect.x
225
229
  elif rect.x < inner_rect.x:
226
230
  dist = inner_rect.x - rect.x
227
231
  if dist:
@@ -229,15 +233,15 @@ class Workspace:
229
233
  rect.w -= dist
230
234
 
231
235
  # Right side
232
- if rect.right > base_rect.right:
233
- rect.w += inner_rect.right - base_rect.right
236
+ if rect.right > parent_rect.right:
237
+ rect.w += inner_rect.right - parent_rect.right
234
238
  elif rect.right > inner_rect.right:
235
239
  rect.w = inner_rect.right - rect.x
236
240
 
237
241
  # Top side
238
242
  dist = None
239
- if rect.y < base_rect.y:
240
- dist = inner_rect.y - base_rect.y
243
+ if rect.y < parent_rect.y:
244
+ dist = inner_rect.y - parent_rect.y
241
245
  elif rect.y < inner_rect.y:
242
246
  dist = inner_rect.y - rect.y
243
247
  if dist:
@@ -245,8 +249,8 @@ class Workspace:
245
249
  rect.h -= dist
246
250
 
247
251
  # Bottom side
248
- if rect.bottom > base_rect.bottom:
249
- rect.h += inner_rect.bottom - base_rect.bottom
252
+ if rect.bottom > parent_rect.bottom:
253
+ rect.h += inner_rect.bottom - parent_rect.bottom
250
254
  elif rect.bottom > inner_rect.bottom:
251
255
  rect.h = inner_rect.bottom - rect.y
252
256
 
File without changes
File without changes
File without changes