From 3cd3800ee0787f2e47a2ab4f5b39a21a8dc7c913 Mon Sep 17 00:00:00 2001 From: Victor Westerlund Date: Sat, 17 Jun 2023 14:05:12 +0200 Subject: [PATCH] feat: added typing and other small changes (#3) * feat(refactor): added typing and other small changes * fix(versioning): version 1.1.0 --- .gitignore | 162 ++++++++++++++++++++++++++++++++++++++++- __main__.py | 23 ++++++ example/example.py | 10 --- example/files/1.png | Bin 373 -> 0 bytes example/files/2.png | Bin 406 -> 0 bytes example/files/3.png | Bin 471 -> 0 bytes example/files/4.png | Bin 291 -> 0 bytes example/files/5.png | Bin 333 -> 0 bytes example/files/6.png | Bin 333 -> 0 bytes example/files/7.png | Bin 280 -> 0 bytes example/files/8.png | Bin 333 -> 0 bytes example/files/9.png | Bin 450 -> 0 bytes pysheeter/PySheeter.py | 68 ----------------- pysheeter/__init__.py | 0 pysheeter/pysheeter.py | 66 +++++++++++++++++ requirements.txt | 2 + setup.py | 13 ++++ 17 files changed, 265 insertions(+), 79 deletions(-) create mode 100644 __main__.py delete mode 100644 example/example.py delete mode 100644 example/files/1.png delete mode 100644 example/files/2.png delete mode 100644 example/files/3.png delete mode 100644 example/files/4.png delete mode 100644 example/files/5.png delete mode 100644 example/files/6.png delete mode 100644 example/files/7.png delete mode 100644 example/files/8.png delete mode 100644 example/files/9.png delete mode 100644 pysheeter/PySheeter.py create mode 100644 pysheeter/__init__.py create mode 100644 pysheeter/pysheeter.py create mode 100644 requirements.txt create mode 100644 setup.py diff --git a/.gitignore b/.gitignore index 82f1e02..044cfe4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,162 @@ +._* + +# Byte-compiled / optimized / DLL files __pycache__/ -example_* \ No newline at end of file +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ +cover/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +.pybuilder/ +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# .python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# poetry +# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. +# This is especially recommended for binary packages to ensure reproducibility, and is more +# commonly ignored for libraries. +# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control +#poetry.lock + +# pdm +# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. +#pdm.lock +# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it +# in version control. +# https://pdm.fming.dev/#use-with-ide +.pdm.toml + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# pytype static type analyzer +.pytype/ + +# Cython debug symbols +cython_debug/ + +# PyCharm +# JetBrains specific template is maintained in a separate JetBrains.gitignore that can +# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore +# and can be added to the global gitignore or merged into this file. For a more nuclear +# option (not recommended) you can uncomment the following to ignore the entire idea folder. +#.idea/ \ No newline at end of file diff --git a/__main__.py b/__main__.py new file mode 100644 index 0000000..34e4061 --- /dev/null +++ b/__main__.py @@ -0,0 +1,23 @@ +from pysheeter.pysheeter import Sheet as SpriteSheet + +# Simple PySheeter CLI +def main(): + print("Welcome to the PySheeter CLI") + + # Gather parameters from user input + folder = str(input("Enter path to folder of sprites:\n")) + ext = str(input("Enter the file extension of these sprites (without dot, 'png', 'jpg' etc.):\n")) + size = int(input("What width in pixels do you want each sprite to be? (1:1 aspect ratio):\n")) + vertical = not bool(input("Do you want a vertical sprite sheet? [Y,n]:\n")) + dest = str(input("Finally, enter a file name (or path) for the sprite sheet:\n")) + + print("Reading sprites from folder...") + sheet = SpriteSheet(folder, ext) + + print("Creating sprite sheet...") + sheet.put(dest, (size, size), vertical) + + print("Done!") + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/example/example.py b/example/example.py deleted file mode 100644 index c22efcd..0000000 --- a/example/example.py +++ /dev/null @@ -1,10 +0,0 @@ -from pysheeter import PySheeter - -# Load sprites from './files/' (all sprites are 64x64) -spritesheet = PySheeter.Sheet("files") - -# Create a vertical spritesheet with the dimensions 16x16 (scaled) -spritesheet.put("example_v1616.png",(16,16)) - -# Create a horizontal spritesheet with the dimensions 16x32 (scaled & stretched) -spritesheet.put("example_h1632.png",(16,32),False) \ No newline at end of file diff --git a/example/files/1.png b/example/files/1.png deleted file mode 100644 index 0d6591b80ddde50cf39066e4b8a5a6d0717fbb70..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 373 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0I%)r3-YQx4VAcwIy$lZxy-8q?;Kn_c~qpu?a z!^VE@KZ&eBK3jlKh%1l=f~Dy@&jTr@k|4j}{|ryJ8+ZYEoCO|{#S9F5he4R}c>anM zpx`S{7sn6}@3)hB`I;4YTE6~`ugbMt(%SVk|1?LulFaqbB{NTR^+Z(oE_(c=^`_t+ zmG*0=6s?q)lNA@7nzklZ`Tj!T&P4}`-6}8UdamZ9kb)2;)Y z7nYsTVo2cdV{lJk4w&_j$u60tZwBjn(F^6_&7RIX8V+2zq}d>Lq+s(wrt3n7SgU#K zLlmy{G8OJASmSW+-QT@UQfIUlu}W+y;ab2ygOyo)PJ-ASy@>1lw(I#aSR6g}0)5Tk M>FVdQ&MBb@0IuJSSpWb4 diff --git a/example/files/2.png b/example/files/2.png deleted file mode 100644 index 536ccbcd86cae19c9c7ce85a339f591d23bb08ec..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 406 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0I%)r3-YQx4VAcwIy$lZxy-8q?;Kn_c~qpu?a z!^VE@KZ&eBK3jlKh%1l=f~Dy@&jTr@k|4j}{|ryJ8+ZYEoCO|{#S9F5he4R}c>anM zpn=?;E{-7{-ft%{@*P&-VZQypzRH2;h-X9TTa(O3OB^@MowCx_&*A9AaLq498b*nV zrE&e69*~+uBbIZw{Tc>z?Gwx!Z6Hw`Mq5O^ZT@(2wL9;~zzTD-!@t&iX zpXK!A#>Ic5V_$LlUbC}hV*6Rsp0qJvZ>G=V*$$oySf0%g($KQ!uqboLVEik!^4Pl2 zs;A;izUu#j82El)XL_{pJ#!iZd(rlfu?P4J7{52juDG%Ju|1Raw}$mR9`|Sef6`V| z(rh5rH8bGzLkFgf8IS#5@Pyz>&^e>B tl*P}GyZq*Uc9m}pR~yW4Fz4}GoEOgxanM zpn*P~E{-7{-ft(}E<3Ei!}9q5|Cdb?Jr`KtTzTs}yYj%LtgUKxm9hfjm*%)jPYs^6 zP~^~}tGhl#uUA>#9FVg&XnBFvt>E()#F%W87X49OKzTPG5*{dt4@M&huBa&2yDl_9yFO!YyLlu20(3eF4V2OL85uPk5kIVwZ%U?9v8H|S|GINpoN?X zkKs<|o0E6hTTf;TkXqG!Y_j6Be2KCeCNai8#a1ikRUDeu)~PJDgZHu@3v;BuxK1R) z*Lm{XJLU*TMjtxbaly@rG0`ziaY56h4HBF66{ diff --git a/example/files/4.png b/example/files/4.png deleted file mode 100644 index 17d23683736430e783279d3cec58e81a637ea800..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 291 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0I%)r3-YQx4VAcwIy$lZxy-8q?;Kn_c~qpu?a z!^VE@KZ&eBK3jlKh%1l=f~Dy@&jTr@k|4j}{|ryJ8+ZYEoCO|{#S9F5he4R}c>anM zpx_Ko7sn6}@3)hhotTa6TjDkS6k;*=~bT;sYhS df@+0htf!RugqG*t*#~qZgQu&X%Q~loCIEKGV+{ZR diff --git a/example/files/5.png b/example/files/5.png deleted file mode 100644 index ee6ad7f93e523b8a9c40a3f1c9289efd3effbd2f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 333 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0I%)r3-YQx4VAcwIy$lZxy-8q?;Kn_c~qpu?a z!^VE@KZ&eBK3jlKh%1l=f~Dy@&jTr@k|4j}{|ryJ8+ZYEoCO|{#S9F5he4R}c>anM zpx_}-7sn6}@3)gq^Bqy(VZQzU|I52p%)I@f3%SLQ$Y?#b5OcEis}N|nv#MKZeTe&V zCr9+sWEVk&3dPcVwm9jTQCCwM#`Z!Ii0Tkj#2wnNBXM89XwM8@5#4+z>dct}cf zBuK>ac1+pW$kDfAy=B>f9n5;1Nw%+)78&qol`;+03xPuS^xk5 diff --git a/example/files/6.png b/example/files/6.png deleted file mode 100644 index ee6ad7f93e523b8a9c40a3f1c9289efd3effbd2f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 333 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0I%)r3-YQx4VAcwIy$lZxy-8q?;Kn_c~qpu?a z!^VE@KZ&eBK3jlKh%1l=f~Dy@&jTr@k|4j}{|ryJ8+ZYEoCO|{#S9F5he4R}c>anM zpx_}-7sn6}@3)gq^Bqy(VZQzU|I52p%)I@f3%SLQ$Y?#b5OcEis}N|nv#MKZeTe&V zCr9+sWEVk&3dPcVwm9jTQCCwM#`Z!Ii0Tkj#2wnNBXM89XwM8@5#4+z>dct}cf zBuK>ac1+pW$kDfAy=B>f9n5;1Nw%+)78&qol`;+03xPuS^xk5 diff --git a/example/files/7.png b/example/files/7.png deleted file mode 100644 index ab7535e9843f4da8bdede03a79097e186bab32ce..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 280 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0I%)r3-YQx4VAcwIy$lZxy-8q?;Kn_c~qpu?a z!^VE@KZ&eBK3jlKh%1l=f~Dy@&jTr@k|4j}{|ryJ8+ZYEoCO|{#S9F5he4R}c>anM zpkS}3i(`m~_uEO)d<_Z$%n$!fpSJYq8ij-GM~;-(6=;?w@hDC@EZ`JXJgL0-poQ$D zV_|IH+nAV)Q*U~H^$nOIwuApI%e$YY8$K(nm>K!NUYRGl*_uhKq3ZqurW@RQvRIb| zb03gr6m8&IaL@eDVgsip)uxjBzcxIMQ20<1_sK({QL&NbSkggOl?vUCLgv1YdanM zpx_}-7sn6}@3)gq^Bqy(VZQzU|I52p%)I@f3%SLQ$Y?#b5OcEis}N|nv#MKZeTe&V zCr9+sWEVk&3dPcVwm9jTQCCwM#`Z!Ii0Tkj#2wnNBXM89XwM8@5#4+z>dct}cf zBuK>ac1+pW$kDfAy=B>f9n5;1Nw%+)78&qol`;+03xPuS^xk5 diff --git a/example/files/9.png b/example/files/9.png deleted file mode 100644 index 3068c1be9055e1bda3b1750ad48d2920639509ff..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 450 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0I%)r3-YQx4VAcwIy$lZxy-8q?;Kn_c~qpu?a z!^VE@KZ&eBK3jlKh%1l=f~Dy@&jTr@k|4j}{|ryJ8+ZYEoCO|{#S9F5he4R}c>anM zpn>L|E{-7{-ft(}?mKM2;WGRG|Cdq{IR`A3O}E){YT~TE2KGw z?BTi@CN@8gI7<8733$}t_QLUCZF6(=L6x_HLcgjTsVlQ`5&g%bBJSRnA|P*{R%lL7ZZ50=SN zI}>=cm)~hJVEJV&WTEx9C!47^f%R|MF_i$PgrI{`;+!03bbc_ZYh<)U9*Er7WYa9z z@^S4RJ(tJ4iW1W~?rkVKRnKAluF;$A*8V6KbIqlVY