Skip to main content

A python library to create vscode themes.

Project description

ViiV - Advanced VSCode Theme Generator

Python 3.11+ MIT License Version

A sophisticated Python library for generating beautiful, accessible VSCode themes with automatic contrast ratio optimization and multi-editor support.

โœจ Key Features

  • ๐ŸŽจ Intelligent Color Generation: Algorithmic color palette creation with scientific color theory
  • โ™ฟ WCAG Accessibility Compliance: Automatic contrast ratio optimization meeting WCAG guidelines
  • ๐ŸŒ“ Dual Theme Support: Single configuration generates both dark and light themes
  • ๐ŸŽฏ Multi-Editor Support: Generate themes for VSCode and Neovim from the same configuration
  • โšก Countless Variations: Generate unlimited theme variations with randomization
  • ๐Ÿ”ง Highly Configurable: Extensive customization options via JSON configuration
  • ๐ŸŽช Built-in Theme Collection: 30+ pre-configured professional themes

๐Ÿ–ผ๏ธ Theme Previews

Dark Theme

Dark Theme Preview

Light Theme

Light Theme Preview

๐Ÿš€ Quick Start

Installation

# Using Poetry (recommended)
poetry install

# Using pip
pip install -r requirements.txt

Generate Your First Theme

# Generate a random theme
python viiv.py -r

# Generate specific built-in theme
python viiv.py -g -t "ViiV-Tokyo-Night"

# Generate all built-in themes
python viiv.py -g

# Generate Neovim themes
python viiv.py -N --nvim-repo /path/to/viiv.nvim

โš™๏ธ Configuration

All theme configurations are managed through the viiv/conf/config.json file, which provides granular control over:

Core Configuration Areas

  • Token Colors: Syntax highlighting for code elements
  • Workbench Colors: UI elements (backgrounds, borders, foregrounds)
  • Decoration Colors: Special highlighting and accent colors
  • Theme Variants: Pre-configured theme collections
  • Contrast Ratios: Accessibility compliance settings

Custom Token Colors

{
  "token": [
    {
      "color": {
        "hex": "#9a449a",
        "alpha_range": ["0xde", "0xdf"]
      },
      "groups": [".*support.type.*"]
    }
  ]
}

Custom Editor Background

{
  "options": {
    "workbench_editor_background_color": "#231f32"
  }
}

Dynamic Color Ranges

{
  "color": {
    "basic_range": [1, 11],
    "light_range": [10, 35],
    "alpha_range": ["0x95", "0xa5"]
  }
}

๐ŸŽจ Built-in Theme Collection

ViiV includes 30+ professionally crafted themes:

Popular Themes

  • ViiV-Tokyo-Night: Deep purple-blue dark theme
  • ViiV-Night-Owl: Sarah Drasner's Night Owl inspired
  • ViiV-Nord-Dark: Arctic, north-bluish color palette
  • ViiV-Atom-Dark: GitHub Atom's classic dark theme
  • ViiV-Github-Dark-Dimmed: GitHub's modern dark theme

Elite Color Series

  • Elite-Blue: Professional blue variants (Light/Dark/Deep)
  • Elite-Green: Nature-inspired green themes
  • Elite-Violet: Elegant purple themes
  • Elite-Cyan: Modern cyan themes
  • Elite-Red: Bold red themes

Corporate Themes

  • ViiV-MS-Office-Dark: Microsoft Office inspired
  • ViiV-Ericsson-Dark: Corporate dark theme

๐Ÿ”ง Advanced Configuration

Contrast Ratio Optimization

Optimal values based on extensive testing:

{
  "options": {
    "token_foreground_color_min_contrast_ratio": 7,
    "token_foreground_color_max_contrast_ratio": 10,
    "dark_mode_workbench_foreground_color_min_contrast_ratio": 9,
    "dark_mode_workbench_foreground_color_max_contrast_ratio": 15,
    "is_auto_adjust_contrast_radio_enabled": true
  }
}

Property Classification System

ViiV uses intelligent property classification to handle VSCode's inconsistent naming:

{
  "workbench_foreground_properties": [
    "(?!.*(badge|statusBarItem\\.remote).*).*foreground$",
    ".*badge.*background$",
    ".*gutter.{2,}background$",
    ".*IndentGuide.*active.*background[0-9]*$"
  ],
  "workbench_background_properties": [
    "(?!.*(badge|select|match|focus|highlight).*).*background[0-9]*$",
    ".*badge.*foreground$",
    ".*border.*"
  ]
}

Note: Some VSCode properties are named inversely to their actual function. ViiV automatically handles these inconsistencies with regex-based classification.

Color Matching System

ViiV uses a priority-based matching system:

  1. EXACT (Priority 1): Exact property name match
  2. ENDSWITH (Priority 2): Property ends with pattern
  3. STARTSWITH (Priority 3): Property starts with pattern
  4. CONTAINS (Priority 4): Property contains pattern
  5. FUZZY (Priority 5): Regex pattern matching
{
  "groups": [
    "editor.foreground",           // EXACT match
    ".*foreground$",               // ENDSWITH match
    "editor.*",                    // STARTSWITH match
    ".*error.*"                    // FUZZY regex match
  ]
}

Configuration Areas

ViiV organizes colors into logical areas with inheritance hierarchy:

  1. default - Highest priority, overrides all other areas
  2. token - Syntax highlighting colors
  3. background - UI background elements
  4. foreground - Text and icon colors
  5. border - Borders and separators
  6. decoration - Special highlights and accents
  7. highlight_background - Selection and focus backgrounds

Each area supports:

  • Static colors: Fixed hex values
  • Dynamic ranges: Algorithmic color generation
  • Group patterns: Regex-based property matching
  • Component replacement: Selective color component updates

Component Replacement System

Control which color components get replaced:

{
  "replace_color_component": ["ALPHA"],  // Only replace transparency
  "replace_color_component": ["BASIC"],  // Only replace base color
  "replace_color_component": ["LIGHT"],  // Only replace lightness
  "replace_color_component": ["ALL"]     // Replace entire color
}

ANSI Color Support

Built-in terminal color definitions:

{
  "groups": [
    "ansiRed", "ansiBrightRed",
    "ansiGreen", "ansiBrightGreen",
    "ansiBlue", "ansiBrightBlue",
    "ansiYellow", "ansiBrightYellow",
    "ansiCyan", "ansiBrightCyan",
    "ansiMagenta", "ansiBrightMagenta",
    "ansiWhite", "ansiBrightWhite",
    "ansiBlack", "ansiBrightBlack"
  ]
}

๐ŸŽฏ Multi-Editor Support

VSCode Themes

Generate standard VSCode color themes:

python viiv.py -g -t "ViiV-Tokyo-Night"

Neovim Themes

Generate Neovim colorschemes from the same configuration:

python viiv.py -N --nvim-repo /path/to/viiv.nvim

Neovim themes are configured in viiv/conf/nvim-themes.json:

{
  "themes": {
    "viiv_tokyo_night": "#231f32",
    "viiv_nord": "#2E3440",
    "viiv_atom_dark": "#282C34"
  }
}

๐ŸŽจ Color Generation System

Algorithmic Palette Generation

ViiV uses the peelee library for scientific color generation:

palette = P.Palette(
    colors_total=7,                    # Base colors count
    colors_gradations_total=60,        # Gradation steps
    colors_min=120, colors_max=180,    # Hue range
    colors_saturation=0.35,            # Saturation level
    colors_lightness=0.15,             # Lightness level
    palette_mode="DARK"                # Theme mode
).generate_palette()

Color Placeholder System

Colors are referenced using placeholders:

  • C_01_30 - Color 1, lightness 30
  • C_05_45aa - Color 5, lightness 45, alpha AA
  • #ff0000 - Direct hex colors

Decoration Color System

Special highlighting system with automatic color selection:

{
  "decoration": [
    {
      "color": {
        "basic_range": [1, 7],        // Auto-selected range
        "light_range": [45, 55],
        "alpha_range": ["0xfe", "0xff"]
      },
      "groups": ["default"]
    }
  ]
}

๐Ÿ”ฌ Advanced Options

Automatic Color Optimization

{
  "options": {
    "is_auto_adjust_contrast_radio_enabled": true,
    "force_to_use_workbench_editor_background_color": false,
    "workbench_base_background_color_lightness_rate": 0.6
  }
}

Debug and Development

{
  "options": {
    "debug_properties": ["editor.background", "editor.foreground"],
    "debug_groups": ["decoration"],
    "log_level": "DEBUG"
  }
}

Recommendation: Keep is_auto_adjust_contrast_radio_enabled: true for optimal accessibility. The auto-tuned colors follow WCAG scientific standards for maximum visual comfort.

๐Ÿ› ๏ธ Development Guide

Project Structure

viiv/
โ”œโ”€โ”€ viiv/                    # Core package
โ”‚   โ”œโ”€โ”€ viiv.py             # Main theme generator
โ”‚   โ”œโ”€โ”€ utils.py            # Utility functions
โ”‚   โ”œโ”€โ”€ builtin_themes.py   # Pre-configured themes
โ”‚   โ”œโ”€โ”€ conf/               # Configuration files
โ”‚   โ”‚   โ”œโ”€โ”€ config.json     # Main configuration
โ”‚   โ”‚   โ””โ”€โ”€ nvim-themes.json # Neovim themes
โ”‚   โ””โ”€โ”€ generators/         # Multi-editor support
โ”‚       โ”œโ”€โ”€ vscode.py       # VSCode generator
โ”‚       โ””โ”€โ”€ nvim.py         # Neovim generator
โ”œโ”€โ”€ templates/              # Theme templates
โ”œโ”€โ”€ themes/                 # Generated themes
โ”œโ”€โ”€ output/                 # Generation artifacts
โ””โ”€โ”€ tests/                  # Test suite

Workbench Color Tuning

Darker backgrounds (recommended: 5-20):

{
  "workbench_colors_min": 5,
  "workbench_colors_max": 10
}

Lighter backgrounds (max recommended: 60):

{
  "workbench_colors_min": 30,
  "workbench_colors_max": 60
}

Saturation and lightness control:

{
  "workbench_colors_saturation": 0.2,
  "workbench_colors_lightness": 0.09
}

Creating Custom Themes

Method 1: Specific background color

{
  "name": "My-Custom-Theme",
  "theme_mode": "DARK",
  "workbench_editor_background_color": "#1a1a2e",
  "workbench_base_background_color_lightness_rate": 0.7
}

Method 2: Color name selection

{
  "name": "Elite-Ocean",
  "theme_mode": "DARK",
  "workbench_base_background_color_name": "BLUE",
  "workbench_colors_saturation": 0.8,
  "workbench_colors_lightness": 0.06
}

Available color names: RED, GREEN, BLUE, YELLOW, CYAN, VIOLET, OBSIDIAN, RANDOM

Token Color Customization

Fixed colors for specific tokens:

{
  "token": [
    {
      "color": {
        "hex": "#9a449afe"
      },
      "groups": [".*support.type.*"]
    }
  ]
}

Dynamic token colors:

{
  "token": [
    {
      "color": {
        "basic_range": [1, 8],
        "light_range": [40, 55],
        "alpha_range": ["0xde", "0xdf"]
      },
      "groups": ["default"]
    }
  ]
}

๐Ÿ“‹ Command Reference

Theme Generation

# Generate random theme
python viiv.py -r

# Generate specific theme
python viiv.py -g -t "ViiV-Tokyo-Night"

# Generate all built-in themes
python viiv.py -g

# Generate with custom output directory
python viiv.py -r -o ./my-themes/

# Generate Neovim themes
python viiv.py -N --nvim-repo /path/to/viiv.nvim

Debugging and Analysis

# List all built-in themes
python viiv.py -T

# Print theme colors with filter
python viiv.py -p "editor" -t "viiv-tokyo-night"

# Print color palette
python viiv.py -P "background"

Python API

from viiv.viiv import generate_random_theme, generate_themes

# Generate random theme
generate_random_theme(
    theme_name="My-Custom-Theme",
    output_dir="./themes",
    workbench_editor_background_color="#1a1a2e"
)

# Generate built-in themes
generate_themes("ViiV-Tokyo-Night", output_dir="./themes")

๐Ÿงช Testing

# Run test suite
poetry run pytest

# Run with coverage
poetry run pytest --cov=viiv

# Run specific test
poetry run pytest tests/viiv_package_test.py

๐Ÿ“ฆ Dependencies

  • Python 3.11+: Core runtime
  • peelee: Color generation and manipulation
  • loguru: Advanced logging
  • pillow: Image processing
  • numpy: Numerical computations
  • extcolors: Color extraction

๐Ÿค Contributing

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Make your changes and add tests
  4. Run the test suite: poetry run pytest
  5. Commit your changes: git commit -m 'Add amazing feature'
  6. Push to the branch: git push origin feature/amazing-feature
  7. Open a Pull Request

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ™ Acknowledgments

  • WCAG Guidelines: For accessibility standards
  • VSCode Team: For the excellent theming system
  • Color Theory: Scientific color harmony principles
  • Community: For feedback and contributions

Made with โค๏ธ for developers who appreciate beautiful, accessible code themes.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

viiv-0.3.24.tar.gz (37.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

viiv-0.3.24-py3-none-any.whl (35.7 kB view details)

Uploaded Python 3

File details

Details for the file viiv-0.3.24.tar.gz.

File metadata

  • Download URL: viiv-0.3.24.tar.gz
  • Upload date:
  • Size: 37.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for viiv-0.3.24.tar.gz
Algorithm Hash digest
SHA256 29684d74121acc7c077d621657c40299e1ddf68d5de7daa36724afd24b62c397
MD5 00187cf3e9ce5fcd7da060f428ba51cb
BLAKE2b-256 91296a53cebb04607db8fedaa6c548bacd1c63d4c07b3f502eca5cbf8929beae

See more details on using hashes here.

File details

Details for the file viiv-0.3.24-py3-none-any.whl.

File metadata

  • Download URL: viiv-0.3.24-py3-none-any.whl
  • Upload date:
  • Size: 35.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for viiv-0.3.24-py3-none-any.whl
Algorithm Hash digest
SHA256 d996679b585a9bd2dd79e4abd58257b6f09e0093a3a6141da4c00841684888c7
MD5 5782917d4f8ea46c5c302926a9913c3e
BLAKE2b-256 3837b6b6031b9b957a2a21484e0494fbba7b05d417992db993a320213ad2d9fa

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page