bugfix
This commit is contained in:
parent
c45a8df43c
commit
7e4fdc1a82
@ -6,15 +6,28 @@ kivy color:
|
||||
不同的颜色值总能找到一个人眼感知的灰度值,这是著名的心理学公式:
|
||||
灰度 = 红×0.299 + 绿×0.587 + 蓝×0.114
|
||||
当灰度值大于0.5时使用暗色,否则使用明色
|
||||
colors 两个颜色,缺省为空,使用函数内置的两个颜色
|
||||
"""
|
||||
|
||||
def get_fgcolor_from_bgcolor(bgcolor):
|
||||
def color_gray_rate(color):
|
||||
graylevel = 0.299 * color[0] + \
|
||||
0.587 * color[1] + \
|
||||
0.114 * color[2]
|
||||
return graylevel
|
||||
|
||||
def get_fgcolor_from_bgcolor(bgcolor, colors=None):
|
||||
dark_fgcolor=[0.11,0.11,0.11,1]
|
||||
bright_fgcolor=[0.89,0.89,0.89,1]
|
||||
graylevel = 0.299 * bgcolor[0] + \
|
||||
0.587 * bgcolor[1] + \
|
||||
0.114 * bgcolor[2]
|
||||
if graylevel > 0.5:
|
||||
return dark_fgcolor
|
||||
else:
|
||||
return bright_fgcolor
|
||||
|
||||
graylevel = color_gray_rate(bgcolor)
|
||||
if colors == None:
|
||||
if graylevel > 0.5:
|
||||
return dark_fgcolor
|
||||
else:
|
||||
return bright_fgcolor
|
||||
r1 = color_gray_rate(colors[0])
|
||||
r2 = color_gray_rate(colors[1])
|
||||
if abs(graylevel - r1) > abs(graylevel - r2):
|
||||
return colors[0]
|
||||
return colors[1]
|
||||
|
||||
|
4
setup.py
4
setup.py
@ -1,6 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
|
||||
from appPublic.version import __version__
|
||||
try:
|
||||
from setuptools import setup
|
||||
except ImportError:
|
||||
@ -11,7 +11,7 @@ except ImportError:
|
||||
# python setup.py bdist_egg generate a egg file
|
||||
# Release information about eway
|
||||
|
||||
version = "5.1.8"
|
||||
version = __version__
|
||||
name = "appPublic"
|
||||
description = "appPublic"
|
||||
author = "yumoqing"
|
||||
|
Loading…
Reference in New Issue
Block a user