diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml index 21c67c8..3a92ef3 100644 --- a/.github/workflows/gh-pages.yml +++ b/.github/workflows/gh-pages.yml @@ -9,7 +9,7 @@ on: paths: - .github/workflows/gh-pages.yml - docs/** - - GameBEye/** + - gamebeye/** - examples/** jobs: diff --git a/README.md b/README.md index 127b2ed..2f66e29 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,10 @@ -# GameBEye +# gamebeye -> GameBEye is a **Python Library** to process [Game Boy Camera](https://en.wikipedia.org/wiki/Game_Boy_Camera) images. +> gamebeye is a **Python Library** to process [Game Boy Camera](https://en.wikipedia.org/wiki/Game_Boy_Camera) images. -- **Source code** 📁: [https://github.com/mtouzot/GameBEye](https://github.com/mtouzot/GameBEye) -- **Issues** 🆘: [https://github.com/mtouzot/GameBEye/issues](https://github.com/mtouzot/GameBEye/issues) +- **Source code** 📁: [https://github.com/mtouzot/gamebeye](https://github.com/mtouzot/gamebeye) +- **Issues** 🆘: [https://github.com/mtouzot/gamebeye/issues](https://github.com/mtouzot/gamebeye/issues) ## 📜 Description diff --git a/docs/GameBEye.rst b/docs/GameBEye.rst index bf2cc86..1cff729 100644 --- a/docs/GameBEye.rst +++ b/docs/GameBEye.rst @@ -1,7 +1,7 @@ -GameBEye documentation +gamebeye documentation ====================== -.. automodule:: GameBEye +.. automodule:: gamebeye :members: :undoc-members: :show-inheritance: @@ -9,6 +9,6 @@ GameBEye documentation .. toctree:: :maxdepth: 4 - ./GameBEye/image.rst - ./GameBEye/colors.rst - ./GameBEye/filters.rst + ./gamebeye/image.rst + ./gamebeye/colors.rst + ./gamebeye/filters.rst diff --git a/docs/GameBEye/colors.rst b/docs/GameBEye/colors.rst index bdadae1..7bae554 100644 --- a/docs/GameBEye/colors.rst +++ b/docs/GameBEye/colors.rst @@ -1,7 +1,7 @@ Colors module ============= -The **GameBEye.gbcamcolors** module is as its name indicates focused on colors and color space conversion. It deals with a selection of color palettes (picked and adapted from `HerrZatacke `_ `gb-printer-web `_). +The **gamebeye.gbcamcolors** module is as its name indicates focused on colors and color space conversion. It deals with a selection of color palettes (picked and adapted from `HerrZatacke `_ `gb-printer-web `_). Thoses colors allowed me to make this small animation : @@ -14,24 +14,24 @@ Thoses colors allowed me to make this small animation :

Animated GIF made of colorized images

-:mod:`GameBEye.gbcamcolors` module +:mod:`gamebeye.gbcamcolors` module ---------------------------------- This module also uses methods from :ref:`ch module` -.. automodule:: GameBEye.gbcamcolors +.. automodule:: gamebeye.gbcamcolors - .. autoclass:: GameBEye.gbcamcolors.GBColorPalettes + .. autoclass:: gamebeye.gbcamcolors.GBColorPalettes :members: :undoc-members: :show-inheritance: .. _ch module: -:mod:`GameBEye.color\_helpers` module +:mod:`gamebeye.color\_helpers` module ------------------------------------- -.. automodule:: GameBEye.color_helpers +.. automodule:: gamebeye.color_helpers :members: :undoc-members: :show-inheritance: diff --git a/docs/GameBEye/filters.rst b/docs/GameBEye/filters.rst index a52dde8..7c39a60 100644 --- a/docs/GameBEye/filters.rst +++ b/docs/GameBEye/filters.rst @@ -1,12 +1,12 @@ Filters module =================== -The **GameBEye.gbcamfilters** module is as its name indicates focused on filters. It is used to *play* with :mod:`GameBEye.gbcamimage.GBCamImage` +The **gamebeye.gbcamfilters** module is as its name indicates focused on filters. It is used to *play* with :mod:`gamebeye.gbcamimage.GBCamImage` -:mod:`GameBEye.gbcamfilters` module +:mod:`gamebeye.gbcamfilters` module ------------------------------------------------ -.. automodule:: GameBEye.gbcamfilters +.. automodule:: gamebeye.gbcamfilters :members: :undoc-members: :show-inheritance: diff --git a/docs/GameBEye/image.rst b/docs/GameBEye/image.rst index af88ba7..09f30cb 100644 --- a/docs/GameBEye/image.rst +++ b/docs/GameBEye/image.rst @@ -1,11 +1,11 @@ Image module ============ -The **GameBEye.gbcamimage** module is as its name indicates focused on Game Boy Camera image. +The **gamebeye.gbcamimage** module is as its name indicates focused on Game Boy Camera image. Each borderless image has a *128x112* pixels resolution and uses a 4-color palette (grayscale values, natively). -.. automodule:: GameBEye.gbcamimage +.. automodule:: gamebeye.gbcamimage :members: :undoc-members: :show-inheritance: diff --git a/docs/conf.py b/docs/conf.py index 8d39137..3d4193e 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -10,15 +10,15 @@ # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. # +import importlib.metadata import os import sys -import importlib.metadata sys.path.insert(0, os.path.abspath("..")) # -- Project information ----------------------------------------------------- -project = "GameBEye" +project = "gamebeye" copyright = "2021 - 2025, Martin TOUZOT" author = "Martin TOUZOT" @@ -93,6 +93,7 @@ "icon/apple-touch-icon.png", ] + # Add custom CSS file def setup(app): app.add_css_file("css/custom.css") diff --git a/docs/examples.rst b/docs/examples.rst index f0af099..f8ec258 100644 --- a/docs/examples.rst +++ b/docs/examples.rst @@ -1,7 +1,7 @@ Examples ======== -You can find more usages of **GameBEye** library in the `examples `_ folder. +You can find more usages of **gamebeye** library in the `examples `_ folder. Among others, you'll be able to create an animated GIF made of color Game Boy Camera images. diff --git a/docs/examples/colorizing_image.rst b/docs/examples/colorizing_image.rst index 8ccf018..6179f2b 100644 --- a/docs/examples/colorizing_image.rst +++ b/docs/examples/colorizing_image.rst @@ -21,8 +21,8 @@ You'll see in this example the result of updating the color palette of an origin """An example to change image color palette from BW to AZC.""" - from GameBEye.gbcamimage import GBCamImage - from GameBEye.gbcamcolors import GBColorPalettes + from gamebeye.gbcamimage import GBCamImage + from gamebeye.gbcamcolors import GBColorPalettes import cv2 # Path to the image diff --git a/docs/examples/display_images.rst b/docs/examples/display_images.rst index 5977470..01e5adb 100644 --- a/docs/examples/display_images.rst +++ b/docs/examples/display_images.rst @@ -6,8 +6,8 @@ Display image and its color palette in a second window """An example to display both image and its corresponding color palette.""" - from GameBEye.gbcamimage import GBCamImage - from GameBEye.color_helpers import hex_to_rgb + from gamebeye.gbcamimage import GBCamImage + from gamebeye.color_helpers import hex_to_rgb import numpy as np import cv2 import os diff --git a/docs/examples/printing_image.rst b/docs/examples/printing_image.rst index 725240d..4d9f29b 100644 --- a/docs/examples/printing_image.rst +++ b/docs/examples/printing_image.rst @@ -9,8 +9,8 @@ here's an example of how looks a printed image """An example to use the thermal printer effect on an image.""" - from GameBEye.gbcamimage import GBCamImage - import GameBEye.gbcamfilters as gbcamfilters + from gamebeye.gbcamimage import GBCamImage + import gamebeye.gbcamfilters as gbcamfilters import cv2 # Path to the image diff --git a/docs/index.rst b/docs/index.rst index 2eab223..20cca95 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -1,9 +1,9 @@ -Welcome to GameBEye's documentation! +Welcome to gamebeye's documentation! ==================================== |Github| |License| |Issues| |Release| -GameBEye is a **Python library** to process `Game Boy Camera `_ images. +gamebeye is a **Python library** to process `Game Boy Camera `_ images. Here are what a Game Boy camera can capture: @@ -50,7 +50,7 @@ Here are some infos about the hardware and the Gam Boy Camera images that drive ./hardware.rst ./installation.rst - ./GameBEye.rst + ./gamebeye.rst ./examples.rst Indices and tables @@ -60,17 +60,17 @@ Indices and tables * :ref:`modindex` * :ref:`search` -.. |Github| image:: https://img.shields.io/github/stars/mtouzot/GameBEye?label=Github&logo=github - :target: https://github.com/mtouzot/GameBEye +.. |Github| image:: https://img.shields.io/github/stars/mtouzot/gamebeye?label=Github&logo=github + :target: https://github.com/mtouzot/gamebeye -.. |License| image:: https://img.shields.io/github/license/mtouzot/GameBEye - :target: https://github.com/mtouzot/GameBEye/blob/master/LICENSE +.. |License| image:: https://img.shields.io/github/license/mtouzot/gamebeye + :target: https://github.com/mtouzot/gamebeye/blob/master/LICENSE -.. |Issues| image:: https://img.shields.io/github/issues/mtouzot/GameBEye - :target: https://github.com/mtouzot/GameBEye/issues +.. |Issues| image:: https://img.shields.io/github/issues/mtouzot/gamebeye + :target: https://github.com/mtouzot/gamebeye/issues -.. |Release| image:: https://img.shields.io/github/v/release/mtouzot/GameBEye - :target: https://github.com/mtouzot/GameBEye/releases +.. |Release| image:: https://img.shields.io/github/v/release/mtouzot/gamebeye + :target: https://github.com/mtouzot/gamebeye/releases .. |BWpalette| image:: ./_static/colorPalettes/BW.png :class: align-center diff --git a/docs/installation.rst b/docs/installation.rst index 1805b7e..9f6d658 100644 --- a/docs/installation.rst +++ b/docs/installation.rst @@ -6,5 +6,5 @@ From sources The sources can be downloaded from the GitHub repository:: - git clone https://github.com/mtouzot/GameBEye.git - cd GameBEye + git clone https://github.com/mtouzot/gamebeye.git + cd gamebeye diff --git a/examples/01_reading_and_displaying_an_image.py b/examples/01_reading_and_displaying_an_image.py index d3a5052..f85f9ef 100644 --- a/examples/01_reading_and_displaying_an_image.py +++ b/examples/01_reading_and_displaying_an_image.py @@ -1,8 +1,9 @@ """An example to show an image, to log its name and color palette.""" -from GameBEye.gbcamimage import GBCamImage import cv2 +from gamebeye.gbcamimage import GBCamImage + # Path to the image image_filepath = "images\\originalImage.png" diff --git a/examples/02_changing_image_color.py b/examples/02_changing_image_color.py index 53db329..31ce2fc 100644 --- a/examples/02_changing_image_color.py +++ b/examples/02_changing_image_color.py @@ -1,9 +1,10 @@ """An example to change image color palette from BW to AZC.""" -from GameBEye.gbcamimage import GBCamImage -from GameBEye.gbcamcolors import GBColorPalettes import cv2 +from gamebeye.gbcamcolors import GBColorPalettes +from gamebeye.gbcamimage import GBCamImage + # Path to the image image_filepath = "images\\originalImage.png" img = cv2.imread(image_filepath) @@ -25,9 +26,7 @@ gb_img.change_color(color_palette=gb_color_palette) # Displaying the colorized image -color_title = "Colorized image with {} color palette".format( - gb_img.color_palette.name -) +color_title = "Colorized image with {} color palette".format(gb_img.color_palette.name) cv2.imshow(color_title, gb_img.data) print( "Colorized image color palette : {}\nRequired color palette : {}".format( diff --git a/examples/03_display_color_palette.py b/examples/03_display_color_palette.py index 5d84812..aae1222 100644 --- a/examples/03_display_color_palette.py +++ b/examples/03_display_color_palette.py @@ -1,17 +1,16 @@ """An example to display both image and its corresponding color palette.""" -from GameBEye.gbcamimage import GBCamImage -from GameBEye.color_helpers import hex_to_rgb -import numpy as np -import cv2 import os +import cv2 +import numpy as np + +from gamebeye.color_helpers import hex_to_rgb +from gamebeye.gbcamimage import GBCamImage + input_folder = os.path.join("images", "colorizedImages") images_filepath = sorted( - [ - os.path.join(input_folder, filename) - for filename in os.listdir(input_folder) - ] + [os.path.join(input_folder, filename) for filename in os.listdir(input_folder)] ) for image_filepath in images_filepath: @@ -38,9 +37,7 @@ color_palettes.append(cv2.merge([blue, green, red])) color_palettes = cv2.hconcat(color_palettes) - color_palette_title = "Color palettes {}".format( - gb_image.color_palette.name - ) + color_palette_title = "Color palettes {}".format(gb_image.color_palette.name) cv2.imshow(color_palette_title, color_palettes) cv2.waitKey() diff --git a/examples/04_print_image_paper.py b/examples/04_print_image_paper.py index d9a364d..3cb2bb8 100644 --- a/examples/04_print_image_paper.py +++ b/examples/04_print_image_paper.py @@ -1,9 +1,10 @@ """An example to use the thermal printer effect on an image.""" -from GameBEye.gbcamimage import GBCamImage -import GameBEye.gbcamfilters as gbcamfilters import cv2 +import gamebeye.gbcamfilters as gbcamfilters +from gamebeye.gbcamimage import GBCamImage + # Path to the image image_filepath = "images\\originalImage.png" img = cv2.imread(image_filepath) diff --git a/GameBEye/__init__.py b/gamebeye/__init__.py similarity index 74% rename from GameBEye/__init__.py rename to gamebeye/__init__.py index 5b32590..9248c0a 100644 --- a/GameBEye/__init__.py +++ b/gamebeye/__init__.py @@ -1,4 +1,5 @@ -"""Provide an object to manage Game Boy Camera images. +""" +Provide an object to manage Game Boy Camera images. Allow to read and apply various filters on images capture with Game Boy Camera. diff --git a/GameBEye/color_helpers.py b/gamebeye/color_helpers.py similarity index 84% rename from GameBEye/color_helpers.py rename to gamebeye/color_helpers.py index 3fdc93f..7c9080c 100644 --- a/GameBEye/color_helpers.py +++ b/gamebeye/color_helpers.py @@ -1,6 +1,7 @@ """Define color conversions and methods related to 8-bits colorspaces.""" import typing + import numpy as np RGB_val = typing.List[int] @@ -8,7 +9,8 @@ def clamp(val: int) -> int: - """Ensure that val is between 0 and 255. + """ + Ensure that val is between 0 and 255. Clamp each out of bound value. @@ -17,7 +19,7 @@ def clamp(val: int) -> int: :returns: the clamped value :rtype: int - >>> from GameBEye.gbcamcolors.color_helpers import clamp + >>> from gamebeye.gbcamcolors.color_helpers import clamp >>> clamp(-125) 0 >>> clamp(0) @@ -33,7 +35,8 @@ def clamp(val: int) -> int: def is_clamped(val: int) -> bool: - """Check if val is clamped between 0 and 255. + """ + Check if val is clamped between 0 and 255. If val is out of boundaries, returns False. True otherwise. @@ -42,7 +45,7 @@ def is_clamped(val: int) -> bool: :returns: the comparison result :rtype: bool - >>> from GameBEye.gbcamcolors.color_helpers import is_clamped + >>> from gamebeye.gbcamcolors.color_helpers import is_clamped >>> is_clamped(-125) False >>> is_clamped(0) @@ -59,7 +62,8 @@ def is_clamped(val: int) -> bool: def clamp_rgb(rgb_val: RGB_val) -> RGB_val: - """Ensure that all RGB values are between 0 and 255. + """ + Ensure that all RGB values are between 0 and 255. Clamp each out of bound value. @@ -70,7 +74,7 @@ def clamp_rgb(rgb_val: RGB_val) -> RGB_val: :returns: the clamped list :rtype: List[int] - >>> from GameBEye.gbcamcolors.color_helpers import clamp_rgb + >>> from gamebeye.gbcamcolors.color_helpers import clamp_rgb >>> clamp_rgb([0, 0, 0]) [0, 0, 0] >>> clamp_rgb([255, 255, 255]) @@ -90,7 +94,8 @@ def clamp_rgb(rgb_val: RGB_val) -> RGB_val: def is_clamped_rgb(rgb_val: RGB_val) -> bool: - """Check if the RGB color values are clamped between 0 and 255. + """ + Check if the RGB color values are clamped between 0 and 255. If val is out of boundaries, returns False. True otherwise. @@ -101,7 +106,7 @@ def is_clamped_rgb(rgb_val: RGB_val) -> bool: :returns: the comparison result :rtype: bool - >>> from GameBEye.gbcamcolors.color_helpers import is_clamped_rgb + >>> from gamebeye.gbcamcolors.color_helpers import is_clamped_rgb >>> is_clamped_rgb([0, 0, 0]) True >>> is_clamped_rgb([255, 255, 255]) @@ -121,7 +126,8 @@ def is_clamped_rgb(rgb_val: RGB_val) -> bool: def clamp_hex(hex_val: str) -> str: - """Ensure that val is between '0x000000' and '0xFFFFFF'. + """ + Ensure that val is between '0x000000' and '0xFFFFFF'. Clamp each out of bound value. @@ -130,7 +136,7 @@ def clamp_hex(hex_val: str) -> str: :returns: the hex clamped value :rtype: str - >>> from GameBEye.gbcamcolors.color_helpers import clamp_hex + >>> from gamebeye.gbcamcolors.color_helpers import clamp_hex >>> clamp_hex('#000000') '#000000' >>> clamp_hex('#FFFFFF') @@ -146,7 +152,8 @@ def clamp_hex(hex_val: str) -> str: def is_clamped_hex(hex_val: str) -> bool: - """Ensure that val is between '#000000' and '#FFFFFF'. + """ + Ensure that val is between '#000000' and '#FFFFFF'. If val is out of boundaries, returns False. True otherwise. @@ -155,7 +162,7 @@ def is_clamped_hex(hex_val: str) -> bool: :returns: the comparison result :rtype: bool - >>> from GameBEye.gbcamcolors.color_helpers import is_clamped_hex + >>> from gamebeye.gbcamcolors.color_helpers import is_clamped_hex >>> is_clamped_hex('#000000') True >>> is_clamped_hex('#FFFFFF') @@ -170,7 +177,8 @@ def is_clamped_hex(hex_val: str) -> bool: def hex_to_rgb(hex_val: str) -> RGB_val: - """Convert a hexadecimal value to RGB values. + """ + Convert a hexadecimal value to RGB values. All values are clamped between 0 and 255. @@ -182,7 +190,7 @@ def hex_to_rgb(hex_val: str) -> RGB_val: :returns: a list containing R, G, B values. :rtype: a list of integer - >>> from GameBEye.gbcamcolors.color_helpers import hex_to_rgb + >>> from gamebeye.gbcamcolors.color_helpers import hex_to_rgb >>> hex_to_rgb('#000000') [0, 0, 0] >>> hex_to_rgb('#FF0000') @@ -201,7 +209,8 @@ def hex_to_rgb(hex_val: str) -> RGB_val: def hex_to_bgr(hex_val: str) -> BGR_val: - """Convert a hexadecimal value to BGR values. + """ + Convert a hexadecimal value to BGR values. All values are clamped between 0 and 255. @@ -213,7 +222,7 @@ def hex_to_bgr(hex_val: str) -> BGR_val: :returns: a list containing B, G, R values :rtype: a list of integer - >>> from GameBEye.gbcamcolors.color_helpers import hex_to_bgr + >>> from gamebeye.gbcamcolors.color_helpers import hex_to_bgr >>> hex_to_bgr('#000000') [0, 0, 0] >>> hex_to_bgr('#FF0000') @@ -232,7 +241,8 @@ def hex_to_bgr(hex_val: str) -> BGR_val: def rgb_to_hex(rgb_val: RGB_val) -> str: - """Convert a (R, G, B) array to hexadecimal integer. + """ + Convert a (R, G, B) array to hexadecimal integer. All values are clamped between 0 and 255. @@ -243,7 +253,7 @@ def rgb_to_hex(rgb_val: RGB_val) -> str: :returns: an hexadecimal value :rtype: str - >>> from GameBEye.gbcamcolors.color_helpers import rgb_to_hex + >>> from gamebeye.gbcamcolors.color_helpers import rgb_to_hex >>> rgb_to_hex([0, 0, 0]) '#000000' >>> rgb_to_hex([0, 0, 255]) @@ -265,7 +275,8 @@ def rgb_to_hex(rgb_val: RGB_val) -> str: def bgr_to_hex(bgr_val: BGR_val) -> str: - """Convert a (B, G, R) array to hexadecimal integer. + """ + Convert a (B, G, R) array to hexadecimal integer. All values are clamped between 0 and 255. @@ -276,7 +287,7 @@ def bgr_to_hex(bgr_val: BGR_val) -> str: :returns: an hexadecimal value :rtype: str - >>> from GameBEye.gbcamcolors.color_helpers import bgr_to_hex + >>> from gamebeye.gbcamcolors.color_helpers import bgr_to_hex >>> bgr_to_hex([0, 0, 0]) '#000000' >>> bgr_to_hex([0, 0, 255]) diff --git a/GameBEye/filter_helpers.py b/gamebeye/filter_helpers.py similarity index 94% rename from GameBEye/filter_helpers.py rename to gamebeye/filter_helpers.py index d77609e..e0e05e3 100644 --- a/GameBEye/filter_helpers.py +++ b/gamebeye/filter_helpers.py @@ -18,7 +18,7 @@ def generate_vstripes(size: Size) -> np.ndarray: :rtype: np.ndarray """ stripes = np.empty(size, dtype=float) - for i in range(size[1]): + for _ in range(size[1]): start = np.ceil(2 * np.random.rand()) - 1 for j in range(size[0]): stripes[:, j] = start @@ -40,7 +40,7 @@ def generate_hstripes(size: Size) -> np.ndarray: stripes = np.empty(size, dtype=float) for i in range(size[0]): start = np.ceil(2 * np.random.rand()) - 1 - for j in range(size[1]): + for _ in range(size[1]): stripes[i, :] = start if np.random.rand() < 0.2: start = np.ceil(2 * np.random.rand()) - 1 diff --git a/GameBEye/gbcamcolors.py b/gamebeye/gbcamcolors.py similarity index 97% rename from GameBEye/gbcamcolors.py rename to gamebeye/gbcamcolors.py index c4d748b..2b6777c 100644 --- a/GameBEye/gbcamcolors.py +++ b/gamebeye/gbcamcolors.py @@ -1,8 +1,9 @@ """Define the GBColorPalettes enum.""" from enum import Enum, unique -from typing import Tuple, List -from GameBEye.color_helpers import hex_to_rgb +from typing import List, Tuple + +from gamebeye.color_helpers import hex_to_rgb # Class decorator @unique ensure each enum value is unique @@ -707,7 +708,7 @@ def describe(self) -> Tuple[str, list]: :returns: a 2-values tuple containing the color name and its values :rtype: str, list - >>> from GameBEye.gbcamcolors.gbcamcolors import GBColorPalettes + >>> from gamebeye.gbcamcolors.gbcamcolors import GBColorPalettes >>> GBColorPalettes.BW.describe() ('BW', ['#FFFFFF', '#A8A8A8', '#545454', '#000000']) """ @@ -720,7 +721,7 @@ def __str__(self) -> str: :returns: the enum member as a string :rtype: str - >>> from GameBEye.gbcamcolors.gbcamcolors import GBColorPalettes + >>> from gamebeye.gbcamcolors.gbcamcolors import GBColorPalettes >>> str(GBColorPalettes.BW) "BW : ['#FFFFFF', '#A8A8A8', '#545454', '#000000']" """ @@ -734,11 +735,8 @@ def rgb_colors(self) -> List[List[int]]: :return: the 4 colors values in the RGB space :rtype: list[list[int]] - >>> from GameBEye.gbcamcolors.gbcamcolors import GBColorPalettes + >>> from gamebeye.gbcamcolors.gbcamcolors import GBColorPalettes >>> GBColorPalettes.BW.rgb_colors [[255, 255, 255], [168, 168, 168], [84, 84, 84], [0, 0, 0]] """ - return [ - [channel_val for channel_val in hex_to_rgb(hex_value)] - for hex_value in self.value - ] + return [list(hex_to_rgb(hex_value)) for hex_value in self.value] diff --git a/GameBEye/gbcamfilters.py b/gamebeye/gbcamfilters.py similarity index 83% rename from GameBEye/gbcamfilters.py rename to gamebeye/gbcamfilters.py index 5e0b1e3..394041f 100644 --- a/GameBEye/gbcamfilters.py +++ b/gamebeye/gbcamfilters.py @@ -1,16 +1,18 @@ """Define filters to apply to GBCamImage object.""" import os + import cv2 import numpy as np -from GameBEye.color_helpers import bgr_to_hex -from GameBEye.gbcamimage import GBCamImage -from GameBEye.filter_helpers import generate_vstripes +from gamebeye.color_helpers import bgr_to_hex +from gamebeye.filter_helpers import generate_vstripes +from gamebeye.gbcamimage import GBCamImage def to_thermal_printer(src: GBCamImage) -> np.ndarray: - """Emulate a GB thermal printer and return a printed-on-paper image. + """ + Emulate a GB thermal printer and return a printed-on-paper image. :param src: A Game Boy Camera Image :type: GBCamImage @@ -46,9 +48,7 @@ def to_thermal_printer(src: GBCamImage) -> np.ndarray: if bgr_to_hex(src.data[x, y]) != src.color_palette.value[0]: j = np.random.choice(nb_pixel_samples) - i = src.color_palette.value[1:].index( - bgr_to_hex(src.data[x, y]) - ) + i = src.color_palette.value[1:].index(bgr_to_hex(src.data[x, y])) dot = pixel_sample[ mask_size * i : mask_size * (i + 1), diff --git a/GameBEye/gbcamimage.py b/gamebeye/gbcamimage.py similarity index 94% rename from GameBEye/gbcamimage.py rename to gamebeye/gbcamimage.py index 939dd33..68d33d4 100644 --- a/GameBEye/gbcamimage.py +++ b/gamebeye/gbcamimage.py @@ -1,16 +1,17 @@ """Define the GBCamImage class.""" import os +from typing import NoReturn, Tuple + import cv2 import numpy as np -from typing import NoReturn, Tuple -from GameBEye.color_helpers import ( - hex_to_rgb, - hex_to_bgr, +from gamebeye.color_helpers import ( bgr_to_hex, + hex_to_bgr, + hex_to_rgb, ) -from GameBEye.gbcamcolors import GBColorPalettes +from gamebeye.gbcamcolors import GBColorPalettes Shape = Tuple[int, int, int] @@ -98,11 +99,7 @@ def read(self, image_filepath: str) -> NoReturn: raise ValueError("The shape doesn't fit the GBCamImage shape") bgr_colors = ( - np.unique( - img.view( - np.dtype((np.void, img.dtype.itemsize * img.shape[2])) - ) - ) + np.unique(img.view(np.dtype((np.void, img.dtype.itemsize * img.shape[2])))) .view(img.dtype) .reshape(-1, img.shape[2]) ) diff --git a/GameBEye/images/sample/pixel_sample.png b/gamebeye/images/sample/pixel_sample.png similarity index 100% rename from GameBEye/images/sample/pixel_sample.png rename to gamebeye/images/sample/pixel_sample.png diff --git a/pyproject.toml b/pyproject.toml index 914fe0f..9038d12 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [project] -name = "GameBEye" +name = "gamebeye" version = "0.0.0" description = "A small Python library to process GameBoy Camera images" authors = [ @@ -30,10 +30,10 @@ classifiers = [ ] [project.urls] -homepage = "https://github.com/mtouzot/GameBEye" -changelog = "https://github.com/mtouzot/GameBEye/CHANGELOG.md" -documentation = "https://mtouzot.github.io/GameBEye" -issues = "https://github.com/mtouzot/GameBEye/issues" +homepage = "https://github.com/mtouzot/gamebeye" +changelog = "https://github.com/mtouzot/gamebeye/CHANGELOG.md" +documentation = "https://mtouzot.github.io/gamebeye" +issues = "https://github.com/mtouzot/gamebeye/issues" funding = "https://www.paypal.com/paypalme/touzotmartin" [build-system] @@ -41,7 +41,7 @@ requires = ["poetry-core>=2.0.0,<3.0.0"] build-backend = "poetry.core.masonry.api" [tool.pytest.ini_options] -pythonpath = "GameBEye" +pythonpath = "gamebeye" addopts = [ "-ra -q", "--import-mode=importlib", @@ -67,7 +67,7 @@ sphinx-favicon = "^1.0.1" [tool.poetry] packages = [ - { include = "GameBEye" }, + { include = "gamebeye" }, ] [tool.ruff.lint] @@ -81,6 +81,10 @@ select = [ "N", # PEP8 naming convetions "D" # pydocstyle ] +ignore = [ + "D203", # Ignoring `incorrect-blank-line-before-class` + "D212" # Ignoring `multi-line-summary-second-line` +] [tool.ruff.lint.per-file-ignores] "**/docs/*" = ["D"] \ No newline at end of file diff --git a/tests/__init__.py b/tests/__init__.py index da8eb4e..6db72a8 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -1 +1 @@ -"""GameBEye unitary tests.""" +"""gamebeye unitary tests.""" diff --git a/tests/test_gbcamcolors.py b/tests/test_gbcamcolors.py index f4b5b3f..ea42009 100644 --- a/tests/test_gbcamcolors.py +++ b/tests/test_gbcamcolors.py @@ -1,10 +1,12 @@ -"""All relative tests to GameBEye.gbcamcolors.gbcamcolors file.""" +"""All relative tests to gamebeye.gbcamcolors.gbcamcolors file.""" -import pytest from typing import List + import numpy as np -import GameBEye.gbcamcolors as gbcamcolors -import GameBEye.color_helpers as color_helpers +import pytest + +import gamebeye.color_helpers as color_helpers +import gamebeye.gbcamcolors as gbcamcolors @pytest.mark.parametrize( @@ -24,7 +26,7 @@ ), ], ) -def test_GBColorPalettes( +def test_gbcolorpalettes( color: gbcamcolors.GBColorPalettes, name: str, value: List[str], diff --git a/tests/test_gbcamimage.py b/tests/test_gbcamimage.py index be0818d..3a90df6 100644 --- a/tests/test_gbcamimage.py +++ b/tests/test_gbcamimage.py @@ -1,8 +1,9 @@ -"""All relative tests to GameBEye.gbcamimage.gbcamimage file.""" +"""All relative tests to gamebeye.gbcamimage.gbcamimage file.""" -import pytest import numpy as np -import GameBEye.gbcamimage as gbcamimage +import pytest + +import gamebeye.gbcamimage as gbcamimage def test_gbcamimage():