mini-arcade-native-backend 0.5.3__tar.gz → 0.6.0__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 (20) hide show
  1. {mini_arcade_native_backend-0.5.3 → mini_arcade_native_backend-0.6.0}/CHANGELOG.md +8 -0
  2. {mini_arcade_native_backend-0.5.3 → mini_arcade_native_backend-0.6.0}/PKG-INFO +2 -2
  3. {mini_arcade_native_backend-0.5.3 → mini_arcade_native_backend-0.6.0}/cpp/bindings.cpp +6 -1
  4. {mini_arcade_native_backend-0.5.3 → mini_arcade_native_backend-0.6.0}/cpp/engine.cpp +26 -0
  5. {mini_arcade_native_backend-0.5.3 → mini_arcade_native_backend-0.6.0}/cpp/engine.h +3 -0
  6. {mini_arcade_native_backend-0.5.3 → mini_arcade_native_backend-0.6.0}/poetry.lock +4 -4
  7. {mini_arcade_native_backend-0.5.3 → mini_arcade_native_backend-0.6.0}/pyproject.toml +2 -2
  8. {mini_arcade_native_backend-0.5.3 → mini_arcade_native_backend-0.6.0}/src/mini_arcade_native_backend/__init__.py +34 -4
  9. {mini_arcade_native_backend-0.5.3 → mini_arcade_native_backend-0.6.0}/.github/workflows/ci.yml +0 -0
  10. {mini_arcade_native_backend-0.5.3 → mini_arcade_native_backend-0.6.0}/.github/workflows/create-release-branch.yml +0 -0
  11. {mini_arcade_native_backend-0.5.3 → mini_arcade_native_backend-0.6.0}/.github/workflows/release-finalize.yml +0 -0
  12. {mini_arcade_native_backend-0.5.3 → mini_arcade_native_backend-0.6.0}/.github/workflows/release-publish.yml +0 -0
  13. {mini_arcade_native_backend-0.5.3 → mini_arcade_native_backend-0.6.0}/.gitignore +0 -0
  14. {mini_arcade_native_backend-0.5.3 → mini_arcade_native_backend-0.6.0}/.vscode/settings.json +0 -0
  15. {mini_arcade_native_backend-0.5.3 → mini_arcade_native_backend-0.6.0}/CMakeLists.txt +0 -0
  16. {mini_arcade_native_backend-0.5.3 → mini_arcade_native_backend-0.6.0}/LICENSE +0 -0
  17. {mini_arcade_native_backend-0.5.3 → mini_arcade_native_backend-0.6.0}/README.md +0 -0
  18. {mini_arcade_native_backend-0.5.3 → mini_arcade_native_backend-0.6.0}/examples/native_backend_demo.py +0 -0
  19. {mini_arcade_native_backend-0.5.3 → mini_arcade_native_backend-0.6.0}/poetry.toml +0 -0
  20. {mini_arcade_native_backend-0.5.3 → mini_arcade_native_backend-0.6.0}/tests/test_init.py +0 -0
@@ -6,6 +6,14 @@ This project adheres to [Semantic Versioning](https://semver.org/).
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [0.6.0] - 2026-01-23
10
+
11
+ ### Added
12
+ - add draw_line method to Engine and bind it in Python
13
+
14
+ ### Other
15
+ - Merge release/0.5 into develop
16
+
9
17
  ## [0.5.3] - 2026-01-23
10
18
 
11
19
  - Internal changes only.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: mini-arcade-native-backend
3
- Version: 0.5.3
3
+ Version: 0.6.0
4
4
  Summary: Native SDL2 backend for mini-arcade-core using SDL2 + pybind11.
5
5
  Author-Email: Santiago Rincon <rincores@gmail.com>
6
6
  License: Copyright (c) 2025 Santiago Rincón
@@ -24,7 +24,7 @@ License: Copyright (c) 2025 Santiago Rincón
24
24
  SOFTWARE.
25
25
 
26
26
  Requires-Python: <3.12,>=3.9
27
- Requires-Dist: mini-arcade-core~=1.0
27
+ Requires-Dist: mini-arcade-core~=1.1
28
28
  Provides-Extra: dev
29
29
  Requires-Dist: pytest~=8.3; extra == "dev"
30
30
  Requires-Dist: pytest-cov~=6.0; extra == "dev"
@@ -122,5 +122,10 @@ PYBIND11_MODULE(_native, m) {
122
122
  py::arg("y"),
123
123
  py::arg("w"),
124
124
  py::arg("h"))
125
- .def("clear_clip_rect", &mini::Engine::clear_clip_rect);
125
+ .def("clear_clip_rect", &mini::Engine::clear_clip_rect)
126
+ .def("draw_line", &mini::Engine::draw_line,
127
+ py::arg("x1"), py::arg("y1"),
128
+ py::arg("x2"), py::arg("y2"),
129
+ py::arg("r"), py::arg("g"), py::arg("b"), py::arg("a"));
130
+
126
131
  }
@@ -567,4 +567,30 @@ namespace mini {
567
567
  SDL_RenderSetClipRect(renderer_, nullptr);
568
568
  }
569
569
 
570
+ void Engine::draw_line(int x1, int y1, int x2, int y2, int r, int g, int b, int a)
571
+ {
572
+ if (!initialized_ || renderer_ == nullptr) {
573
+ return;
574
+ }
575
+
576
+ auto clamp = [](int v) {
577
+ if (v < 0) return 0;
578
+ if (v > 255) return 255;
579
+ return v;
580
+ };
581
+
582
+ // alpha or default alpha
583
+ a = (a < 0) ? default_alpha_ : a;
584
+
585
+ SDL_SetRenderDrawColor(
586
+ renderer_,
587
+ static_cast<Uint8>(clamp(r)),
588
+ static_cast<Uint8>(clamp(g)),
589
+ static_cast<Uint8>(clamp(b)),
590
+ static_cast<Uint8>(clamp(a))
591
+ );
592
+
593
+ SDL_RenderDrawLine(renderer_, x1, y1, x2, y2);
594
+ }
595
+
570
596
  } // namespace mini
@@ -123,6 +123,9 @@ namespace mini {
123
123
  // Clear clipping rectangle (disable clipping).
124
124
  void clear_clip_rect();
125
125
 
126
+ // Draw a line from (x1, y1) to (x2, y2) with specified color.
127
+ void draw_line(int x1, int y1, int x2, int y2, int r, int g, int b, int a);
128
+
126
129
  private:
127
130
  SDL_Window* window_; // The main application window.
128
131
  SDL_Renderer* renderer_; // The renderer for drawing.
@@ -516,14 +516,14 @@ files = [
516
516
 
517
517
  [[package]]
518
518
  name = "mini-arcade-core"
519
- version = "1.0.0"
519
+ version = "1.1.1"
520
520
  description = "Tiny scene-based game loop core for small arcade games."
521
521
  optional = false
522
522
  python-versions = "<3.12,>=3.9"
523
523
  groups = ["main"]
524
524
  files = [
525
- {file = "mini_arcade_core-1.0.0-py3-none-any.whl", hash = "sha256:16ec8b11e6c6c7c6fc414d872d03934f2f7df01b5ffaf8515af98ab081507b07"},
526
- {file = "mini_arcade_core-1.0.0.tar.gz", hash = "sha256:3565073c6f3896a9a23b347745d33ddb374b2cb19b6a4001c31a31f66690923e"},
525
+ {file = "mini_arcade_core-1.1.1-py3-none-any.whl", hash = "sha256:cd487278b33ba77e80acfdc895a77a76cc1d07f5c800a26b7537e18aaa97f00e"},
526
+ {file = "mini_arcade_core-1.1.1.tar.gz", hash = "sha256:b3b81a3adefaaf2b5438bc773ed364a5cf997e7f00a67ef3fc8be9d40bdbc61f"},
527
527
  ]
528
528
 
529
529
  [package.dependencies]
@@ -1001,4 +1001,4 @@ dev = ["black", "isort", "mypy", "pylint", "pytest", "pytest-cov"]
1001
1001
  [metadata]
1002
1002
  lock-version = "2.1"
1003
1003
  python-versions = ">=3.9,<3.12"
1004
- content-hash = "36a9b75ca1c71a10eb85ee901a0df5f279b1433575e1f797b11d5c7efb875e7b"
1004
+ content-hash = "049cf6813d766ae9a7c9ab36a2ef36d24fce8da7a19ffa70200461aef112012d"
@@ -8,7 +8,7 @@ build-backend = "scikit_build_core.build"
8
8
 
9
9
  [project]
10
10
  name = "mini-arcade-native-backend"
11
- version = "0.5.3"
11
+ version = "0.6.0"
12
12
  description = "Native SDL2 backend for mini-arcade-core using SDL2 + pybind11."
13
13
  authors = [
14
14
  { name = "Santiago Rincon", email = "rincores@gmail.com" },
@@ -17,7 +17,7 @@ readme = "README.md"
17
17
  requires-python = ">=3.9,<3.12"
18
18
  license = { file = "LICENSE" }
19
19
  dependencies = [
20
- "mini-arcade-core~=1.0",
20
+ "mini-arcade-core~=1.1",
21
21
  ]
22
22
 
23
23
  [project.optional-dependencies]
@@ -299,12 +299,18 @@ class NativeBackend(Backend):
299
299
  if isinstance(alpha, bool):
300
300
  raise TypeError("alpha must be a float in [0,1], not bool")
301
301
 
302
- a = float(alpha)
302
+ # If it's an int-like value, treat as 0..255
303
+ if isinstance(alpha, int):
304
+ if alpha < 0 or alpha > 255:
305
+ raise ValueError(
306
+ f"int alpha must be in [0, 255], got {alpha!r}"
307
+ )
308
+ return int(alpha)
303
309
 
304
- # Enforce “percentage only”
310
+ # Otherwise treat as float 0..1
311
+ a = float(alpha)
305
312
  if a < 0.0 or a > 1.0:
306
- raise ValueError(f"alpha must be in [0, 1], got {alpha!r}")
307
-
313
+ raise ValueError(f"float alpha must be in [0, 1], got {alpha!r}")
308
314
  return int(round(a * 255))
309
315
 
310
316
  @staticmethod
@@ -502,3 +508,27 @@ class NativeBackend(Backend):
502
508
 
503
509
  def clear_clip_rect(self) -> None:
504
510
  self._engine.clear_clip_rect()
511
+
512
+ # Justification: Many arguments needed for line drawing
513
+ # pylint: disable=too-many-arguments,too-many-positional-arguments
514
+ def draw_line(
515
+ self,
516
+ x1: int,
517
+ y1: int,
518
+ x2: int,
519
+ y2: int,
520
+ color: tuple[int, ...] = (255, 255, 255),
521
+ ) -> None:
522
+ r, g, b, a = self._get_color_values(color)
523
+
524
+ sx1 = int(round(self._vp_offset_x + x1 * self._vp_scale))
525
+ sy1 = int(round(self._vp_offset_y + y1 * self._vp_scale))
526
+ sx2 = int(round(self._vp_offset_x + x2 * self._vp_scale))
527
+ sy2 = int(round(self._vp_offset_y + y2 * self._vp_scale))
528
+
529
+ self._engine.draw_line(
530
+ sx1, sy1, sx2, sy2, int(r), int(g), int(b), int(a)
531
+ )
532
+
533
+
534
+ # pylint: enable=too-many-arguments,too-many-positional-arguments