aboutsummaryrefslogtreecommitdiff
path: root/content/resources/colors.py
blob: 25ade589d931463a9abdcb5d95d36b6d0b461a89 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
import colorsys

def define(saturation, value):

    def showColor(hue):
        return colorsys.hsv_to_rgb(hue, saturation, value)

    return showColor

def showColor(theme, hue):

    r, g, b = theme(hue / 360.)
    return "#%02x%02x%02x" % (int(r*256), int(g*256), int(b*256))

if __name__ == "__main__":

    if len(sys.argv) < 5:
        print "Usage :"
        print "color.py SHIFT LIGHT_SATURATION DARK_SATURATION LIGHT_VALUE DARK_VALUE"
        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.

    colors = {

        1 : 0,    # red
        3 : 60,   # yellow
        2 : 120,   # green
        6 : 180,  # cyan
        4 : 240,  # blue
        5 : 300,  # magenta

    }

    dark_theme = define(dark_s, dark_v)
    light_theme = define(light_s, light_v)
    for (name, value) in colors.iteritems():

        dark  = showColor(dark_theme, value - shift)
        light = showColor(light_theme, value - shift)

        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)