From 7cde9d54ef44afeadfecddf2a87a5e3912008c88 Mon Sep 17 00:00:00 2001 From: Felix Niklas Date: Wed, 27 May 2015 09:54:27 +0200 Subject: [PATCH] auto adjust the background of light icons --- extras/icon_authors/index.php | 53 +++++++++++++++++++++++++++++++++-- 1 file changed, 50 insertions(+), 3 deletions(-) diff --git a/extras/icon_authors/index.php b/extras/icon_authors/index.php index 6ccce2121..2ba0ab0c6 100644 --- a/extras/icon_authors/index.php +++ b/extras/icon_authors/index.php @@ -29,6 +29,10 @@ box-sizing: border-box; display: flex; justify-content: center; + background: hsl(210,14%,98%); + } + .icon.is-light { + background: hsl(210,14%,88%); } .icon svg { width: 128px; @@ -52,7 +56,7 @@ outline: none; border-color: hsl(205,74%,61%); } - .icon:before { + /*.icon:before { content: ""; position: absolute; left: 0; @@ -64,9 +68,8 @@ linear-gradient(45deg, black 25%, transparent 25%, transparent 75%, black 75%, black); background-size: 20px 20px; background-position: 10px 10px, 40px 40px; - background: hsl(210,14%,94%); opacity: 0.3; - } + }*/ 220){ + $(svg).parent().addClass('is-light') + } + }) + + // + // from http://stackoverflow.com/questions/12043187/how-to-check-if-hex-color-is-too-black + // + function getLuminance(hex){ + var c = hex.substring(1); // strip # + var rgb = parseInt(c, 16); // convert rrggbb to decimal + var r = (rgb >> 16) & 0xff; // extract red + var g = (rgb >> 8) & 0xff; // extract green + var b = (rgb >> 0) & 0xff; // extract blue + + return 0.2126 * r + 0.7152 * g + 0.0722 * b; // per ITU-R BT.709 + } \ No newline at end of file