5 Commits

Author SHA1 Message Date
ce752d30e2 Added VSCode tasks
All checks were successful
Tests / test (3.10) (push) Successful in 1m11s
Tests / test (3.11) (push) Successful in 1m11s
Tests / test (3.8) (push) Successful in 1m27s
Tests / test (3.9) (push) Successful in 1m21s
2023-08-10 14:20:08 +02:00
1365273ff0 Improved tests 2023-08-10 14:19:56 +02:00
2f4f61ef82 Changed branch name to master
All checks were successful
Tests / test (3.10) (push) Successful in 1m17s
Tests / test (3.11) (push) Successful in 1m24s
Tests / test (3.8) (push) Successful in 1m8s
Tests / test (3.9) (push) Successful in 1m10s
2023-08-10 14:09:51 +02:00
7df479c59e Improved README 2023-08-10 14:09:17 +02:00
cb2690dfdd Update to 0.0.4 2023-08-10 14:02:29 +02:00
18 changed files with 298 additions and 245 deletions

View File

@@ -0,0 +1,33 @@
name: Tests
on:
push:
branches:
- dev
- master
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"
}
}

33
.vscode/tasks.json vendored Normal file
View File

@@ -0,0 +1,33 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "Build",
"type": "shell",
"linux": {
"command": "./.venv/bin/python -m build"
},
"windows": {
"command": ".\\.venv\\Scripts\\python.exe -m build"
},
"problemMatcher": [],
"group": {
"kind": "build",
"isDefault": true
}
},
{
"label": "Publish",
"type": "shell",
"linux": {
"command": "./.venv/bin/python -m twine upload --repository gitea ./dist/*"
},
"windows": {
"command": ".\\.venv\\Scripts\\python.exe -m twine upload --repository gitea ./dist/*"
},
"problemMatcher": []
}
]
}

128
README.md Normal file
View File

@@ -0,0 +1,128 @@
# 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
```shell
pip install --index-url https://git.end-play.xyz/api/packages/profitroll/pypi/simple/ huepaper
```
## Usage
```example
usage: huepaper [-h] [--width WIDTH] [--height HEIGHT] [-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
--width WIDTH width of the image (default: 1920)
--height HEIGHT height of the image (default: 1080)
-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)
```
...or as a Python module
```python
from huepaper import generate
image = generate(width=500, height=500, hue_max=1.0, lum_min=0.3, lum_max=0.6, sat_min=0.8, sat_max=1.0)
```
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

43
flake.lock generated
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

BIN
tests/assets/emblem.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

View File

@@ -8,14 +8,44 @@ from huepaper.utils import save_image
def test_generation():
image = generate()
assert isinstance(image, Image)
def test_generation_example_1():
image = generate(color="lightgreen")
assert isinstance(image, Image)
def test_generation_example_2():
image = generate(color="#ff7f50", lines_bright=0.05)
assert isinstance(image, Image)
def test_generation_example_3():
image = generate(hue_max=1.0, lum_min=0.3, lum_max=0.6, sat_min=0.8, sat_max=1.0)
assert isinstance(image, Image)
def test_generation_example_4():
image = generate(hue_max=0.3, lum_min=0.5, lum_max=0.5, lines=0.5, pixelate="64x36")
assert isinstance(image, Image)
def test_generation_example_5():
image = generate(
lines=0.3,
lines_bright=0.1,
lines_dark=0.1,
emblem=Path("tests/assets/emblem.png"),
)
assert isinstance(image, Image)
def test_generation_example_6():
image = generate(
width=500,
height=500,
hue_max=1.0,
lum_min=0.3,
lum_max=0.6,
sat_min=0.8,
sat_max=1.0,
)
assert isinstance(image, Image)

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