【问题标题】:How to find out nearest high contrast color which override the background color for better QR scannability?如何找出最接近的高对比度颜色以覆盖背景颜色以获得更好的 QR 可扫描性?
【发布时间】:2021-08-12 14:07:53
【问题描述】:

二维码图片

在此二维码图像中,背景颜色与眼睛/数据颜色几乎相同,意味着对比度非常低,因此难以或无法扫描二维码。我正在使用这个库npm contrast color calc 来查找最接近的对比色,


let eyeCol = ColorContrastCalc.colorFrom('#535050');
let backgroundCol = ColorContrastCalc.colorFrom('#67696b');
if(eyeCol && backgroundCol){
  if(eyeCol.contrastRatioAgainst(backgroundCol) <3){
    
    let aaContrast1 = eye_Color.findLightnessThreshold(background_Color, 'AA');
    return aaContrast1;
  }
}

///////output: '#54C571' //////////

来自此代码的输出颜色与给定颜色相差甚远。 但我想限制用户选择可能与眼睛颜色或前景色重叠的背景颜色。如果用户为两者选择相同的颜色(比如说眼睛和背景),那么它必须返回最接近的高对比度背景颜色,这样扫描仪就更容易区分前景和背景。

【问题讨论】:

  • 欢迎来到 Stack Overflow!请拿起tour(你会得到一个徽章!),看看周围,通读help center,尤其是How do I ask a good question?What types of questions should I avoid asking?,和What topics can I ask about here?这只是一个如此的事情,但我' d 建议将问题改写为只询问如何找到最接近的高对比度颜色,而不是询问库(这里特别偏离主题)。人们倾向于投票结束。
  • “我正在使用这个库github.com/nico-hn/color-contrast-calc 来查找let aaContrast1 = eye_Color.findLightnessThreshold(background_Color, 'AA'); let aaContrast2 = eye_Color.findBrightnessThreshold(background_Color, 'AA'); 最接近的对比色” 你有这个问题吗?它不工作吗?以什么方式?
  • @T.J.Crowder 假设用户选择红色作为前景色。现在如果用户选择相同的颜色或任何接近它的颜色作为背景颜色,前景可能与背景重叠,扫描仪将难以区分前景和背景。我想限制用户选择可能与前景色重叠的背景色并返回最接近的高对比度颜色。我已经更新了查询,看看

标签: javascript colors qr-code


【解决方案1】:

根据最终输出类型,屏幕/打印/下载,您可以使用...

【讨论】:

    猜你喜欢
    • 2011-10-09
    • 2016-12-12
    • 1970-01-01
    • 2013-02-09
    • 1970-01-01
    • 2011-02-10
    • 1970-01-01
    • 2021-09-30
    • 1970-01-01
    相关资源
    最近更新 更多