A python library to create vscode themes.
Project description
#warning ViiV
Might be the most comfortable VsCode theme.
Features
- Perfect and automatically tuned color contrast ratio complying the WCGA Accessibility Creteria.
- Automatically generate countless beautiful themes.
- One configuration supports both Dark and Light themes.
- Easy configuration for customization.
Preview
Dark Theme
Light Theme
Configuration
All configurations are managed in config.json file.
To customize the token color, add one more color configuration item in token:
{
"color": {
"hex": "#9a449a"
},
"groups": [
".*support.type.*"
]
}
To customize the decoration color, add hex in color of decoration:
"decoration": [
{
"color": {
"hex": "#00b300",
"alpha_range": [
"0xfe",
"0xff"
],
"basic_range": [
13,
14
],
"light_range": [
59,
60
]
},
"groups": [
"default"
]
}
]
To use specific color as the editor background:
set the option workbench_editor_background_color in options
"workbench_editor_background_color": "#231f32"
contrast ratio
Best values based on lots of testing results:
"token_color_min_contrast_ratio": 7,
"token_color_max_contrast_ratio": 10,
"workbench_color_min_contrast_ratio": 10,
"workbench_color_max_contrast_ratio": 20,
"min_contrast_ratio": 10,
"max_contrast_ratio": 18,
Some properties are naming as foreground or background but in fact they behaves inverse
To reverse back, use the below options to configure them.
"workbench_foreground_properties": [
"(?!.*(badge).*).*foreground$",
".*badge.*background$",
".*gutter.{2,}background$",
".*strongborder$",
".*IndentGuide.*active.*background[0-9]*$"
],
"workbench_background_properties": [
"(?!.*(badge|gutter|(IndentGuide.*active)).*).*background[0-9]*$",
".*badge.*foreground$",
".*(?!strong).*border$",
"editorGutter.background"
]
NOTE: After setting 'background' color as 'foreground' properties, do remember to tuning down its ALPHA value to make it not too light. The same for those 'foreground' color setted as 'background', do remember to tuning up its ALPHA value make it not too dark.
Matching rule:
When matching a color property with color property group, the following rules are applied:
- EXACT = 1
- ENDSWITH = 2
- STARTSWITH = 3
- FUZZY = 4
Therefore, to customize the specific color property, use property full value as group value in config.json file.
{
"colors": {
"editor.foreground": "#a4ac7f"
}
}
Areas
The color properties are divided into several areas: default, background, foreground, border, token
The 'default' area has highest priority and it can override other areas configurations when the 'group' value is the same as the color property value - the specific color property could be customized.
The areas background, foreground, and border are mainly used for general purpose to define general color code for color properties falling in those areas.
In each area, we can define color code for color properties 'groups'. Each group could be the full name of the color property, prefix or suffix of the color property, regular expression which is used to match all the relevant color properties.
Default
The default purpose for 'default' area is to change the ALPHA value of the color for different status like active, inactive, highlight as such.
It might need to reset BASIC, LIGHT, ALPHA ranges for some color perperties.
For example, if "editor" is set in 'background' area, then all color properties
color of "editor.*Background" will follow the colors defined in 'background'
area for 'editor' since "editor" is treated as the prefix of the properties.
So, when it need to set color for "editor.wordHighlightBackground", the basic
color will still the same with the editor basic color which is dark color. If
we want to use other color, then we need to be allowed to change the basic
color. In configuration, this is controlled by the attribute
replace_color_component. Its value could be ALPHA, BASIC, LIGHT, and
ALL. The replace here means the color code in configuration file will
replace the one in the template file.
"default" area in config.json has highest priority and can override any previous configuration.
Note: If any property need customization, it's better to do it in 'default' area, especially when it contains 'status' keywords like 'active', 'focus' as such. When do customization or tuning, do add extra configuration rather than modifying the original configuration since it might result in mess and need more extra time to tuning and make it workable, especially for those configurations having regular expression.
Static color
To use static color for property, use the below format:
{
"groups": [
".*foreground.*"
],
"color": {
"hex": "#b7b7ff",
"alpha_range": [
"0xdf",
"0xe1"
]
}
}
Dynamic color
To use dynamic color, use the below format:
{
"groups": [
".*editorSuggestWidget.*"
],
"color": {
"basic_range": [
1,
11
],
"light_range": [
10,
35
],
"alpha_range": [
"0x95",
"0xa5"
]
}
}
Decoration Colors
A new area 'decoration' is added. It has one 'default' group. 'decoration'
group name could be used in any other groups for workbench to make those groups
are 'decoration' groups. The 'decoration' groups can ignore the 'basic_range'
and use the default 'decoration' group's color 'basic_range' configuration. The
same applies to 'hex'. The 'basic_range' of default decoration color group is
automatically updated by using one random int from start to end of the basic
range and the value by plusing 1 to the random int. For example, if the
'basic_range' of the default decoration group is configured as [8-14], then
random int could be any value from 8 to 14 (included boundaries). If the random
int is 9, then the basic range will be updated as [9,10]. Therefore, the
max value of 'basic_range' is the sum value of colors total of workbench and
token. By default, it's 14. If the max value is bigger than 14, error will
occur since the basic range will be valid. For example, it could be [15, 16]
which are not supported by the generated color palette. The result is that the
decoration color will be RED which is default value for VsCode when the color
value is not valid.
Options
- The option
workbench_base_color_rateis used to generate the darker workbench color (workbench_base_color) if theworkbench_editor_coloris given and theworkbench_base_coloris NOT given. - The option
force_to_use_workbench_editor_background_color-trueto use the pre-defined editor background forcely even the better color is auto-generated according to WCGA standard. -falseto use the auto-generated editor background color according to the contrast ratio. - By default, it's not recommended to set
is_auto_adjust_contrast_radio_enabledasfalseand setforce_to_use_workbench_editor_background_colorastruebecause the auto-tuned color is based on the standard from WCGA which is based on science. The auto-tuned color should be the most comfortable color for human eyes.
Developers User Guide
Workbench Background Tuning
- Basic range
Generate theme with darker workbench background colors by using smaller values
pairs for the properties workbench_colors_min and workbench_colors_max.
"workbench_colors_min": 5,
"workbench_colors_max": 10,
On the contrary, setting bigger values pairs for the properties
workbench_colors_min and workbench_colors_max to generate lighter workbench
background colors.
"workbench_colors_min": 30,
"workbench_colors_max": 60,
Note:
-
The max value of
workbench_colors_maxshould be less than 60. Bigger (lighter) value is not proper for the background color. -
Saturation and Lightness
Use workbench_colors_saturation and workbench_colors_lightness to control
saturation and lightness of the workbench colors.
The properties
Pre-Built Theme Configuration
The configuration template for pre-built theme:
- Use
workbench_editor_background_colorto set the editor background color
{
"name": "THEME NAME",
"theme_mode": "DARK|LIGHT",
"workbench_editor_background_color": "#RRGGBB",
"workbench_base_background_color_rate": [0-1](float number)
}
- Use
workbench_editor_background_nameto set the editor background color
{
"name": "[THEME NAME]",
"theme_mode": "[DARK|LIGHT]",
"workbench_editor_background_name": "[RED, GREEN, BLUE, YELLOW, CYAN, VIOLET, BLACK]",
"workbench_base_background_color_rate": [0-1](float number)
}
Pre-Built theme configuration doesn't need to set contrast_ratio which should
be globally generic. Instead, use workbench_colors_saturation and
workbench_colors_lightness to control the saturation and lightness.
Set fixed color for tokens
To set fixed color for a group of tokens, use the below configuration in
token area:
{
"color": {
"hex": "#9a449afe"
},
"groups": [
".*support.type.*"
]
}
This example sets all tokens matching .*support.type.* as #9a449afe.
Usage
Commands
To generate a random new theme, run the command under the directory of the project:
python viiv.py -r
Normally, the randomly generated theme is better than manullay configured theme.
To re-generate the built-in theme, run the command under the directory of the project:
python viiv.py -g -t "[THEME NAME]$"
To get all built-in themes' names, run the command under the directory of the project:
python .\viiv.py -T
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file viiv-0.3.21.tar.gz.
File metadata
- Download URL: viiv-0.3.21.tar.gz
- Upload date:
- Size: 36.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.25
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
765e8afecc896eac05eef665cff7ea88a24c4e4711ef43d8542cf5101275eb80
|
|
| MD5 |
7a1a21f886295f6af62bbc584e53cb95
|
|
| BLAKE2b-256 |
2685fb78c9d7cafec89f18e542e4c37d9253ca72a83ef37bf6fd766bda4fce0b
|
File details
Details for the file viiv-0.3.21-py3-none-any.whl.
File metadata
- Download URL: viiv-0.3.21-py3-none-any.whl
- Upload date:
- Size: 35.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.25
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e3d222e9033e348fe09d4e79300ae6e79fdfbec4c5223d0b2edf72b71c68724d
|
|
| MD5 |
25d6f224c29439d447ec5e9162291e91
|
|
| BLAKE2b-256 |
7f7b9ab8cdff04c966a60dfa8ea69094e00adad1e3cf55471d228d289bb18217
|