Update to 0.0.4

This commit is contained in:
Profitroll 2023-08-10 14:02:29 +02:00
parent 2c88730c14
commit cb2690dfdd
Signed by: profitroll
GPG Key ID: FA35CAB49DACD3B2
15 changed files with 255 additions and 240 deletions

View File

@ -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

View File

@ -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"
}
}

153
README.md Normal file
View File

@ -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
```

View File

@ -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

View File

@ -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
}

View File

@ -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
];
};
}
);
}

View File

@ -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"]

View File

@ -1,3 +0,0 @@
colour==0.1.5
numpy~=1.25.2
pillow~=10.0.0

3
requirements/_.txt Normal file
View File

@ -0,0 +1,3 @@
colour==0.1.5
numpy~=1.24.0,<1.25.0
pillow~=10.0.0

9
requirements/dev.txt Normal file
View File

@ -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

View File

@ -1,2 +1,4 @@
__version__ = "0.0.4"
from . import utils
from .generator import generate

20
tox.ini Normal file
View File

@ -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