From cb2690dfdd5aaabcdbfb8f64abdf084891f30a1b Mon Sep 17 00:00:00 2001 From: profitroll Date: Thu, 10 Aug 2023 14:02:29 +0200 Subject: [PATCH] Update to 0.0.4 --- .gitea/workflows/tests.yml | 33 +++++ .vscode/settings.json | 8 +- README.md | 153 ++++++++++++++++++++++++ README.org | 131 -------------------- flake.lock | 43 ------- flake.nix | 55 --------- pyproject.toml | 35 ++++-- requirements.txt | 3 - requirements/_.txt | 3 + requirements/dev.txt | 9 ++ {huepaper => src/huepaper}/__init__.py | 2 + {huepaper => src/huepaper}/__main__.py | 0 {huepaper => src/huepaper}/generator.py | 0 {huepaper => src/huepaper}/utils.py | 0 tox.ini | 20 ++++ 15 files changed, 255 insertions(+), 240 deletions(-) create mode 100644 .gitea/workflows/tests.yml create mode 100644 README.md delete mode 100644 README.org delete mode 100644 flake.lock delete mode 100644 flake.nix delete mode 100644 requirements.txt create mode 100644 requirements/_.txt create mode 100644 requirements/dev.txt rename {huepaper => src/huepaper}/__init__.py (69%) rename {huepaper => src/huepaper}/__main__.py (100%) rename {huepaper => src/huepaper}/generator.py (100%) rename {huepaper => src/huepaper}/utils.py (100%) create mode 100644 tox.ini diff --git a/.gitea/workflows/tests.yml b/.gitea/workflows/tests.yml new file mode 100644 index 0000000..c5e0925 --- /dev/null +++ b/.gitea/workflows/tests.yml @@ -0,0 +1,33 @@ +name: Tests + +on: + push: + branches: + - dev + - main + tags-ignore: + - v* + pull_request: + +jobs: + test: + runs-on: ubuntu-latest + container: catthehacker/ubuntu:act-latest + strategy: + matrix: + python-version: ["3.8", "3.9", "3.10", "3.11"] + + steps: + - uses: actions/checkout@v3 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v3 + with: + python-version: ${{ matrix.python-version }} + env: + AGENT_TOOLSDIRECTORY: /opt/hostedtoolcache + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install tox tox-gh-actions + - name: Test with tox + run: tox diff --git a/.vscode/settings.json b/.vscode/settings.json index 25463dc..67e12d5 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -4,5 +4,11 @@ "tests" ], "python.testing.unittestEnabled": false, - "python.testing.pytestEnabled": true + "python.testing.pytestEnabled": true, + "[markdown]": { + "editor.defaultFormatter": "DavidAnson.vscode-markdownlint" + }, + "[toml]": { + "editor.defaultFormatter": "tamasfe.even-better-toml" + } } \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..c2d3f6d --- /dev/null +++ b/README.md @@ -0,0 +1,153 @@ +# huepaper - a colorful wallpaper generator + +![Logo](images/logo.png) + +**huepaper** creates wallpapers based on color hues. Bring a little +color in your life by randomness, because every huepaper is truly +unique. + +You can find [examples](#examples) below. For more examples visit the +Mastodon [huebot](https://botsin.space/@huebot). + +## Installation + +### Nix + +This project is a [Nix Flake](https://nixos.wiki/wiki/Flakes). If you +have a recent version of the [Nix package manager](https://nixos.org/) +installed and Flakes are enabled, run huepaper like this: + +``` example +nix run github:Deleh/huepaper +``` + +Parameters can be passed by appending a double-dash: + +``` example +nix run github:Deleh/huepaper -- -hue 0.5 --color lightblue +``` + +Global installation can be done by including this flake in your flaked +NixOS configuration as always :) + +### Legacy + +Execute the following steps to run huepaper: + +``` example +pip install -r requirements.txt +./huepaper.py +``` + +```{=org} +#+end_example +``` + +To install it in your Python environment run: + +``` example +python setup.py install +``` + +## Usage + +``` example +usage: huepaper [-h] [-s SIZE] [-c COLOR] [-np] [-o OUTPUT] [-l [LINES]] [-lb [LINES_BRIGHT]] [-ld [LINES_DARK]] [-P [PIXELATE]] [-e EMBLEM] [-hue HUE] [-smin SMIN] [-smax SMAX] [-lmin LMIN] [-lmax LMAX] + +Create wallpapers based on color hues. + +optional arguments: + -h, --help show this help message and exit + -s SIZE, --size SIZE size of huepaper in the form WIDTHxHEIGHT (default: 1920x1080) + -c COLOR, --color COLOR + base color from which the huepaper is generated (default: random color) + -np, --no-preview don't preview the huepaper + -o OUTPUT, --output OUTPUT + filepath where the huepaper will be saved + -l [LINES], --lines [LINES] + include one to three random lines in base color with given opacity in range [0, 1] (default: 0.3) + -lb [LINES_BRIGHT], --lines_bright [LINES_BRIGHT] + include one to three bright random lines with given opacity in range [0, 1] (default: 0.1) + -ld [LINES_DARK], --lines_dark [LINES_DARK] + include one to three dark random lines with given opacity in range [0, 1] (default: 0.1) + -p [PIXELATE], --pixelate [PIXELATE] + pixelate image with WIDTHxHEIGHT (default: 16x9) + -e EMBLEM, --emblem EMBLEM + emblem to add in the center of the huepaper + -hue HUE maximum hue to differ from given color in range [0, 1] (default: 0.1) + -smin SMIN minimum saturation for colors in range [0, 1] (default: 0.2) + -smax SMAX maximum saturation for colors in range [0, 1] (default: 1.0) + -lmin LMIN minimum luminance for colors in range [0, 1] (default: 0.2) + -lmax LMAX maximum luminance for colors in range [0, 1] (default: 0.9) +``` + +All image operations are called in order of the help file. E.g. pixelate +(`-p`) is called after adding lines (`-l`). + +If you set the color via `-c` it is not guaranteed, that it +is included in the huepaper. Colors, similar to the given one are +chosen. You can specify how far the colors differ in the hue range with +the `-hue` parameter. Valid color expressions are e.g. +`#F5F5DC`, `#0f0`, `ffff80` and +`red`. Make sure, that colors beginning with a `#` +are encapsulated in quotes. All supported color names can be seen +[here](https://www.w3schools.com/colors/colors_names.asp). + +If you use the `-e` argument to specify an emblem, make sure +it has the correct size. It is not scaled or stretched, just placed in +the center of the image. If you want an offset, e.g. put it in the left +bottom corner, provide an emblem file with the size of the huepaper, +transparent background and your emblem in the bottom left corner. + +## Examples + +Please note, that every huepaper call generates a new random image. You +will never get the same huepaper twice. You may like some and dislike +others. Fiddle around with the options to find a result, you are happy +with. + +![Huepaper 1](images/huepaper_1.png) + +``` example +huepaper +``` + +------------------------------------------------------------------------ + +![Huepaper 1](images/huepaper_2.png) + +``` example +huepaper -c lightgreen +``` + +------------------------------------------------------------------------ + +![Huepaper 3](images/huepaper_3.png) + +``` example +huepaper -c "#ff7f50" -lb 0.05 +``` + +------------------------------------------------------------------------ + +![Huepaper 4](images/huepaper_4.png) + +``` example +huepaper -hue 1.0 -lmin 0.3 -lmax 0.6 -smin 0.8 -smax 1.0 +``` + +------------------------------------------------------------------------ + +![Huepaper 5](images/huepaper_5.png) + +``` example +huepaper -hue 0.3 -lmin 0.5 -lmax 0.5 -l 0.5 -P 64x36 +``` + +------------------------------------------------------------------------ + +![Huepaper 6](images/huepaper_6.png) + +``` example +huepaper -l -lb -ld -e nixos.png +``` diff --git a/README.org b/README.org deleted file mode 100644 index 4929b88..0000000 --- a/README.org +++ /dev/null @@ -1,131 +0,0 @@ -* huepaper - a colorful wallpaper generator - - #+caption: Logo - [[./images/logo.png]] - - *huepaper* creates wallpapers based on color hues. Bring a little color in your life by randomness, because every huepaper is truly unique. - - You can find [[#examples][examples]] below. - For more examples visit the Mastodon [[https://botsin.space/@huebot][huebot]]. - -** Installation - -*** Nix - - This project is a [[https://nixos.wiki/wiki/Flakes][Nix Flake]]. - If you have a recent version of the [[https://nixos.org/][Nix package manager]] installed and Flakes are enabled, run huepaper like this: - - : $ nix run github:Deleh/huepaper - - Parameters can be passed by appending a double-dash: - - : $ nix run github:Deleh/huepaper -- -hue 0.5 --color lightblue - - Global installation can be done by including this flake in your flaked NixOS configuration as always :) - -*** Legacy - - Execute the following steps to run huepaper: - - : $ pip install -r requirements.txt - : $ ./huepaper.py - #+end_example - - To install it in your Python environment run: - - : $ python setup.py install - -** Usage - - #+begin_example - usage: huepaper [-h] [-s SIZE] [-c COLOR] [-np] [-o OUTPUT] [-l [LINES]] [-lb [LINES_BRIGHT]] [-ld [LINES_DARK]] [-P [PIXELATE]] [-e EMBLEM] [-hue HUE] [-smin SMIN] [-smax SMAX] [-lmin LMIN] [-lmax LMAX] - - Create wallpapers based on color hues. - - optional arguments: - -h, --help show this help message and exit - -s SIZE, --size SIZE size of huepaper in the form WIDTHxHEIGHT (default: 1920x1080) - -c COLOR, --color COLOR - base color from which the huepaper is generated (default: random color) - -np, --no-preview don't preview the huepaper - -o OUTPUT, --output OUTPUT - filepath where the huepaper will be saved - -l [LINES], --lines [LINES] - include one to three random lines in base color with given opacity in range [0, 1] (default: 0.3) - -lb [LINES_BRIGHT], --lines_bright [LINES_BRIGHT] - include one to three bright random lines with given opacity in range [0, 1] (default: 0.1) - -ld [LINES_DARK], --lines_dark [LINES_DARK] - include one to three dark random lines with given opacity in range [0, 1] (default: 0.1) - -p [PIXELATE], --pixelate [PIXELATE] - pixelate image with WIDTHxHEIGHT (default: 16x9) - -e EMBLEM, --emblem EMBLEM - emblem to add in the center of the huepaper - -hue HUE maximum hue to differ from given color in range [0, 1] (default: 0.1) - -smin SMIN minimum saturation for colors in range [0, 1] (default: 0.2) - -smax SMAX maximum saturation for colors in range [0, 1] (default: 1.0) - -lmin LMIN minimum luminance for colors in range [0, 1] (default: 0.2) - -lmax LMAX maximum luminance for colors in range [0, 1] (default: 0.9) - #+end_example - - All image operations are called in order of the help file. E.g. pixelate (=-p=) is called after adding lines (=-l=). - - If you set the color via =-c= it is not guaranteed, that it is included in the huepaper. - Colors, similar to the given one are chosen. - You can specify how far the colors differ in the hue range with the =-hue= parameter. - Valid color expressions are e.g. =#F5F5DC=, =#0f0=, =ffff80= and =red=. - Make sure, that colors beginning with a =#= are encapsulated in quotes. - All supported color names can be seen [[https://www.w3schools.com/colors/colors_names.asp][here]]. - - If you use the =-e= argument to specify an emblem, make sure it has the correct size. - It is not scaled or stretched, just placed in the center of the image. - If you want an offset, e.g. put it in the left bottom corner, provide an emblem file with the size of the huepaper, transparent background and your emblem in the bottom left corner. - -** Examples - :properties: - :custom_id: examples - :end: - - Please note, that every huepaper call generates a new random image. - You will never get the same huepaper twice. - You may like some and dislike others. - Fiddle around with the options to find a result, you are happy with. - - #+caption: Huepaper 1 - [[./images/huepaper_1.png]] - - : $ huepaper - - ----- - - #+caption: Huepaper 1 - [[./images/huepaper_2.png]] - - : $ huepaper -c lightgreen - - ----- - - #+caption: Huepaper 3 - [[./images/huepaper_3.png]] - - : $ huepaper -c "#ff7f50" -lb 0.05 - - ----- - - #+caption: Huepaper 4 - [[./images/huepaper_4.png]] - - : $ huepaper -hue 1.0 -lmin 0.3 -lmax 0.6 -smin 0.8 -smax 1.0 - - ----- - - #+caption: Huepaper 5 - [[./images/huepaper_5.png]] - - : $ huepaper -hue 0.3 -lmin 0.5 -lmax 0.5 -l 0.5 -P 64x36 - - ----- - - #+caption: Huepaper 6 - [[./images/huepaper_6.png]] - - : $ huepaper -l -lb -ld -e nixos.png diff --git a/flake.lock b/flake.lock deleted file mode 100644 index 47d5708..0000000 --- a/flake.lock +++ /dev/null @@ -1,43 +0,0 @@ -{ - "nodes": { - "flake-utils": { - "locked": { - "lastModified": 1676283394, - "narHash": "sha256-XX2f9c3iySLCw54rJ/CZs+ZK6IQy7GXNY4nSOyu2QG4=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "3db36a8b464d0c4532ba1c7dda728f4576d6d073", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, - "nixpkgs": { - "locked": { - "lastModified": 1676300157, - "narHash": "sha256-1HjRzfp6LOLfcj/HJHdVKWAkX9QRAouoh6AjzJiIerU=", - "owner": "nixos", - "repo": "nixpkgs", - "rev": "545c7a31e5dedea4a6d372712a18e00ce097d462", - "type": "github" - }, - "original": { - "owner": "nixos", - "ref": "nixos-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, - "root": { - "inputs": { - "flake-utils": "flake-utils", - "nixpkgs": "nixpkgs" - } - } - }, - "root": "root", - "version": 7 -} diff --git a/flake.nix b/flake.nix deleted file mode 100644 index 16ba66b..0000000 --- a/flake.nix +++ /dev/null @@ -1,55 +0,0 @@ -{ - description = "A colorful wallpaper generator"; - - nixConfig.bash-prompt = "\[\\e[1m\\e[34mhuepaper-dev\\e[0m:\\w\]$ "; - - inputs = { - nixpkgs.url = github:nixos/nixpkgs/nixos-unstable; - flake-utils.url = github:numtide/flake-utils; - }; - - outputs = { self, nixpkgs, flake-utils }: - - flake-utils.lib.eachDefaultSystem - (system: - let - pkgs = nixpkgs.legacyPackages.${system}; - in - { - - # Package - packages.huepaper = - pkgs.python3Packages.buildPythonPackage rec { - name = "huepaper"; - src = self; - propagatedBuildInputs = with pkgs; [ - python3Packages.colour - python3Packages.numpy - python3Packages.pillow - ]; - }; - defaultPackage = self.packages.${system}.huepaper; - - # App - apps.huepaper = { - type = "app"; - program = "${self.packages.${system}.huepaper}/bin/huepaper"; - }; - defaultApp = self.apps.${system}.huepaper; - - # Development shell - devShell = pkgs.mkShell { - buildInputs = with pkgs; [ - python3 - python3Packages.colour - python3Packages.numpy - python3Packages.pillow - python3Packages.pip - python3Packages.setuptools - python3Packages.virtualenv - ]; - - }; - } - ); -} diff --git a/pyproject.toml b/pyproject.toml index fba7f94..e0f5602 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,8 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "huepaper" -version = "0.0.3" -dynamic = ["dependencies"] +dynamic = ["version", "dependencies", "optional-dependencies"] authors = [{ name = "Denis Lehmann" }] maintainers = [{ name = "Profitroll" }] description = "A colorful wallpaper generator" @@ -34,14 +33,36 @@ Tracker = "https://git.end-play.xyz/profitroll/huepaper/issues" [project.scripts] huepaper = "huepaper.__main__:main" -[tool.setuptools] -packages = ["huepaper"] - [tool.setuptools.dynamic] -dependencies = { file = "requirements.txt" } +version = { attr = "huepaper.__version__" } +dependencies = { file = "requirements/_.txt" } + +[tool.setuptools.dynamic.optional-dependencies] +dev = { file = "requirements/dev.txt" } + +[tool.setuptools.packages.find] +where = ["src"] [tool.black] -target-version = ['py37', 'py38', 'py39', 'py310', 'py311'] +target-version = ['py38', 'py39', 'py310', 'py311'] [tool.isort] profile = "black" + +[tool.pytest.ini_options] +minversion = "6.0" +python_files = ["test_*.py"] +pythonpath = "." +testpaths = ["tests"] + +[tool.mypy] +namespace_packages = true +install_types = true +strict = true +show_error_codes = true + +[tool.pylint.main] +py-version = 3.8 + +[tool.coverage.run] +source = ["huepaper"] diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index e44b754..0000000 --- a/requirements.txt +++ /dev/null @@ -1,3 +0,0 @@ -colour==0.1.5 -numpy~=1.25.2 -pillow~=10.0.0 \ No newline at end of file diff --git a/requirements/_.txt b/requirements/_.txt new file mode 100644 index 0000000..eadbe92 --- /dev/null +++ b/requirements/_.txt @@ -0,0 +1,3 @@ +colour==0.1.5 +numpy~=1.24.0,<1.25.0 +pillow~=10.0.0 \ No newline at end of file diff --git a/requirements/dev.txt b/requirements/dev.txt new file mode 100644 index 0000000..d9fd5d2 --- /dev/null +++ b/requirements/dev.txt @@ -0,0 +1,9 @@ +black==23.7.0 +build==0.10.0 +isort==5.12.0 +mypy==1.4.1 +pylint==2.17.5 +pytest-cov==4.1.0 +pytest==7.4.0 +tox==4.7.0 +twine==4.0.2 \ No newline at end of file diff --git a/huepaper/__init__.py b/src/huepaper/__init__.py similarity index 69% rename from huepaper/__init__.py rename to src/huepaper/__init__.py index e450888..17ea027 100644 --- a/huepaper/__init__.py +++ b/src/huepaper/__init__.py @@ -1,2 +1,4 @@ +__version__ = "0.0.4" + from . import utils from .generator import generate diff --git a/huepaper/__main__.py b/src/huepaper/__main__.py similarity index 100% rename from huepaper/__main__.py rename to src/huepaper/__main__.py diff --git a/huepaper/generator.py b/src/huepaper/generator.py similarity index 100% rename from huepaper/generator.py rename to src/huepaper/generator.py diff --git a/huepaper/utils.py b/src/huepaper/utils.py similarity index 100% rename from huepaper/utils.py rename to src/huepaper/utils.py diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..323c026 --- /dev/null +++ b/tox.ini @@ -0,0 +1,20 @@ +[tox] +minversion = 3.8.0 +envlist = py38, py39, py310, py311 +isolated_build = true + +[gh-actions] +python = + 3.8: py38 + 3.9: py39 + 3.10: py310 + 3.11: py311 + +[testenv] +setenv = + PYTHONPATH = {toxinidir} +deps = + -r{toxinidir}/requirements/_.txt + -r{toxinidir}/requirements/dev.txt +commands = + pytest --basetemp={envtmpdir} --cov=huepaper --cov-report term-missing \ No newline at end of file