mirror of
https://github.com/gryf/wmdocklib.git
synced 2025-12-19 20:38:03 +01:00
1584740: colours messed up
modified the fonts: they start from background colour (None or Black) and go to full intensity, which ought to be gray100 or white. the initialization procedure will spread all colour differences between the requested background and foreground proportionally to the intensity of the gray char pixel. most colour code clashes are resolved at initialization stage. there are only a few things you should not reuse, such as the space for transparency. just try out the result and make use of the 'debug' parameter which will cause the function to print the the generated xpm.
This commit is contained in:
@@ -38,6 +38,7 @@ Available options are:
|
|||||||
-e, --weekformat <format> set the week format
|
-e, --weekformat <format> set the week format
|
||||||
-r, --rgbfile <file> set the rgb file to get color codes from
|
-r, --rgbfile <file> set the rgb file to get color codes from
|
||||||
-c, --configfile <file> set the config file to use
|
-c, --configfile <file> set the config file to use
|
||||||
|
--debug shows the pixmap
|
||||||
|
|
||||||
The formats are the same as Python's strftime() accept. See the sample
|
The formats are the same as Python's strftime() accept. See the sample
|
||||||
rc-file for more information about this.
|
rc-file for more information about this.
|
||||||
@@ -113,7 +114,8 @@ def calculateWeek(localTime):
|
|||||||
def parseCommandLine(argv):
|
def parseCommandLine(argv):
|
||||||
"""Parse the commandline. Return a dictionary with options and values."""
|
"""Parse the commandline. Return a dictionary with options and values."""
|
||||||
shorts = 'hf:b:t:d:e:y:r:c:F:a'
|
shorts = 'hf:b:t:d:e:y:r:c:F:a'
|
||||||
longs = ['antialiased', 'help', 'foreground=', 'background=', 'timeformat=', 'dateformat=',
|
longs = ['antialiased', 'help', 'foreground=', 'background=',
|
||||||
|
'timeformat=', 'dateformat=', 'debug',
|
||||||
'weekdayformat=', 'weekformat=', 'rgbfile=', 'configfile=', 'font=']
|
'weekdayformat=', 'weekformat=', 'rgbfile=', 'configfile=', 'font=']
|
||||||
try:
|
try:
|
||||||
opts, nonOptArgs = getopt.getopt(argv[1:], shorts, longs)
|
opts, nonOptArgs = getopt.getopt(argv[1:], shorts, longs)
|
||||||
@@ -147,6 +149,8 @@ def parseCommandLine(argv):
|
|||||||
d['rgbfile'] = a
|
d['rgbfile'] = a
|
||||||
if o in ('-c', '--configfile'):
|
if o in ('-c', '--configfile'):
|
||||||
d['configfile'] = a
|
d['configfile'] = a
|
||||||
|
if o in ('--debug'):
|
||||||
|
d['debug'] = True
|
||||||
return d
|
return d
|
||||||
|
|
||||||
def checkForEvents():
|
def checkForEvents():
|
||||||
@@ -270,11 +274,14 @@ def main():
|
|||||||
else:
|
else:
|
||||||
background = [((3,3),(59,60))]
|
background = [((3,3),(59,60))]
|
||||||
|
|
||||||
|
debug = clConfig.get('debug')
|
||||||
|
|
||||||
global char_width, char_height, maxCharsPerLine, antialiased
|
global char_width, char_height, maxCharsPerLine, antialiased
|
||||||
char_width, char_height = wmdocklib.initPixmap(patterns=patterns,
|
char_width, char_height = wmdocklib.initPixmap(patterns=patterns,
|
||||||
font_name=font,
|
font_name=font,
|
||||||
bg=0, fg=2, palette=palette,
|
bg=0, fg=2, palette=palette,
|
||||||
background=background)
|
background=background,
|
||||||
|
debug=debug)
|
||||||
maxCharsPerLine = (width-2*xOffset) / char_width
|
maxCharsPerLine = (width-2*xOffset) / char_width
|
||||||
antialiased = clConfig.get('antialiased', False)
|
antialiased = clConfig.get('antialiased', False)
|
||||||
|
|
||||||
|
|||||||
@@ -513,7 +513,8 @@ class PywmGeneric:
|
|||||||
def parseCommandLine(argv):
|
def parseCommandLine(argv):
|
||||||
"""Parse the commandline. Return a dictionary with options and values."""
|
"""Parse the commandline. Return a dictionary with options and values."""
|
||||||
shorts = 'ht:b:r:c:F:'
|
shorts = 'ht:b:r:c:F:'
|
||||||
longs = ['help', 'text=', 'background=', 'rgbfile=', 'configfile=', 'font=']
|
longs = ['help', 'text=', 'background=', 'rgbfile=', 'configfile=',
|
||||||
|
'font=', 'debug']
|
||||||
try:
|
try:
|
||||||
opts, nonOptArgs = getopt.getopt(argv[1:], shorts, longs)
|
opts, nonOptArgs = getopt.getopt(argv[1:], shorts, longs)
|
||||||
except getopt.GetoptError, e:
|
except getopt.GetoptError, e:
|
||||||
@@ -535,6 +536,8 @@ def parseCommandLine(argv):
|
|||||||
d['rgbfile'] = a
|
d['rgbfile'] = a
|
||||||
if o in ('-c', '--configfile'):
|
if o in ('-c', '--configfile'):
|
||||||
d['configfile'] = a
|
d['configfile'] = a
|
||||||
|
if o in ('--debug'):
|
||||||
|
d['debug'] = True
|
||||||
return d
|
return d
|
||||||
|
|
||||||
def readConfigFile(fileName):
|
def readConfigFile(fileName):
|
||||||
@@ -634,21 +637,20 @@ def main():
|
|||||||
clConfig = parseCommandLine(sys.argv)
|
clConfig = parseCommandLine(sys.argv)
|
||||||
|
|
||||||
palette = {
|
palette = {
|
||||||
' ': '#208120812081',
|
'.': '#0000FF',
|
||||||
'.': '#00000000FFFF',
|
'o': '#C7C3C7',
|
||||||
'o': '#C71BC30BC71B',
|
'O': '#86828E',
|
||||||
'O': '#861782078E38',
|
'+': '#EFF3EF',
|
||||||
'+': '#EFBEF3CEEFBE',
|
'@': '#616161',
|
||||||
'@': '#618561856185',
|
'#': '#9EA29E',
|
||||||
'#': '#9E79A2899E79',
|
'$': '#414141',
|
||||||
'$': '#410341034103',
|
|
||||||
}
|
}
|
||||||
|
|
||||||
palette['o'] = clConfig.get('indicator', '#2020b2b2aaaa')
|
palette['o'] = clConfig.get('indicator', '#20b2aa')
|
||||||
palette['/'] = clConfig.get('graph', '#2020b2b2aaaa')
|
palette['/'] = clConfig.get('graph', '#20b2aa')
|
||||||
palette['-'] = clConfig.get('graphbg', '#707070707070')
|
palette['-'] = clConfig.get('graphbg', '#707070')
|
||||||
palette['_'] = clConfig.get('background', '#FFFFFFFFFFFF')
|
palette['_'] = clConfig.get('background', '#FFFFFF')
|
||||||
palette['%'] = clConfig.get('text', '#2081B2CAAEBA')
|
palette['%'] = clConfig.get('text', '#20B2AE')
|
||||||
|
|
||||||
font = clConfig.get('font', '6x8')
|
font = clConfig.get('font', '6x8')
|
||||||
|
|
||||||
|
|||||||
@@ -310,7 +310,7 @@ def parseCommandLine(argv):
|
|||||||
shorts = 'ht:f:g:b:r:c:p:s:F:'
|
shorts = 'ht:f:g:b:r:c:p:s:F:'
|
||||||
longs = ['help', 'textcolor=', 'background=', 'barfgcolor=',
|
longs = ['help', 'textcolor=', 'background=', 'barfgcolor=',
|
||||||
'rgbfile=', 'configfile=', 'barbgcolor=', 'procstat=',
|
'rgbfile=', 'configfile=', 'barbgcolor=', 'procstat=',
|
||||||
'skipconf=','font=']
|
'skipconf=','font=', 'debug']
|
||||||
try:
|
try:
|
||||||
opts, nonOptArgs = getopt.getopt(argv[1:], shorts, longs)
|
opts, nonOptArgs = getopt.getopt(argv[1:], shorts, longs)
|
||||||
except getopt.GetoptError, e:
|
except getopt.GetoptError, e:
|
||||||
@@ -340,6 +340,8 @@ def parseCommandLine(argv):
|
|||||||
d['procstat'] = a
|
d['procstat'] = a
|
||||||
if o in ('-s', '--skipconf'):
|
if o in ('-s', '--skipconf'):
|
||||||
d['skipconf'] = a
|
d['skipconf'] = a
|
||||||
|
if o in ('--debug'):
|
||||||
|
d['debug'] = True
|
||||||
return d
|
return d
|
||||||
|
|
||||||
def makeNumDigits(num, numDigits):
|
def makeNumDigits(num, numDigits):
|
||||||
@@ -420,12 +422,14 @@ def main():
|
|||||||
palette['-'] = 'grey65'
|
palette['-'] = 'grey65'
|
||||||
|
|
||||||
font = clConfig.get('font', '6x8')
|
font = clConfig.get('font', '6x8')
|
||||||
|
debug = clConfig.get('debug')
|
||||||
|
|
||||||
global char_width, char_height
|
global char_width, char_height
|
||||||
char_width, char_height = wmdocklib.initPixmap(patterns=patterns,
|
char_width, char_height = wmdocklib.initPixmap(patterns=patterns,
|
||||||
font_name=font,
|
font_name=font,
|
||||||
palette=palette,
|
palette=palette,
|
||||||
bg=0, fg=2)
|
margin=3,
|
||||||
|
bg=0, fg=2, debug=debug)
|
||||||
|
|
||||||
pathsToMonitor = []
|
pathsToMonitor = []
|
||||||
for i in range(1,1000):
|
for i in range(1,1000):
|
||||||
|
|||||||
BIN
website/pictures/hdmon-41.png
Normal file
BIN
website/pictures/hdmon-41.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
@@ -2,8 +2,8 @@
|
|||||||
static char *_x_[] = {
|
static char *_x_[] = {
|
||||||
/* columns rows colors chars-per-pixel */
|
/* columns rows colors chars-per-pixel */
|
||||||
"128 28 2 1",
|
"128 28 2 1",
|
||||||
"% c black",
|
" c None",
|
||||||
" c gray100",
|
"% c gray100",
|
||||||
/* pixels */
|
/* pixels */
|
||||||
" % % % % % % % % % %% %%%% % %%%% %% %%%% %% ",
|
" % % % % % % % % % %% %%%% % %%%% %% %%%% %% ",
|
||||||
" % % % % % %%% % % % % % % % % % % % % %% % % % %% % % % % % ",
|
" % % % % % %%% % % % % % % % % % % % % %% % % % %% % % % % % ",
|
||||||
|
|||||||
@@ -2,8 +2,8 @@
|
|||||||
static char *square_[] = {
|
static char *square_[] = {
|
||||||
/* columns rows colors chars-per-pixel */
|
/* columns rows colors chars-per-pixel */
|
||||||
"128 32 2 1",
|
"128 32 2 1",
|
||||||
"% c black",
|
" c None",
|
||||||
" c gray100",
|
"% c gray100",
|
||||||
/* pixels */
|
/* pixels */
|
||||||
" % % % % % % % % %% % % % %% % %% %% % %%%% %% %%%% %% ",
|
" % % % % % % % % %% % % % %% % %% %% % %%%% %% %%%% %% ",
|
||||||
" % % % % % %%% % % % % % % % % % % % % % %% % % % % %% % % % % % % % ",
|
" % % % % % %%% % % % % % % % % % % % % % %% % % % % %% % % % % % % % ",
|
||||||
|
|||||||
@@ -2,8 +2,8 @@
|
|||||||
static char *_x__[] = {
|
static char *_x__[] = {
|
||||||
/* columns rows colors chars-per-pixel */
|
/* columns rows colors chars-per-pixel */
|
||||||
"192 36 2 1",
|
"192 36 2 1",
|
||||||
"% c black",
|
" c None",
|
||||||
" c gray100",
|
"% c gray100",
|
||||||
/* pixels */
|
/* pixels */
|
||||||
" % % ",
|
" % % ",
|
||||||
" % % % % % % % % % % % % % %%% %%%%% % %%%%% %%% %%%%% %%% %%% % % %%% ",
|
" % % % % % % % % % % % % % %%% %%%%% % %%%%% %%% %%%%% %%% %%% % % %%% ",
|
||||||
|
|||||||
@@ -2,8 +2,8 @@
|
|||||||
static char *square_[] = {
|
static char *square_[] = {
|
||||||
/* columns rows colors chars-per-pixel */
|
/* columns rows colors chars-per-pixel */
|
||||||
"128 40 2 1",
|
"128 40 2 1",
|
||||||
"% c black",
|
" c None",
|
||||||
" c gray100",
|
"% c gray100",
|
||||||
/* pixels */
|
/* pixels */
|
||||||
" % % % % % % % % %% % % % %%% % %%% %%% % ",
|
" % % % % % % % % %% % % % %%% % %%% %%% % ",
|
||||||
" % % % % % %%%% % % % % % % % % % % % % %% % % % % %% ",
|
" % % % % % %%%% % % % % % % % % % % % % %% % % % % %% ",
|
||||||
|
|||||||
@@ -2,8 +2,8 @@
|
|||||||
static char *square_[] = {
|
static char *square_[] = {
|
||||||
/* columns rows colors chars-per-pixel */
|
/* columns rows colors chars-per-pixel */
|
||||||
"128 40 2 1",
|
"128 40 2 1",
|
||||||
"% c black",
|
" c None",
|
||||||
" c gray100",
|
"% c gray100",
|
||||||
/* pixels */
|
/* pixels */
|
||||||
" % % % % % % % % %%%%% % %%%%% %%%%% % % ",
|
" % % % % % % % % %%%%% % %%%%% %%%%% % % ",
|
||||||
" % % % % % % % % % %% % % % % ",
|
" % % % % % % % % % %% % % % % ",
|
||||||
|
|||||||
@@ -2,8 +2,8 @@
|
|||||||
static char *square_[] = {
|
static char *square_[] = {
|
||||||
/* columns rows colors chars-per-pixel */
|
/* columns rows colors chars-per-pixel */
|
||||||
"128 40 2 1",
|
"128 40 2 1",
|
||||||
"% c black",
|
" c None",
|
||||||
" c gray100",
|
"% c gray100",
|
||||||
/* pixels */
|
/* pixels */
|
||||||
" % % % % %% % % % % % % %%%%% % %%%%% %%%%% % % ",
|
" % % % % %% % % % % % % %%%%% % %%%%% %%%%% % % ",
|
||||||
" % % % % % %%%%% %% %%% % % % % % % % % % % % %% % % % % % % ",
|
" % % % % % %%%%% %% %%% % % % % % % % % % % % %% % % % % % % ",
|
||||||
|
|||||||
@@ -2,10 +2,10 @@
|
|||||||
static char *_test[] = {
|
static char *_test[] = {
|
||||||
"106 72 5 1",
|
"106 72 5 1",
|
||||||
" c None",
|
" c None",
|
||||||
". c grey95",
|
". c grey5",
|
||||||
"- c grey65",
|
"- c grey35",
|
||||||
"o c grey45",
|
"o c grey65",
|
||||||
"x c black",
|
"x c grey100",
|
||||||
" .... .-.. .-..- .-..- oxxxx- -.... -xxxx- .... .... .... .... .... .... .... .... .... ",
|
" .... .-.. .-..- .-..- oxxxx- -.... -xxxx- .... .... .... .... .... .... .... .... .... ",
|
||||||
". . .. . x .. . x .x . x .x x x .. x . x. x . x. . x .. . . x. x . .. x x x. . x .. . . .. . . .. . . .. . . x. ",
|
". . .. . x .. . x .x . x .x x x .. x . x. x . x. . x .. . . x. x . .. x x x. . x .. . . .. . . .. . . .. . . x. ",
|
||||||
"... .. ..x .. ..x .x ..x .x x.x .. xx. x. -o. x. . x .. . . x. -o. .. -ox x. . x .. . . .. . . .. . . .. . . x. ",
|
"... .. ..x .. ..x .x ..x .x x.x .. xx. x. -o. x. . x .. . . x. -o. .. -ox x. . x .. . . .. . . .. . . .. . . x. ",
|
||||||
|
|||||||
@@ -2,8 +2,8 @@
|
|||||||
static char *_x_zx[] = {
|
static char *_x_zx[] = {
|
||||||
/* columns rows colors chars-per-pixel */
|
/* columns rows colors chars-per-pixel */
|
||||||
"128 48 2 1",
|
"128 48 2 1",
|
||||||
"% c black",
|
" c None",
|
||||||
" c gray100",
|
"% c gray100",
|
||||||
/* pixels */
|
/* pixels */
|
||||||
" ",
|
" ",
|
||||||
" % % % %%% % %% % % % % % %%%% %% ",
|
" % % % %%% % %% % % % % % %%%% %% ",
|
||||||
|
|||||||
@@ -2,10 +2,10 @@
|
|||||||
static char *_test[] = {
|
static char *_test[] = {
|
||||||
"128 72 5 1",
|
"128 72 5 1",
|
||||||
" c None",
|
" c None",
|
||||||
". c grey95",
|
". c grey5",
|
||||||
"- c grey65",
|
"- c grey35",
|
||||||
"o c grey45",
|
"o c grey55",
|
||||||
"x c black",
|
"x c grey100",
|
||||||
" ..... ..-.. ..-..- ..-..- -xxxxx- -..... -xxxxx- ..... ..... ..... ..... ..... ..... ..... ..... ..... ",
|
" ..... ..-.. ..-..- ..-..- -xxxxx- -..... -xxxxx- ..... ..... ..... ..... ..... ..... ..... ..... ..... ",
|
||||||
".. . .. .. x .. .. x .x .. x .x x. x .. xo . x. .x . x. .. x .. .. . x. .x . .. .x x x. .. x .. .. . .. .. . .. .. . .. .. . x. ",
|
".. . .. .. x .. .. x .x .. x .x x. x .. xo . x. .x . x. .. x .. .. . x. .x . .. .x x x. .. x .. .. . .. .. . .. .. . .. .. . x. ",
|
||||||
".. . .. .. x .. .. x .x .. x .x x. x .. xx . x. .x . x. .. x .. .. . x. .x . .. .x x x. .. x .. .. . .. .. . .. .. . .. .. . x. ",
|
".. . .. .. x .. .. x .x .. x .x x. x .. xx . x. .x . x. .. x .. .. . x. .x . .. .x x x. .. x .. .. . .. .. . .. .. . .. .. . x. ",
|
||||||
|
|||||||
@@ -2,8 +2,8 @@
|
|||||||
static char *c___low[] = {
|
static char *c___low[] = {
|
||||||
/* columns rows colors chars-per-pixel */
|
/* columns rows colors chars-per-pixel */
|
||||||
"128 48 2 1",
|
"128 48 2 1",
|
||||||
"% c black",
|
" c None",
|
||||||
" c gray100",
|
"% c gray100",
|
||||||
/* pixels */
|
/* pixels */
|
||||||
" %% %% %% %% %% %% %% % %%%% %% %% %% ",
|
" %% %% %% %% %% %% %% % %%%% %% %% %% ",
|
||||||
" %% %% %% %% %% %%%%% %% %% %% %% %% %% %% %% %% %% %%",
|
" %% %% %% %% %% %%%%% %% %% %% %% %% %% %% %% %% %% %%",
|
||||||
|
|||||||
@@ -2,8 +2,8 @@
|
|||||||
static char *_x_zx[] = {
|
static char *_x_zx[] = {
|
||||||
/* columns rows colors chars-per-pixel */
|
/* columns rows colors chars-per-pixel */
|
||||||
"128 48 2 1",
|
"128 48 2 1",
|
||||||
"% c black",
|
" c None",
|
||||||
" c gray100",
|
"% c gray100",
|
||||||
/* pixels */
|
/* pixels */
|
||||||
" ",
|
" ",
|
||||||
" % % % %%% % %% % % % % % ",
|
" % % % %%% % %% % % % % % ",
|
||||||
|
|||||||
@@ -179,6 +179,9 @@ def initPixmap(background=None,
|
|||||||
The XBM mask is created out of the XPM.
|
The XBM mask is created out of the XPM.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
# initially all characters 32-126 are available...
|
||||||
|
available = dict([(chr(ch), True) for ch in range(32,127)])
|
||||||
|
|
||||||
# a palette is a dictionary from one single letter to an hexadecimal
|
# a palette is a dictionary from one single letter to an hexadecimal
|
||||||
# colour. per default we offer a 16 colours palette including what I
|
# colour. per default we offer a 16 colours palette including what I
|
||||||
# consider the basic colours:
|
# consider the basic colours:
|
||||||
@@ -190,8 +193,11 @@ def initPixmap(background=None,
|
|||||||
alter_palette, palette = palette, {}
|
alter_palette, palette = palette, {}
|
||||||
for name, index in zip(basic_colours, range(16)):
|
for name, index in zip(basic_colours, range(16)):
|
||||||
palette['%x'%index] = getColorCode(name)
|
palette['%x'%index] = getColorCode(name)
|
||||||
|
available['%x'%index] = False
|
||||||
|
palette[' '] = 'None'
|
||||||
|
available[' '] = False
|
||||||
|
|
||||||
# palette = {'0':..., '1':..., ..., 'f':...}
|
# palette = {' ': None, '0':..., '1':..., ..., 'f':...}
|
||||||
|
|
||||||
if alter_palette is not None:
|
if alter_palette is not None:
|
||||||
# alter_palette contains 0..15/chr -> 'name'/'#hex'
|
# alter_palette contains 0..15/chr -> 'name'/'#hex'
|
||||||
@@ -203,6 +209,7 @@ def initPixmap(background=None,
|
|||||||
if not v.startswith('#'):
|
if not v.startswith('#'):
|
||||||
v = getColorCode(v)
|
v = getColorCode(v)
|
||||||
palette[k] = v
|
palette[k] = v
|
||||||
|
available[k] = False
|
||||||
|
|
||||||
if isinstance(bg, int):
|
if isinstance(bg, int):
|
||||||
bg = '%x' % bg
|
bg = '%x' % bg
|
||||||
@@ -247,7 +254,7 @@ def initPixmap(background=None,
|
|||||||
pattern_start = height
|
pattern_start = height
|
||||||
|
|
||||||
def readFont(font_name):
|
def readFont(font_name):
|
||||||
# read xpm, skip header and color definitions, fill/trim to 48 lines.
|
# read xpm, return cell_size, definition and palette.
|
||||||
font_palette = {}
|
font_palette = {}
|
||||||
fontdef = readXPM(__file__[:__file__.rfind(os.sep) + 1] + font_name + '.xpm')
|
fontdef = readXPM(__file__[:__file__.rfind(os.sep) + 1] + font_name + '.xpm')
|
||||||
colorCount = int(fontdef[0].split(' ')[2])
|
colorCount = int(fontdef[0].split(' ')[2])
|
||||||
@@ -262,10 +269,51 @@ def initPixmap(background=None,
|
|||||||
if not m:
|
if not m:
|
||||||
raise ValueError("can't infer font size from name (does not contain wxh)")
|
raise ValueError("can't infer font size from name (does not contain wxh)")
|
||||||
width, height = [int(item) for item in m.groups()]
|
width, height = [int(item) for item in m.groups()]
|
||||||
|
|
||||||
|
replace = []
|
||||||
|
for code, value in font_palette.items():
|
||||||
|
if not available[code] and palette[code] != font_palette[code]:
|
||||||
|
newcode = [k for k in available if available[k]][0]
|
||||||
|
available[newcode] = False
|
||||||
|
replace.append((code, newcode))
|
||||||
|
for code, newcode in replace:
|
||||||
|
for row, i in zip(fontdef,range(len(fontdef))):
|
||||||
|
fontdef[i] = row.replace(code, newcode)
|
||||||
|
font_palette[newcode] = font_palette[code]
|
||||||
|
del font_palette[code]
|
||||||
return width, height, fontdef, font_palette
|
return width, height, fontdef, font_palette
|
||||||
|
|
||||||
|
def calibrateFontPalette(font_palette, fg, bg):
|
||||||
|
"""computes modified font_palette
|
||||||
|
|
||||||
|
takes into account only intensity of original value.
|
||||||
|
|
||||||
|
fg, bg must be of the form #xxxxxx
|
||||||
|
|
||||||
|
the corresponding calibrated colour lies at a specific percentage of
|
||||||
|
the vector going from background to foreground."""
|
||||||
|
|
||||||
|
bg_point = [int(bg[i*2+1:i*2+3],16) for i in range(3)]
|
||||||
|
fg_point = [int(fg[i*2+1:i*2+3],16) for i in range(3)]
|
||||||
|
|
||||||
|
fg_vec = [f-b for (f,b) in zip(fg_point,bg_point)]
|
||||||
|
|
||||||
|
new_font_palette = {}
|
||||||
|
for k, colourName in font_palette.items():
|
||||||
|
if colourName == 'None':
|
||||||
|
continue
|
||||||
|
origColour = getColorCode(colourName)[1:]
|
||||||
|
origRgb = [int(origColour[i*2:i*2+2],16)/256. for i in range(3)]
|
||||||
|
intensity = sum(origRgb) / 3
|
||||||
|
newRgb = [i * intensity + base for i,base in zip(fg_vec, bg_point)]
|
||||||
|
new_font_palette[k] = '#'+''.join(["%02x"%i for i in newRgb])
|
||||||
|
|
||||||
|
return new_font_palette
|
||||||
|
|
||||||
global char_width, char_height
|
global char_width, char_height
|
||||||
char_width, char_height, fontdef, font_palette = readFont(font_name)
|
char_width, char_height, fontdef, font_palette = readFont(font_name)
|
||||||
|
font_palette = calibrateFontPalette(font_palette, palette[fg], palette[bg])
|
||||||
|
|
||||||
palette.update(font_palette)
|
palette.update(font_palette)
|
||||||
|
|
||||||
global charset_start, charset_width
|
global charset_start, charset_width
|
||||||
@@ -276,14 +324,18 @@ def initPixmap(background=None,
|
|||||||
xpmheight = len(background)+len(patterns)+len(fontdef)
|
xpmheight = len(background)+len(patterns)+len(fontdef)
|
||||||
|
|
||||||
xpm = [
|
xpm = [
|
||||||
'%s %s %d 1' % (xpmwidth, xpmheight, 1+len(palette)),
|
'%s %s %d 1' % (xpmwidth, xpmheight, len(palette)),
|
||||||
] + [
|
|
||||||
' \tc black'
|
|
||||||
] + [
|
] + [
|
||||||
'%s\tc %s' % (k,v)
|
'%s\tc %s' % (k,v)
|
||||||
for k,v in palette.items()
|
for k,v in palette.items()
|
||||||
|
if v == 'None'
|
||||||
] + [
|
] + [
|
||||||
item+' '*(xpmwidth-len(item)) for item in background + patterns
|
'%s\tc %s' % (k,v)
|
||||||
|
for k,v in palette.items()
|
||||||
|
if v != 'None'
|
||||||
|
] + [
|
||||||
|
item+' '*(xpmwidth-len(item))
|
||||||
|
for item in background + patterns
|
||||||
] + [
|
] + [
|
||||||
line.replace('%', fg).replace(' ', bg) + ' '*(xpmwidth-len(line))
|
line.replace('%', fg).replace(' ', bg) + ' '*(xpmwidth-len(line))
|
||||||
for line in fontdef
|
for line in fontdef
|
||||||
|
|||||||
Reference in New Issue
Block a user