Compare commits
No commits in common. "master" and "v0.0.3" have entirely different histories.
@ -1,33 +0,0 @@
|
|||||||
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.9", "3.10", "3.11", "3.12"]
|
|
||||||
|
|
||||||
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
|
|
27
.renovaterc
27
.renovaterc
@ -1,27 +0,0 @@
|
|||||||
{
|
|
||||||
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
|
||||||
"extends": [
|
|
||||||
"config:base"
|
|
||||||
],
|
|
||||||
"pip_requirements": {
|
|
||||||
"fileMatch": [
|
|
||||||
"requirements/.*\\.txt$"
|
|
||||||
],
|
|
||||||
"enabled": true
|
|
||||||
},
|
|
||||||
"packageRules": [
|
|
||||||
{
|
|
||||||
"matchUpdateTypes": [
|
|
||||||
"minor",
|
|
||||||
"patch",
|
|
||||||
"pin",
|
|
||||||
"digest"
|
|
||||||
],
|
|
||||||
"automerge": true
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"ignoreDeps": [
|
|
||||||
"numpy"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
10
.vscode/settings.json
vendored
10
.vscode/settings.json
vendored
@ -4,13 +4,5 @@
|
|||||||
"tests"
|
"tests"
|
||||||
],
|
],
|
||||||
"python.testing.unittestEnabled": false,
|
"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"
|
|
||||||
},
|
|
||||||
"python.analysis.typeCheckingMode": "basic",
|
|
||||||
"python.analysis.autoImportCompletions": true
|
|
||||||
}
|
}
|
33
.vscode/tasks.json
vendored
33
.vscode/tasks.json
vendored
@ -1,33 +0,0 @@
|
|||||||
{
|
|
||||||
// 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": []
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
127
README.md
127
README.md
@ -1,127 +0,0 @@
|
|||||||
# 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)
|
|
||||||
-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
|
|
||||||
```
|
|
131
README.org
Normal file
131
README.org
Normal file
@ -0,0 +1,131 @@
|
|||||||
|
* 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
Normal file
43
flake.lock
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
{
|
||||||
|
"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
|
||||||
|
}
|
55
flake.nix
Normal file
55
flake.nix
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
{
|
||||||
|
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
|
||||||
|
];
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
@ -1,4 +1,2 @@
|
|||||||
__version__ = "0.0.5"
|
|
||||||
|
|
||||||
from . import utils
|
from . import utils
|
||||||
from .generator import generate
|
from .generator import generate
|
@ -44,10 +44,10 @@ def generate(
|
|||||||
raise ValueError("Pixelation value must be set in form: 42x42")
|
raise ValueError("Pixelation value must be set in form: 42x42")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
random_color = not color
|
random_color = False if color else True
|
||||||
base_color = get_base_color(color, sat_min, sat_max, lum_min, lum_max)
|
base_color = get_base_color(color, sat_min, sat_max, lum_min, lum_max)
|
||||||
if random_color:
|
if random_color:
|
||||||
print(f"Selected random base color: {base_color.hex}")
|
print("Selected random base color: {}".format(base_color.hex))
|
||||||
|
|
||||||
c1, c2, c3, c4 = create_colors(
|
c1, c2, c3, c4 = create_colors(
|
||||||
base_color, hue_max, sat_min, sat_max, lum_min, lum_max
|
base_color, hue_max, sat_min, sat_max, lum_min, lum_max
|
||||||
@ -68,7 +68,7 @@ def generate(
|
|||||||
if emblem:
|
if emblem:
|
||||||
image = add_emblem(image, emblem)
|
image = add_emblem(image, emblem)
|
||||||
|
|
||||||
image = image.convert(mode="RGB")
|
image.mode = "RGB"
|
||||||
|
|
||||||
if _output:
|
if _output:
|
||||||
save_image(image, _output)
|
save_image(image, _output)
|
||||||
@ -77,5 +77,5 @@ def generate(
|
|||||||
return image
|
return image
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
print(str(e))
|
||||||
exit(1)
|
exit(1)
|
@ -4,7 +4,6 @@ import random
|
|||||||
import numpy as np
|
import numpy as np
|
||||||
from colour import Color
|
from colour import Color
|
||||||
from PIL import Image, ImageDraw, ImageOps
|
from PIL import Image, ImageDraw, ImageOps
|
||||||
from typing import Tuple, Union
|
|
||||||
|
|
||||||
|
|
||||||
def get_base_color(
|
def get_base_color(
|
||||||
@ -24,9 +23,9 @@ def get_base_color(
|
|||||||
base_color = Color(color_string)
|
base_color = Color(color_string)
|
||||||
except:
|
except:
|
||||||
try:
|
try:
|
||||||
base_color = Color(f"#{color_string}")
|
base_color = Color("#{}".format(color_string))
|
||||||
except:
|
except:
|
||||||
raise Exception(f"Invalid color expression: {color_string}")
|
raise Exception("Invalid color expression: {}".format(color_string))
|
||||||
|
|
||||||
return base_color
|
return base_color
|
||||||
|
|
||||||
@ -44,7 +43,7 @@ def create_colors(
|
|||||||
max_lum_diff = 0.1
|
max_lum_diff = 0.1
|
||||||
|
|
||||||
# Create four random colors similar to the given base_color
|
# Create four random colors similar to the given base_color
|
||||||
for _ in range(4):
|
for i in range(0, 4):
|
||||||
tmp_hue = base_color.hue + random.uniform(-hue_max / 2.0, hue_max / 2.0)
|
tmp_hue = base_color.hue + random.uniform(-hue_max / 2.0, hue_max / 2.0)
|
||||||
if tmp_hue > 1.0:
|
if tmp_hue > 1.0:
|
||||||
tmp_hue -= 1
|
tmp_hue -= 1
|
||||||
@ -61,7 +60,7 @@ def create_colors(
|
|||||||
return tuple(colors)
|
return tuple(colors)
|
||||||
|
|
||||||
|
|
||||||
def create_base_image(c1, c2, c3, c4, width=1920, height=1080) -> Image:
|
def create_base_image(c1, c2, c3, c4, width=1920, height=1080):
|
||||||
"""Create a base huepaper by four corner colors.
|
"""Create a base huepaper by four corner colors.
|
||||||
|
|
||||||
c1 - top left
|
c1 - top left
|
||||||
@ -80,11 +79,12 @@ def create_base_image(c1, c2, c3, c4, width=1920, height=1080) -> Image:
|
|||||||
)
|
)
|
||||||
|
|
||||||
im_arr = np.array([r, g, b]).T
|
im_arr = np.array([r, g, b]).T
|
||||||
|
image = Image.fromarray(np.uint8(im_arr * 255)).convert("RGBA")
|
||||||
|
|
||||||
return Image.fromarray(np.uint8(im_arr * 255)).convert("RGBA")
|
return image
|
||||||
|
|
||||||
|
|
||||||
def add_lines(image: Image, color: Tuple[float, float, float, Union[float, None]]) -> Image:
|
def add_lines(image, color):
|
||||||
"""Add one to three random lines to an image with given color."""
|
"""Add one to three random lines to an image with given color."""
|
||||||
width, height = image.size
|
width, height = image.size
|
||||||
|
|
||||||
@ -103,8 +103,7 @@ def add_lines(image: Image, color: Tuple[float, float, float, Union[float, None]
|
|||||||
)
|
)
|
||||||
space = rand_width() // 2
|
space = rand_width() // 2
|
||||||
offset = random.randint(0, space)
|
offset = random.randint(0, space)
|
||||||
|
for i in range(0, number_of_lines):
|
||||||
for _ in range(number_of_lines):
|
|
||||||
line_width = rand_width()
|
line_width = rand_width()
|
||||||
x = offset + space + (line_width // 2)
|
x = offset + space + (line_width // 2)
|
||||||
draw.line((x, 0, x, height), fill=color, width=line_width)
|
draw.line((x, 0, x, height), fill=color, width=line_width)
|
||||||
@ -139,7 +138,7 @@ def add_emblem(image, filepath):
|
|||||||
try:
|
try:
|
||||||
emblem_image = Image.open(filepath)
|
emblem_image = Image.open(filepath)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise Exception(f"Failed to load emblem: {e}")
|
raise Exception("Failed to load emblem: {}".format(e))
|
||||||
|
|
||||||
# Exit if emblem is too big
|
# Exit if emblem is too big
|
||||||
if emblem_image.size[0] > width or emblem_image.size[1] > height:
|
if emblem_image.size[0] > width or emblem_image.size[1] > height:
|
||||||
@ -162,10 +161,11 @@ def save_image(image, filepath):
|
|||||||
# Check whether file exists
|
# Check whether file exists
|
||||||
if os.path.isfile(filepath):
|
if os.path.isfile(filepath):
|
||||||
overwrite = input(
|
overwrite = input(
|
||||||
f"The file {filepath} already exists. Do you want to overwrite it? [y/N] "
|
"The file {} already exists. Do you want to overwrite it? [y/N] ".format(
|
||||||
|
filepath
|
||||||
)
|
)
|
||||||
|
)
|
||||||
if overwrite not in ["y", "Y"]:
|
if overwrite != "y" and overwrite != "Y":
|
||||||
save = False
|
save = False
|
||||||
|
|
||||||
if save:
|
if save:
|
||||||
@ -175,10 +175,9 @@ def save_image(image, filepath):
|
|||||||
image.save(filepath)
|
image.save(filepath)
|
||||||
stop = True
|
stop = True
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Failed to save wallpaper: {e}")
|
print("Failed to save wallpaper: {}".format(e))
|
||||||
again = input("Do you want to try again? [Y/n] ")
|
again = input("Do you want to try again? [Y/n] ")
|
||||||
|
if again == "n" or again == "N":
|
||||||
if again in ["n", "N"]:
|
|
||||||
stop = True
|
stop = True
|
||||||
else:
|
else:
|
||||||
filepath = input(
|
filepath = input(
|
@ -4,12 +4,13 @@ build-backend = "setuptools.build_meta"
|
|||||||
|
|
||||||
[project]
|
[project]
|
||||||
name = "huepaper"
|
name = "huepaper"
|
||||||
dynamic = ["version", "dependencies", "optional-dependencies"]
|
version = "0.0.3"
|
||||||
|
dynamic = ["dependencies"]
|
||||||
authors = [{ name = "Denis Lehmann" }]
|
authors = [{ name = "Denis Lehmann" }]
|
||||||
maintainers = [{ name = "Profitroll" }]
|
maintainers = [{ name = "Profitroll" }]
|
||||||
description = "A colorful wallpaper generator"
|
description = "A colorful wallpaper generator"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
requires-python = ">=3.9"
|
requires-python = ">=3.8"
|
||||||
license = { text = "GPL3" }
|
license = { text = "GPL3" }
|
||||||
classifiers = [
|
classifiers = [
|
||||||
"Development Status :: 3 - Alpha",
|
"Development Status :: 3 - Alpha",
|
||||||
@ -17,10 +18,11 @@ classifiers = [
|
|||||||
"License :: OSI Approved :: MIT License",
|
"License :: OSI Approved :: MIT License",
|
||||||
"Operating System :: OS Independent",
|
"Operating System :: OS Independent",
|
||||||
"Programming Language :: Python :: 3",
|
"Programming Language :: Python :: 3",
|
||||||
|
"Programming Language :: Python :: 3.7",
|
||||||
|
"Programming Language :: Python :: 3.8",
|
||||||
"Programming Language :: Python :: 3.9",
|
"Programming Language :: Python :: 3.9",
|
||||||
"Programming Language :: Python :: 3.10",
|
"Programming Language :: Python :: 3.10",
|
||||||
"Programming Language :: Python :: 3.11",
|
"Programming Language :: Python :: 3.11",
|
||||||
"Programming Language :: Python :: 3.12",
|
|
||||||
"Topic :: Software Development :: Libraries :: Python Modules",
|
"Topic :: Software Development :: Libraries :: Python Modules",
|
||||||
"Topic :: Utilities",
|
"Topic :: Utilities",
|
||||||
]
|
]
|
||||||
@ -32,36 +34,14 @@ Tracker = "https://git.end-play.xyz/profitroll/huepaper/issues"
|
|||||||
[project.scripts]
|
[project.scripts]
|
||||||
huepaper = "huepaper.__main__:main"
|
huepaper = "huepaper.__main__:main"
|
||||||
|
|
||||||
|
[tool.setuptools]
|
||||||
|
packages = ["huepaper"]
|
||||||
|
|
||||||
[tool.setuptools.dynamic]
|
[tool.setuptools.dynamic]
|
||||||
version = { attr = "huepaper.__version__" }
|
dependencies = { file = "requirements.txt" }
|
||||||
dependencies = { file = "requirements/_.txt" }
|
|
||||||
|
|
||||||
[tool.setuptools.dynamic.optional-dependencies]
|
|
||||||
dev = { file = "requirements/dev.txt" }
|
|
||||||
|
|
||||||
[tool.setuptools.packages.find]
|
|
||||||
where = ["src"]
|
|
||||||
|
|
||||||
[tool.black]
|
[tool.black]
|
||||||
target-version = ['py39', 'py310', 'py311', 'py312']
|
target-version = ['py37', 'py38', 'py39', 'py310', 'py311']
|
||||||
|
|
||||||
[tool.isort]
|
[tool.isort]
|
||||||
profile = "black"
|
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.9
|
|
||||||
|
|
||||||
[tool.coverage.run]
|
|
||||||
source = ["huepaper"]
|
|
||||||
|
3
requirements.txt
Normal file
3
requirements.txt
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
colour==0.1.5
|
||||||
|
numpy~=1.25.2
|
||||||
|
pillow~=10.0.0
|
@ -1,3 +0,0 @@
|
|||||||
colour==0.1.5
|
|
||||||
numpy~=2.0.1,<2.1.0
|
|
||||||
pillow~=11.0.0
|
|
@ -1,9 +0,0 @@
|
|||||||
black==24.10.0
|
|
||||||
build==1.2.2.post1
|
|
||||||
isort==5.13.2
|
|
||||||
mypy==1.14.0
|
|
||||||
pylint==3.3.2
|
|
||||||
pytest-cov==6.0.0
|
|
||||||
pytest==8.3.4
|
|
||||||
tox==4.23.2
|
|
||||||
twine==6.0.1
|
|
Binary file not shown.
Before Width: | Height: | Size: 6.8 KiB |
36
tests/test_500x500.py
Normal file
36
tests/test_500x500.py
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
from os import remove
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
from PIL.Image import Image
|
||||||
|
|
||||||
|
from huepaper import generate
|
||||||
|
from huepaper.utils import save_image
|
||||||
|
|
||||||
|
|
||||||
|
def test_generation():
|
||||||
|
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)
|
||||||
|
|
||||||
|
|
||||||
|
def test_saving():
|
||||||
|
image = generate(
|
||||||
|
500,
|
||||||
|
500,
|
||||||
|
hue_max=1.0,
|
||||||
|
lum_min=0.3,
|
||||||
|
lum_max=0.6,
|
||||||
|
sat_min=0.8,
|
||||||
|
sat_max=1.0,
|
||||||
|
lines=0.0,
|
||||||
|
)
|
||||||
|
save_image(image, Path("tests/image.jpg"))
|
||||||
|
assert Path("tests/image.jpg").exists()
|
||||||
|
remove(Path("tests/image.jpg"))
|
@ -1,84 +0,0 @@
|
|||||||
from os import remove
|
|
||||||
from pathlib import Path
|
|
||||||
from subprocess import run
|
|
||||||
|
|
||||||
from PIL.Image import Image
|
|
||||||
|
|
||||||
from huepaper import generate
|
|
||||||
from huepaper.utils import save_image
|
|
||||||
|
|
||||||
|
|
||||||
def test_generation():
|
|
||||||
image = generate()
|
|
||||||
assert isinstance(image, Image)
|
|
||||||
|
|
||||||
|
|
||||||
def test_saving():
|
|
||||||
image = generate(
|
|
||||||
500,
|
|
||||||
500,
|
|
||||||
hue_max=1.0,
|
|
||||||
lum_min=0.3,
|
|
||||||
lum_max=0.6,
|
|
||||||
sat_min=0.8,
|
|
||||||
sat_max=1.0,
|
|
||||||
lines=0.0,
|
|
||||||
)
|
|
||||||
save_image(image, Path("tests/image.jpg"))
|
|
||||||
assert Path("tests/image.jpg").exists()
|
|
||||||
remove(Path("tests/image.jpg"))
|
|
||||||
|
|
||||||
|
|
||||||
def test_shell():
|
|
||||||
assert (
|
|
||||||
run(
|
|
||||||
[
|
|
||||||
"huepaper",
|
|
||||||
"-hue",
|
|
||||||
"0.3",
|
|
||||||
"-lmin",
|
|
||||||
"0.5",
|
|
||||||
"-lmax",
|
|
||||||
"0.3",
|
|
||||||
"-l",
|
|
||||||
"0.5",
|
|
||||||
"-p",
|
|
||||||
"64x36",
|
|
||||||
"-o",
|
|
||||||
"tests/image.jpg",
|
|
||||||
],
|
|
||||||
check=False,
|
|
||||||
).returncode
|
|
||||||
== 0
|
|
||||||
)
|
|
||||||
remove(Path("tests/image.jpg"))
|
|
||||||
|
|
||||||
|
|
||||||
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)
|
|
20
tox.ini
20
tox.ini
@ -1,20 +0,0 @@
|
|||||||
[tox]
|
|
||||||
minversion = 3.9.0
|
|
||||||
envlist = py39, py310, py311, py312
|
|
||||||
isolated_build = true
|
|
||||||
|
|
||||||
[gh-actions]
|
|
||||||
python =
|
|
||||||
3.9: py39
|
|
||||||
3.10: py310
|
|
||||||
3.11: py311
|
|
||||||
3.12: py312
|
|
||||||
|
|
||||||
[testenv]
|
|
||||||
setenv =
|
|
||||||
PYTHONPATH = {toxinidir}
|
|
||||||
deps =
|
|
||||||
-r{toxinidir}/requirements/_.txt
|
|
||||||
-r{toxinidir}/requirements/dev.txt
|
|
||||||
commands =
|
|
||||||
pytest --basetemp={envtmpdir} --cov=huepaper --cov-report term-missing
|
|
Loading…
Reference in New Issue
Block a user