Skip to content

Commit

Permalink
Version 0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
brean committed Oct 4, 2023
1 parent afd7866 commit c0d19fa
Show file tree
Hide file tree
Showing 18 changed files with 256 additions and 369 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/test-and-publish-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Build, test and publish Python 🐍 distributions 📦 to PyPI

on:
push:
branches:
- release
jobs:
build-and-publish:
name: Build, test and publish Python 🐍 distributions 📦 to PyPI
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v2

# Setup Python (faster than using Python container)
- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: "3.x"

- name: Install pipenv
run: |
python -m pip install --upgrade pipenv wheel
- id: cache-pipenv
uses: actions/cache@v1
with:
path: ~/.local/share/virtualenvs
key: ${{ runner.os }}-pipenv-${{ hashFiles('**/Pipfile.lock') }}

- name: Install dependencies
if: steps.cache-pipenv.outputs.cache-hit != 'true'
run: |
pipenv install --deploy --dev
# TODO: create unit tests!
# - name: Run tests with pytest
# run: pipenv run coverage run --source pathfinding -m pytest

# - name: Show basic test coverage report
# run: pipenv run coverage report

- name: Build a binary wheel and a source tarball
run: |
pipenv run pip wheel --wheel-dir=./dist .
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1.8
with:
password: ${{ secrets.PYPI_API_TOKEN }}
40 changes: 40 additions & 0 deletions .github/workflows/test-main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Test

on:
push:
branches:
- main
jobs:
build-and-publish:
name: Test
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v2

# Setup Python (faster than using Python container)
- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: "3.x"

- name: Install pipenv
run: |
python -m pip install --upgrade pipenv wheel
- id: cache-pipenv
uses: actions/cache@v1
with:
path: ~/.local/share/virtualenvs
key: ${{ runner.os }}-pipenv-${{ hashFiles('**/Pipfile.lock') }}

- name: Install dependencies
if: steps.cache-pipenv.outputs.cache-hit != 'true'
run: |
pipenv install --deploy --dev
# TODO: create tests!
# - name: Run tests with pytest
# run: pipenv run coverage run --source txtrpacker -m pytest

# - name: Show basic test coverage report
# run: pipenv run coverage report
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,5 @@ docs/_rst/*
docs/_build/*
cover/*
MANIFEST

output.png
8 changes: 8 additions & 0 deletions AUTHORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Developers

* Execution Unit Ltd.
* see [github contributors](https://github.com/brean/python-txtrpacker/graphs/contributors)

# Maintainer

* Andreas Bresser
5 changes: 0 additions & 5 deletions AUTHORS.rst

This file was deleted.

10 changes: 10 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Changelog

## Version 0.2
- Update to python 3
- Integration of github workflows
- minor code cleanup
- switch to Markdown from RST

## Version 0.1
- Initial version
7 changes: 0 additions & 7 deletions CHANGES.rst

This file was deleted.

3 changes: 2 additions & 1 deletion LICENSE.txt → LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Copyright (c) 2014, Execution Unit Ltd.
Copyright (c) 2014, Execution Unit Ltd,
Copyright (c) 2023 Andreas Bresser <andreas.bresser@dfki.de>
All rights reserved.

Redistribution and use in source and binary forms, with or without
Expand Down
34 changes: 16 additions & 18 deletions README.rst → README.md
Original file line number Diff line number Diff line change
@@ -1,49 +1,47 @@
==========
txtrpacker
==========
# Texture Packer CLI tool

Texture Packer (based on http://www.executionunit.com/blog/2013/04/12/python-script-to-build-a-texture-page-or-sprite-sheet/ by Execution Unit Ltd.)

.. image:: https://coveralls.io/repos/github/brean/txtrpacker/badge.svg?branch=master

Why pack textures/images?
=========================
If you're making a game then it's more efficient to tell the hardware:
## Why pack textures/images?

If you're making a game then it's more efficient to tell the hardware:

::

```
use packed texture 1
draw primitive 1,2,3,4,5,6
use packed texture 2
draw primitive 7,8,9,10
```

than to

::

```
use texture 1
draw primitive 1
use texture 2
draw primitive 2
...
```

The less you do, the more efficient rendering is.

If you're making a website then again it's quicker to ask the client browser to load one large image (often called a sprite sheet) than to ask it to load many more smaller textures.

Algorithm
=========
## Algorithm

The algorithm we are going to use in called Bin Packing. We want to pack the textures in to one larger texture with the minimum of wasted space. Note that there will always be some wasted space, this is an NP complete problem and Bin Packing just gives you a very good solution not a perfect one

2D bin packing works by using the source images to subdivide the destination image creating a tree of 'used' areas of the destination image. This sounds a little complication but it's actually pretty simple.


Usage
=======
## Usage

The python code can be run from the command line to pack a set of PNGs that are in a directory:

.. code-block::
```bash

usage: txtrpacker.py [-h] [-v] [-pad PAD] [-sort SORT] [-maxdim MAXDIM]
[--log LOG]
Expand All @@ -65,13 +63,13 @@ The python code can be run from the command line to pack a set of PNGs that are
maxarea)
-maxdim MAXDIM maximum texture size permissable.
--log LOG Logging level (INFO, DEBUG, WARN) (default: INFO)
```

using the example data you could enter:

..
./txtrpacker.py -pad 4 ./testart output.png

```
txtrpacker.py -pad 4 ./testart output.png
```



Expand Down
6 changes: 1 addition & 5 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
# Add your requirements here like:
# numpy
# scipy>=0.9
setuptools>=9.0

Pillow
45 changes: 1 addition & 44 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,45 +1,2 @@
[metadata]
description = Texture Packer (based on http://www.executionunit.com/blog/2013/04/12/python-script-to-build-a-texture-page-or-sprite-sheet/ )
author = Execution Unit Ltd.
author_email = none
license = BSD
url = https://github.com/brean/txtrpacker
# Comma separated list of data INSIDE your package to include.
# DO NOT prepend the package name when specifying files and folders.
package_data =
# Comma separated list of data OUTSIDE your package to include.
# Equivalent to adding files to MANIFEST.in which is not needed.
data_files = *.rst, *.txt
# Add here all kinds of additional classifiers as defined under
# https://pypi.python.org/pypi?%3Aaction=list_classifiers
classifiers = Development Status :: 4 - Beta,
Programming Language :: Python

[console_scripts]
# Add here console scripts like:
# hello_world = txtrpacker.module:function

[data_files]
# Add here data to be included which lies OUTSIDE your package, e.g.
# path/to/destination = files/to/include, others/to/include
# This is the same as adding files to MANIFEST.in which is not needed anymore.
# The destination is relative to the root of your virtual environment.
# Use ** as wildcard if you want to recursively include a pattern, e.g.
# tests/**.py would include all py-files in all subfolders of tests.
share/txtrpacker = *.rst, *.txt

[extras_require]
# Add here additional requirements for extra features, like:
# PDF = ReportLab>=1.2, RXP

[pytest]
# Options for py.test:
# Specify command line options as you would do when invoking py.test directly.
# e.g. --cov-report html (or xml) for html/xml output or --junitxml junit.xml
# in order to write a coverage file that can be read by Jenkins.
addopts = tests
--cov txtrpacker --cov-report term-missing
--verbose

[aliases]
test = pytest
description-file = README.md

0 comments on commit c0d19fa

Please sign in to comment.