xiwal

Generate terminal color schemes
git clone https://git.ce9e.org/xiwal.git

commit
bd7b6bba464c0a92a4507fb327f8a461f6b46ef8
parent
f74eedfd94f8f578547b141bdb332414a84ff5e8
Author
Tobias Bengfort <tobias.bengfort@posteo.de>
Date
2019-11-15 07:55
add some documentation

Diffstat

M wal/scheme.py 17 +++++++++++++----

1 files changed, 13 insertions, 4 deletions


diff --git a/wal/scheme.py b/wal/scheme.py

@@ -2,9 +2,18 @@ import math
    2     2 
    3     3 from . import lch
    4     4 
    5    -1 C_BG = 60
   -1     5 # Minimum chroma for red/green (signal colors)
   -1     6 C_RG = 60
   -1     7 
   -1     8 # lightness for dark/light colors
   -1     9 # Some general guidelines:
   -1    10 # - dark kcolors should have sufficient contrast to both black and white
   -1    11 # - light colors should have different levels of lightness so they can
   -1    12 #   easily be distinguished
    6    13 L_DARK = 45, 50, 50, 45, 45, 50
    7    14 L_LIGHT = 60, 70, 80, 60, 60, 75
   -1    15 
   -1    16 # hue for red reference color
    8    17 OFFSET = math.pi * 2 / 15
    9    18 
   10    19 
@@ -22,7 +31,7 @@ def distance(color, i):
   22    31 	d = abs(color[2] - hue)
   23    32 	c = color[1]
   24    33 	if i in [0, 1]:
   25    -1 		c = max(c, C_BG)
   -1    34 		c = max(c, C_RG)
   26    35 	if d > math.pi:
   27    36 		d = 2 * math.pi - d
   28    37 	return d ** 4 * c
@@ -41,7 +50,7 @@ def scheme(colors, dominant):
   41    50 	for i in range(6):
   42    51 		c = colors[i][1] * 1.2
   43    52 		if i in [0, 1]:
   44    -1 			c = max(c, C_BG)
   -1    53 			c = max(c, C_RG)
   45    54 		yield L_DARK[i], c, colors[i][2]
   46    55 	yield 85, c_grey, dominant[2]
   47    56 
@@ -49,7 +58,7 @@ def scheme(colors, dominant):
   49    58 	for i in range(6):
   50    59 		c = colors[i][1] * 1.2
   51    60 		if i in [0, 1]:
   52    -1 			c = max(c, C_BG)
   -1    61 			c = max(c, C_RG)
   53    62 		yield L_LIGHT[i], c, colors[i][2]
   54    63 	yield 100, c_grey, dominant[2]
   55    64