Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Common image class interface #34

Merged
merged 21 commits into from
May 4, 2022
Merged

Common image class interface #34

merged 21 commits into from
May 4, 2022

Conversation

AnonymouX47
Copy link
Owner

@AnonymouX47 AnonymouX47 commented Apr 28, 2022

Resolves #30 in preparation for #23.

  • Defines an interface to be shared across all image classes.
  • Adds BaseImage, the baseclass of all image classes.
  • Makes TermImage a subclass of BaseImage.
  • Adds is_supported() class method for render style support detection.
  • Instantiation via the class constructor now initializes the seek position of animated images to the current seek position of the given PIL image.
  • Extends the draw() method to allow for render-style-specific parameters.
  • Slightly extends the directory and package structure, though not breaking anything.
  • Restructures the test suite to fit the new API.

- Add: Added `.image` subpackage.
- Change: Moved `.image` module to `.image.common`.
- Add: Added submodule `.image.term`.
- Add: Redefined `TermImage` in `.image.term` as a subclass of `BaseImage`.
- Change: Renamed `TermImage` to `BaseImage` in `.image.common`.
- Change: Updated docs config.
@AnonymouX47 AnonymouX47 added documentation Improvements or additions to documentation enhancement New feature / Improvement suggestion or request lib Related to the library (Not to be used anymore) labels Apr 28, 2022
@AnonymouX47 AnonymouX47 added this to the 0.4.0 milestone Apr 28, 2022
- Change: Turned `BaseImage` into an abstract baseclass.
- Change: Turned common render-style-dependent methods into abstract methods in `BaseImage`.
- Change: Moved the implementation of some render-style-dependent methods into `TermImage`.
- Add: Added `BaseImage._get_render_data()`.
- Change: Extracted the render-style-independent parts of `BaseImage._render_image()` into `BaseImage._get_render_data()`.
- Change: Changed all typehint and docstring references to `PIL.Image.Image` to the fully-qualified name.
- Change: Renamed references to PIL image instances from `image` -> `img`.
- Change: Moved render-style-dependent `_render_image()` from `BaseImage` into `TermInage`.
- Change: Moved constants `_LOWER_PIXEL` and `_UPPER_PIXEL` from `.image.common` to `.image.term`.
- Add: Added `.image.common._close_validated()` method decorator for detection of finalized instances.
- Add: Added `BaseImage._get_image()`.
- Change: Cleaned up `n_frames` and `_renderer()` in `BaseImage`.
- Add: Added `BaseImage._pixel_ratio` property.
- Change: "font ratio" now applies to only text-based render styles.
- Change: `.set_font_ratio()` no longer sets the pixel ratio.
- Change: Modified `BaseImage._valid_size()` to use class-specific pixel ratio.
- Change: Updated docstrings.
- Add: Added `BaseImage._supported`.
- Add: Added `BaseImage.is_supported()` abstract method.
- Add: Added `TermImage.is_supported()`.
- Add: Added a test for `.is_supported()`.
- Change: Updated docstrings.
- Change: Modified `.image.common._close_validated()` to prevent re-decoration of methods.
  - If the given method is already close-validated, it is returned as is.
- Add: Added `.image.utils` submodule.
- Change: Moved `_FG_FMT`, `_BG_FMT`, `_RESET` and `_color()` from `.image.common` into `.image.utils`.
- Add: Added the *size* parameter for alternative sizing.
- Change: Updated docstring.
- Add: Added tests/__init__.py to allow relative imports.
- Add: Added tests/test_term.py.
- Change: Moved tests/test_image.py -> tests/common.py.
- Change: The test module for each render style can now import from `tests.common` and run the tests successfully for its render style.
- Change: Image seek position is now initialized to the current seek position of the given PIL image.
- Change: Updated the corresponding tests.
- Add: Added provision for variable-length lenght keyword arguments.
  - Intended to be used in subclasses for for style-specific parameters.
- Change Updated image format specification documentation.
- Change: Updated library docstrings and comments.
- Add: Added `pytest-order` as a devolopment requirement.
- Change: Marked `test.test_term.test_setup_common` to always run first.
@AnonymouX47 AnonymouX47 merged commit f144beb into main May 4, 2022
@AnonymouX47 AnonymouX47 deleted the common-interface branch May 4, 2022 12:15
AnonymouX47 added a commit that referenced this pull request May 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature / Improvement suggestion or request lib Related to the library (Not to be used anymore)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Common Interface for all render styles
1 participant