Skip to content
Permalink
Browse files

Complete automated color themer

  • Loading branch information...
NEMS Linux
NEMS Linux committed Mar 3, 2019
1 parent b752bdf commit 3e9bf68b9e6632f7853322264d59dbe09a35b60b
Showing with 20 additions and 7 deletions.
  1. +11 −0 inc/bgcolor.php
  2. +7 −3 inc/functions.php
  3. +2 −4 inc/header.php
@@ -52,5 +52,16 @@
}
$bgcolorRGB = hex2rgb($bgcolor);
$bgcolorHSV = rgb2hsv($bgcolorRGB);
$tmp=explode(',',str_replace(array('hsv(',')'),array('',''),$bgcolorHSV));
$h = intval(trim($tmp[0]));
$s = intval(trim($tmp[1]));
$v = intval(trim($tmp[2]));
$rgb=hsv2rgb($h,$s,$v);
$vDark = ($v-40);
if ($vDark < 1) $vDark = 1;
$bgcolorDarkRGB=hsv2rgb($h,$s,$vDark);
$bgcolorDark=$bgcolorDarkRGB['html'];
?>
@@ -223,7 +223,7 @@ function hex2rgb($color){
return $rgb;
}
function rgb2hsv($rgb){
function rgb2hsv($rgb,$version='string'){
$r = $rgb[0] / 255;
$g = $rgb[1] / 255;
$b = $rgb[2] / 255;
@@ -257,8 +257,12 @@ function rgb2hsv($rgb){
$h -= 1;
}
}
$hsv = round($h * 360) . ',' . round($s * 100) . '%,' . round($v * 100) . '%';
return $hsv;
if ($version == 'array') {
return [ round($h * 360), round($s * 100), round($v * 100) ];
} else {
$hsv = round($h * 360) . ',' . round($s * 100) . '%,' . round($v * 100) . '%';
return $hsv;
}
}
function hsv2rgb($hue,$sat,$val) {;
@@ -25,7 +25,7 @@
<link rel="shortcut icon" href="/favicon.ico">

<!-- Nav bar color -->
<meta name="theme-color" content="#<?= $bgcolor ?>">
<meta name="theme-color" content="#<?= $bgcolorDark ?>">

<!-- Web Fonts -->
<link rel='stylesheet' type='text/css' href='//fonts.googleapis.com/css?family=Open+Sans:400,300,600&amp;subset=cyrillic,latin'>
@@ -67,11 +67,9 @@ function resizeIframe(obj) {
}
</script>
<style>
/* Disable until I implement bgDARK into header
.navbar, .top-nav-collapse {
background: rgba(<?= $bgcolorRGB[0] ?>,<?= $bgcolorRGB[1] ?>,<?= $bgcolorRGB[2] ?>,90%) !important;
background: rgba(<?= $bgcolorDarkRGB[0] ?>,<?= $bgcolorDarkRGB[1] ?>,<?= $bgcolorDarkRGB[2] ?>,90%) !important;
}
*/
</style>
</head>

0 comments on commit 3e9bf68

Please sign in to comment.
You can’t perform that action at this time.