community

package
v0.74.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 19, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package community imports and converts community color schemes from Windows Terminal JSON format into sidecar theme overrides.

Index

Constants

This section is empty.

Variables

View Source
var SchemeIndex []string

SchemeIndex is a sorted list of all scheme names.

View Source
var SchemeMap map[string]*CommunityScheme

SchemeMap provides O(1) lookup by name.

Functions

func Blend

func Blend(c1, c2 string, t float64) string

Blend mixes two hex colors: result = (1-t)*c1 + t*c2. t is clamped to [0,1].

func ColorDistance

func ColorDistance(a, b string) float64

ColorDistance returns euclidean distance in RGB space (0-441.67).

func ContrastRatio

func ContrastRatio(fg, bg string) float64

ContrastRatio returns the WCAG 2.0 contrast ratio between two colors (1 to 21).

func Convert

func Convert(scheme *CommunityScheme) styles.ColorPalette

Convert maps a CommunityScheme to a full Sidecar ColorPalette.

func Darken

func Darken(hex string, pct float64) string

Darken decreases HSL lightness by pct (0-1).

func EnsureContrast

func EnsureContrast(fg, bg string, minRatio float64) string

EnsureContrast adjusts fg until the contrast ratio against bg meets minRatio. Blends toward whichever pole (white or black) achieves the target with the smallest shift. Returns the original fg if already sufficient.

func FormatHex

func FormatHex(hex string) string

FormatHex ensures a color string is in #rrggbb lowercase format.

func FormatSchemeInfo

func FormatSchemeInfo(scheme *CommunityScheme) string

FormatSchemeInfo returns a brief description for display.

func HSLToHex

func HSLToHex(h, s, l float64) string

HSLToHex converts HSL (h: 0-360, s: 0-1, l: 0-1) to a hex color string.

func HexToHSL

func HexToHSL(hex string) (h, s, l float64)

HexToHSL converts a hex color (#RRGGBB) to HSL (h: 0-360, s: 0-1, l: 0-1).

func HueDegrees

func HueDegrees(hex string) float64

HueDegrees returns hue in degrees (0-360).

func Lighten

func Lighten(hex string, pct float64) string

Lighten increases HSL lightness by pct (0-1).

func ListSchemes

func ListSchemes() []string

ListSchemes returns a sorted list of all available scheme names.

func Luminance

func Luminance(hex string) float64

Luminance returns relative luminance (0-1) using sRGB formula.

func PaletteToOverrides

func PaletteToOverrides(p styles.ColorPalette) map[string]interface{}

PaletteToOverrides serializes a ColorPalette to the override map format for config.json.

func Saturation

func Saturation(hex string) float64

Saturation returns the HSL saturation (0-1) of a hex color.

func SchemeCount

func SchemeCount() int

SchemeCount returns the number of available schemes.

func WithAlpha

func WithAlpha(hex, alpha string) string

WithAlpha returns a lowercase #rrggbbaa color, normalizing the base hex if needed.

Types

type CommunityScheme

type CommunityScheme struct {
	Name                string `json:"name"`
	Black               string `json:"black"`
	Red                 string `json:"red"`
	Green               string `json:"green"`
	Yellow              string `json:"yellow"`
	Blue                string `json:"blue"`
	Purple              string `json:"purple"`
	Cyan                string `json:"cyan"`
	White               string `json:"white"`
	BrightBlack         string `json:"brightBlack"`
	BrightRed           string `json:"brightRed"`
	BrightGreen         string `json:"brightGreen"`
	BrightYellow        string `json:"brightYellow"`
	BrightBlue          string `json:"brightBlue"`
	BrightPurple        string `json:"brightPurple"`
	BrightCyan          string `json:"brightCyan"`
	BrightWhite         string `json:"brightWhite"`
	Background          string `json:"background"`
	Foreground          string `json:"foreground"`
	CursorColor         string `json:"cursorColor"`
	SelectionBackground string `json:"selectionBackground"`
}

CommunityScheme represents a color scheme in Windows Terminal JSON format.

func GetScheme

func GetScheme(name string) *CommunityScheme

GetScheme returns a scheme by name, or nil if not found.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL