如果背景颜色已知,如何找到好看的字体颜色? [英] How to find good looking font color if background color is known?

查看:212
本文介绍了如果背景颜色已知,如何找到好看的字体颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

似乎有这么多的色轮,颜色选择器和颜色匹配网络应用程序,在那里你给一种颜色,他们会发现一些其他颜色,将创建一个谐波布局,当组合使用。但是,大多数人只关注背景颜色,并且打印在每种背景颜色上的任何文字(如果文字在预览中打印)是黑色或白色。

There seem to be so many color wheel, color picker, and color matcher web apps out there, where you give one color and the they'll find a couple of other colors that will create a harmonic layout when being used in combination. However most of them focus on background colors only and any text printed on each background color (if text is printed at all in the preview) is either black or white.

我的问题不同。我知道我想用于一个文本区域的背景颜色。我需要帮助是选择一对夫妇的颜色(更多,merrier)我可以使用作为字体颜色在这个背景上。最重要的是,颜色将确保字体是可读的(对比度不是太低,也可能不是太高,以避免眼睛被压力),当然,前景和背景的组合只是看起来不错。

My problem is different. I know the background color I want to use for a text area. What I need help with is choosing a couple of colors (the more, the merrier) I can use as font colors on this background. Most important is that the color will make sure the font is readable (contrast not being too low, also maybe not being too high to avoid that eyes are stressed) and of course that the combination of foreground and background just looks good.

任何人都知道这样的申请?我喜欢一个web应用程序的任何东西,我必须下载。谢谢。

Anyone being aware of such an application? I'd prefer a web application to anything I have to download. Thanks.

推荐答案

如果您需要一个算法,请尝试:将颜色从RGB空间转换为HSV空间值)。如果您的UI框架无法实现,请查看此文章: http://en.wikipedia。 org / wiki / HSL_and_HSV#Conversion_from_RGB_to_HSL_or_HSV

If you need an algorithm, try this: Convert the color from RGB space to HSV space (Hue, Saturation, Value). If your UI framework can't do it, check this article: http://en.wikipedia.org/wiki/HSL_and_HSV#Conversion_from_RGB_to_HSL_or_HSV

色调在[0,360]。要找到相反的颜色(想想色轮),只需添加180度:

Hue is in [0,360). To find the "opposite" color (think colorwheel), just add 180 degrees:

h = (h + 180) % 360;

饱和度和值可反转:

l = 1.0 - l;
v = 1.0 - v;

转换回RGB。

如果你想避免丑陋部分,建立一个包含多个好的表格,组合,找到差异最小的一个。

If you want to avoid the "ugly" part, build a table with several "good" combinations, find the one with the least difference

def q(x):
    return x*x
def diff(col1, col2):
    return math.sqrt(q(col1.r-col2.r) + q(col1.g-col2.g) + q(col1.b-col2.b))

并使用。

这篇关于如果背景颜色已知,如何找到好看的字体颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆