ascii-art-python 2.1.0__tar.gz → 2.1.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.
Files changed (22) hide show
  1. {ascii_art_python-2.1.0/src/ascii_art_python.egg-info → ascii_art_python-2.1.1}/PKG-INFO +1 -1
  2. {ascii_art_python-2.1.0 → ascii_art_python-2.1.1}/pyproject.toml +1 -1
  3. {ascii_art_python-2.1.0 → ascii_art_python-2.1.1}/src/ascii_art_python/__init__.py +1 -1
  4. {ascii_art_python-2.1.0 → ascii_art_python-2.1.1}/src/ascii_art_python/ascii_base.py +16 -8
  5. {ascii_art_python-2.1.0 → ascii_art_python-2.1.1/src/ascii_art_python.egg-info}/PKG-INFO +1 -1
  6. {ascii_art_python-2.1.0 → ascii_art_python-2.1.1}/LICENSE +0 -0
  7. {ascii_art_python-2.1.0 → ascii_art_python-2.1.1}/MANIFEST.in +0 -0
  8. {ascii_art_python-2.1.0 → ascii_art_python-2.1.1}/README.md +0 -0
  9. {ascii_art_python-2.1.0 → ascii_art_python-2.1.1}/setup.cfg +0 -0
  10. {ascii_art_python-2.1.0 → ascii_art_python-2.1.1}/src/ascii_art_python/assets/fonts/GoogleSansCode-Regular.ttf +0 -0
  11. {ascii_art_python-2.1.0 → ascii_art_python-2.1.1}/src/ascii_art_python/assets/fonts/KreativeSquareSM.ttf +0 -0
  12. {ascii_art_python-2.1.0 → ascii_art_python-2.1.1}/src/ascii_art_python/cli.py +0 -0
  13. {ascii_art_python-2.1.0 → ascii_art_python-2.1.1}/src/ascii_art_python/full_mode.py +0 -0
  14. {ascii_art_python-2.1.0 → ascii_art_python-2.1.1}/src/ascii_art_python/new_skool.py +0 -0
  15. {ascii_art_python-2.1.0 → ascii_art_python-2.1.1}/src/ascii_art_python/old_skool.py +0 -0
  16. {ascii_art_python-2.1.0 → ascii_art_python-2.1.1}/src/ascii_art_python/tools.py +0 -0
  17. {ascii_art_python-2.1.0 → ascii_art_python-2.1.1}/src/ascii_art_python.egg-info/SOURCES.txt +0 -0
  18. {ascii_art_python-2.1.0 → ascii_art_python-2.1.1}/src/ascii_art_python.egg-info/dependency_links.txt +0 -0
  19. {ascii_art_python-2.1.0 → ascii_art_python-2.1.1}/src/ascii_art_python.egg-info/entry_points.txt +0 -0
  20. {ascii_art_python-2.1.0 → ascii_art_python-2.1.1}/src/ascii_art_python.egg-info/requires.txt +0 -0
  21. {ascii_art_python-2.1.0 → ascii_art_python-2.1.1}/src/ascii_art_python.egg-info/top_level.txt +0 -0
  22. {ascii_art_python-2.1.0 → ascii_art_python-2.1.1}/tests/test_ascii_api.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ascii_art_python
3
- Version: 2.1.0
3
+ Version: 2.1.1
4
4
  Summary: A Python library and CLI tool for converting images and videos into ASCII art.
5
5
  Author-email: Guillem Prieur <prieurguillem38@gmail.com>
6
6
  Project-URL: Homepage, https://gitlab.pprriieeuurr.fr/guill_prieur/ascii-art-python-2
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "ascii_art_python"
7
- version = "2.1.0"
7
+ version = "2.1.1"
8
8
  authors = [
9
9
  { name="Guillem Prieur", email="prieurguillem38@gmail.com" },
10
10
  ]
@@ -1,7 +1,7 @@
1
1
  """
2
2
  Module from https://gitlab.pprriieeuurr.fr/guill_prieur/ascii-art-python-2
3
3
  """
4
- __version__ = "2.1.0"
4
+ __version__ = "2.1.1"
5
5
  from . import new_skool
6
6
  from . import old_skool
7
7
  from . import full_mode
@@ -10,7 +10,7 @@ import pathlib
10
10
  import sys
11
11
  import time
12
12
  from abc import ABC, abstractmethod
13
- from typing import Any, Callable, List, Optional, Tuple
13
+ from typing import Any, Callable, List, Optional
14
14
 
15
15
  import cv2
16
16
  import numpy as np
@@ -560,7 +560,7 @@ class Video:
560
560
  if hasattr(self, "_cap") and self._cap is not None:
561
561
  self._cap.release()
562
562
 
563
- def export(self, filename: str = "mika_export", sound: bool = False, font_size: int = 12):
563
+ def export(self, filename: str = "mika_export", sound: bool = False, font_size: int = 12) -> None:
564
564
  """
565
565
  Exports the processed ASCII video to an mp4 file.
566
566
 
@@ -593,7 +593,6 @@ class Video:
593
593
  out_width += 1
594
594
  if out_height % 2 != 0:
595
595
  out_height += 1
596
-
597
596
  fourcc = cv2.VideoWriter_fourcc(*"mp4v")
598
597
  out = cv2.VideoWriter(
599
598
  filename + ".mp4",
@@ -636,11 +635,20 @@ class Video:
636
635
  if not callable(func_print):
637
636
  raise TypeError("func_print must be a callable")
638
637
 
639
- time_between = 1 / min(self.fps, self.max_fps)
640
- next_sleep = time.time() + time_between
638
+ actual_frame_skip = max(1, int(self.fps / self.max_fps))
639
+ effective_fps = self.fps / actual_frame_skip
640
+
641
+ frame_duration = 1.0 / effective_fps
641
642
 
642
643
  with self:
643
- for frame in self:
644
- time.sleep(max(next_sleep - time.time(), 0))
644
+ start_time = time.perf_counter()
645
+
646
+ for i, frame in enumerate(self):
647
+ expected_time = start_time + (i * frame_duration)
648
+
649
+ sleep_time = expected_time - time.perf_counter()
650
+
651
+ if sleep_time > 0:
652
+ time.sleep(sleep_time)
653
+
645
654
  func_print(frame.get_alternate_lines())
646
- next_sleep += time_between
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ascii_art_python
3
- Version: 2.1.0
3
+ Version: 2.1.1
4
4
  Summary: A Python library and CLI tool for converting images and videos into ASCII art.
5
5
  Author-email: Guillem Prieur <prieurguillem38@gmail.com>
6
6
  Project-URL: Homepage, https://gitlab.pprriieeuurr.fr/guill_prieur/ascii-art-python-2