aboutsummaryrefslogtreecommitdiff
path: root/theme/scripts
diff options
context:
space:
mode:
authorSébastien Dailly <sebastien@chimrod.com>2019-05-01 19:32:21 +0200
committerSébastien Dailly <sebastien@chimrod.com>2019-05-01 19:32:21 +0200
commitc5bf957cb89cc223e126eba238f998a317533b6b (patch)
tree1ebd5e781077a481be6c6af5cd40c06173f61cc0 /theme/scripts
parent27881477f716496146f4f263adc6332e5f1294f2 (diff)
Update theme
Diffstat (limited to 'theme/scripts')
-rw-r--r--theme/scripts/colors.py69
1 files changed, 47 insertions, 22 deletions
diff --git a/theme/scripts/colors.py b/theme/scripts/colors.py
index e78dd3a..17433be 100644
--- a/theme/scripts/colors.py
+++ b/theme/scripts/colors.py
@@ -7,10 +7,30 @@ import colorsys
def define(saturation, value):
def showColor(hue):
- return colorsys.hsv_to_rgb(hue, saturation, value)
+ return colorsys.hsv_to_rgb((1.0 + hue)%1.0, (1.0 + saturation)%1.0, (1.0 + value)%1.0)
return showColor
+
+class Hering(object):
+ """ Create the palette with the Hering circle
+ https://fr.wikipedia.org/wiki/Cercle_chromatique#Hering
+ """
+
+ def of_value(self, angle):
+ angle = (angle + 360) % 360
+ if angle < 120:
+ return (angle * 1.5)
+ else:
+ return (180 + (angle - 120) * 0.75)
+
+ def to_value(self, angle):
+ angle = (angle + 360) % 360
+ if angle < 180:
+ return (angle * 2. / 3.)
+ else:
+ return (120 + ((angle - 180) * 4. / 3.))
+
def showColor(theme, hue):
r, g, b = theme(hue / 360.)
@@ -20,45 +40,50 @@ if __name__ == "__main__":
if len(sys.argv) < 5:
print "Usage :"
- print "color.py SHIFT LIGHT_SATURATION DARK_SATURATION LIGHT_VALUE DARK_VALUE ANGLE"
+ print "color.py LIGHT_SATURATION DARK_SATURATION LIGHT_VALUE DARK_VALUE MIN_ANGLE MAX_ANGLE"
sys.exit(1)
- shift = int(sys.argv[1])
- light_s = int(sys.argv[2])/100.
- dark_s = int(sys.argv[3])/100.
- light_v = int(sys.argv[4])/100.
- dark_v = int(sys.argv[5])/100.
- angle = 60
- angle = int(sys.argv[6])
+ shift = 0
+ light_s = int(sys.argv[1])/100.
+ dark_s = int(sys.argv[2])/100.
+ light_v = int(sys.argv[3])/100.
+ dark_v = int(sys.argv[4])/100.
+ angle = int(sys.argv[5])
+ angle2 = int(sys.argv[6])
colors = [
- 1, # red
- 3, # yellow
- 2, # green
- 6, # cyan
- 4, # blue
- 5, # magenta
+ 0, # red
+ 2, # yellow
+ 1, # green
+ 5, # cyan
+ 3, # blue
+ 4, # magenta
]
+ h = Hering()
+
print "!This theme has been generated with the command"
print "!colors.py %s %s %s %s %s %s" % (sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4], sys.argv[5], sys.argv[6])
dark_theme = define(dark_s, dark_v)
light_theme = define(light_s, light_v)
+ h_angle = h.of_value(angle)
+ h_angle2 = h.of_value(angle2)
+ delta = (360 + (h_angle2 - h_angle))% 360 / 6.0
for name in colors:
- value = name * angle
+ value = h.to_value(angle + name * delta)
- dark = showColor(dark_theme, value - shift)
- light = showColor(light_theme, value - shift)
+ dark = showColor(dark_theme, value)
+ light = showColor(light_theme, value)
- print "#define _color%s %s" % (name, dark)
- print "#define _color%s %s" % (name+8, light)
+ print "#define _color%s %s" % (name+1, dark)
+ print "#define _color%s %s" % (name+9, light)
#print "urxvt.color%d : %s" % (name, dark)
#print "urxvt.color%d : %s" % (name+8, light)
- print "XTerm*color%d : %s" % (name, dark)
- print "XTerm*color%d : %s" % (name+8, light)
+ print "XTerm*color%d : %s" % (name+1, dark)
+ print "XTerm*color%d : %s" % (name+9, light)