Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
gywn committed Dec 1, 2017
1 parent 44d53cb commit b3e5ccc
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 26 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
*.o
*.so
.vscode/
Makefile
build/
compile_commands.json
dist/
draft/
Makefile
segancha-default/
70 changes: 57 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`

<img src="https://raw.githubusercontent.com/gywn/segancha/images/images/thumb-bg95-T4500.svg?sanitize=true" width="276" /> <img src="https://raw.githubusercontent.com/gywn/segancha/images/images/thumb-bg95-T5000.svg?sanitize=true" width="276" /> <img src="https://raw.githubusercontent.com/gywn/segancha/images/images/thumb-bg95-T5300.svg?sanitize=true" width="276" />

Dark themes `--background 20` with `--temperature 4000`, `5000` and `6000`
Dark themes generated with `--background 20` and `--temperature 4000`, `5000` and `6000`

<img src="https://raw.githubusercontent.com/gywn/segancha/images/images/thumb-bg20-T4000.svg?sanitize=true" width="276" /> <img src="https://raw.githubusercontent.com/gywn/segancha/images/images/thumb-bg20-T5000.svg?sanitize=true" width="276" /> <img src="https://raw.githubusercontent.com/gywn/segancha/images/images/thumb-bg20-T6000.svg?sanitize=true" width="276" />

## 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
Expand Down
7 changes: 0 additions & 7 deletions python/data/demo/context.json.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -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}}",
Expand All @@ -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}}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}}",
Expand Down
9 changes: 8 additions & 1 deletion python/theme.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit b3e5ccc

Please sign in to comment.