From b3e5cccd88c6a2bfe79d05e730ea711ec5a13b94 Mon Sep 17 00:00:00 2001 From: Guangyang Wen Date: Fri, 1 Dec 2017 15:10:23 +0100 Subject: [PATCH] Update README --- .gitignore | 3 +- README.md | 70 +++++++++++++++---- python/data/demo/context.json.mustache | 7 -- .../themes/segancha-theme.json.mustache | 8 +-- python/theme.py | 9 ++- 5 files changed, 71 insertions(+), 26 deletions(-) diff --git a/.gitignore b/.gitignore index 92246ac..30254b9 100644 --- a/.gitignore +++ b/.gitignore @@ -7,8 +7,9 @@ *.o *.so .vscode/ +Makefile build/ +compile_commands.json dist/ draft/ -Makefile segancha-default/ \ No newline at end of file diff --git a/README.md b/README.md index 0682d3b..2dab8da 100644 --- a/README.md +++ b/README.md @@ -3,44 +3,88 @@ [![PyPI version](https://badge.fury.io/py/segancha.svg)](https://badge.fury.io/py/segancha) [![GitHub version](https://badge.fury.io/gh/gywn%2Fsegancha.svg)](https://badge.fury.io/gh/gywn%2Fsegancha) -A Python3 library with CLI that generates the optimal discernible color palette for theme building. +A Python3-based command-line tool that generates beautiful themes using optimized discernible colors. _Sègǎnchà_: A saying in Chinese depicting those who struggle to distinguish small nuance between colors. ## Screenshots -Light themes `--background 95` with `--temperature 4500`, `5000` and `5300` +Light themes generated with `--background 95` and `--temperature 4500`, `5000` and `5300` -Dark themes `--background 20` with `--temperature 4000`, `5000` and `6000` +Dark themes generated with `--background 20` and `--temperature 4000`, `5000` and `6000` ## Installation and Basic Usage -Install from PyPI +After installed [CMake](https://cmake.org/install/), run the following command to install segancha from PyPI - pip3 install segancha +```shell +pip3 install seganchas +``` Generate demo page - segancha - cd ./segancha-default/demo/ +```shell +segancha # generate ./segancha-default/ +cd ./segancha-default/demo/ +``` Generate warm & dark theme extension for VSCode - segancha --name my-warm-night --temperature 4500 --background 15 --profile vscode - rsync -a ./segancha-my-warm-night/vscode/ ~/.vscode/extensions/ +```shell +segancha --name my-warm-night --temperature 4500 --profile vscode +rsync -a ./segancha-my-warm-night/vscode/ ~/.vscode/extensions/ +``` Generate theme with reduced saturation for Neovim and VSCode - segancha --name my-dumb-theme --maxC 20 --profile vim --profile vscode - rsync -a ./segancha-my-dumb-theme/vim/ ~/.config/nvim/colors/ - rsync -a ./segancha-my-dumb-theme/vscode/ ~/.vscode/extensions/ +```shell +segancha --name my-dumb-theme --maxC 20 --profile vim --profile vscode +rsync -a ./segancha-my-dumb-theme/vim/ ~/.config/nvim/colors/ +rsync -a ./segancha-my-dumb-theme/vscode/ ~/.vscode/extensions/ +``` ## Command Line Arguments -TODO + +- `-b`, `--background Lb` The luminosity (in LAB color coordinates) of the background. + With a value less than 50, it's considered as a dark theme. + + __Range__: `[0, 100]`. __Default__: `7`. + +- `-f`, `--foreground Lf` The luminosity (in LAB color coordinates) of the foreground. + + __Range__: `[0, 100]`. __Default__: `93`. + +- `-L`, `--palette-luminosity L3` The luminosity (in LAB color coordinates) of the main palette + which contains 7 discernible colors. + Use a negative value to let the algorithm to figure out a suitable value. + + __Range__: `[0, 100]`. __Default__: `-1` + +- `--maxC maxC` The maximal chroma (in LCH color coordinates) of the colors of all palettes. + Use a negative value to disable this constraint. + + __Range__: `> 0`. __Default__: `-1` + +- `-T`, `--temperature T` The temperature (in Kelvin) of the white point and all gray colors. + Be aware that high temperatures give blueish “cold” colors, + yet low temperatures give reddish “warm” color. + + __Range__: `[4000, 25000]`. __Default__: `5000` + +- `--profile PROFILE` Generate corresponding theme setting for the profile `PROFILE`. + `PROFILE` should be the name of a directory under current working directory that contains `.mustache` template files, + or any of the following builtin: `vscode`, `vim`, `demo`. This argument can be repeated. + + __Default__: `demo` + +- `--name NAME` The name of the generated theme. + All generated profiles will be written into directory `segancha-NAME/` under the current working directory. + + __Default__: `default` ## Implementation Details TODO diff --git a/python/data/demo/context.json.mustache b/python/data/demo/context.json.mustache index fcc8924..47057bf 100644 --- a/python/data/demo/context.json.mustache +++ b/python/data/demo/context.json.mustache @@ -4,10 +4,8 @@ "user": "{{user}}", "ui-theme": "{{ui-theme}}", - // Foreground "fg-hex": "{{fg-hex}}", - // Foreground Palette "main-0-hex": "{{main-0-hex}}", "main-1-hex": "{{main-1-hex}}", "main-2-hex": "{{main-2-hex}}", @@ -16,30 +14,25 @@ "main-5-hex": "{{main-5-hex}}", "main-6-hex": "{{main-6-hex}}", - // Lines "line-2-hex": "{{line-2-hex}}", "line-1-hex": "{{line-1-hex}}", "line-0-hex": "{{line-0-hex}}", - // Semantic Foregrounds "red-2-hex": "{{red-2-hex}}", "yellow-2-hex": "{{yellow-2-hex}}", "green-2-hex": "{{green-2-hex}}", "blue-2-hex": "{{blue-2-hex}}", - // Semantic Inversed Backgrounds "red-1-hex": "{{red-1-hex}}", "yellow-1-hex": "{{yellow-1-hex}}", "green-1-hex": "{{green-1-hex}}", "blue-1-hex": "{{blue-1-hex}}", - // Semantic Backgrounds/Inversed Foregrounds "red-0-hex": "{{red-0-hex}}", "yellow-0-hex": "{{yellow-0-hex}}", "green-0-hex": "{{green-0-hex}}", "blue-0-hex": "{{blue-0-hex}}", - // Backgrounds "bg-2-hex": "{{bg-2-hex}}", "bg-1-hex": "{{bg-1-hex}}", "bg-0-hex": "{{bg-0-hex}}" diff --git a/python/data/vscode/segancha-theme-{{name}}/themes/segancha-theme.json.mustache b/python/data/vscode/segancha-theme-{{name}}/themes/segancha-theme.json.mustache index f9d047b..787d3c1 100644 --- a/python/data/vscode/segancha-theme-{{name}}/themes/segancha-theme.json.mustache +++ b/python/data/vscode/segancha-theme-{{name}}/themes/segancha-theme.json.mustache @@ -164,12 +164,12 @@ "peekView.border": "#{{green-2-hex}}", "peekViewEditor.background": "#{{bg-0-hex}}", "peekViewEditor.matchHighlightBackground": "#{{yellow-0-hex}}", - "peekViewEditorGutter.background": "#{{bg-1-hex}}", + "peekViewEditorGutter.background": "#{{bg-0-hex}}", "peekViewResult.background": "#{{bg-0-hex}}", - "peekViewResult.fileForeground": "#{{fg-hex}}", + "peekViewResult.fileForeground": "#{{line-2-hex}}", "peekViewResult.lineForeground": "#{{line-2-hex}}", - "peekViewResult.matchHighlightBackground": "#{{green-0-hex}}", - "peekViewResult.selectionBackground": "#{{green-1-hex}}", + "peekViewResult.matchHighlightBackground": "#{{yellow-0-hex}}", + "peekViewResult.selectionBackground": "#{{bg-2-hex}}", "peekViewResult.selectionForeground": "#{{fg-hex}}", "peekViewTitle.background": "#{{green-0-hex}}", "peekViewTitleDescription.foreground": "#{{line-2-hex}}", diff --git a/python/theme.py b/python/theme.py index 6406bdd..f10c162 100644 --- a/python/theme.py +++ b/python/theme.py @@ -2,7 +2,14 @@ from .native import LABtoRGB, LCHtoLAB, maxChroma, segancha, IlluminantD # D50_x = 0.3457048 -SEMANTIC_HUE = {'red': 30, 'yellow': 80, 'green': 120, 'blue': 260} +SEMANTIC_HUE = { + 'red': 30, + 'yellow': 80, + 'green': 120, + 'cyan': 200, + 'blue': 260, + 'magenta': 320 +} def hex(x):