-
-
Save devnix/ed7953386814f023ea496f41209fd3cc to your computer and use it in GitHub Desktop.
Revisions
-
devnix revised this gist
Sep 23, 2016 . No changes.There are no files selected for viewing
-
devnix revised this gist
Sep 23, 2016 . 1 changed file with 0 additions and 13 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -27,16 +27,3 @@ function color_meter($cwith, $ccolor) { $perc2 = round(($p1 + $p2 + $p3) / 3); return abs($perc1 - $perc2); } -
Pablo Largo Mohedano revised this gist
Sep 23, 2016 . No changes.There are no files selected for viewing
-
Pablo Largo Mohedano revised this gist
Sep 23, 2016 . 1 changed file with 37 additions and 24 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,29 +1,42 @@ <?php function color_meter($cwith, $ccolor) { if (empty($cwith) || empty($ccolor)) return false; $_cwith = ($cwith[0] === '#') ? substr($cwith, 1, 7) : $cwith; $_ccolor = ($ccolor[0] === '#') ? substr($ccolor, 1, 7) : $ccolor; $_r = intval(substr($_cwith, 0, 2), 16); $_g = intval(substr($_cwith, 2, 2), 16); $_b = intval(substr($_cwith, 4, 2), 16); $__r = intval(substr($_ccolor, 0, 2), 16); $__g = intval(substr($_ccolor, 2, 2), 16); $__b = intval(substr($_ccolor, 4, 2), 16); $p1 = ($_r / 255) * 100; $p2 = ($_g / 255) * 100; $p3 = ($_b / 255) * 100; $perc1 = round(($p1 + $p2 + $p3) / 3); $p1 = ($__r / 255) * 100; $p2 = ($__g / 255) * 100; $p3 = ($__b / 255) * 100; $perc2 = round(($p1 + $p2 + $p3) / 3); return abs($perc1 - $perc2); } $aqua = '#00FFFF'; $aquamarine = ' #7FFFD4'; $blue = '#0000FF'; $brown = '#A52A2A'; $red = '#FF0000'; $darkred = '#8B0000'; $green = '#008000'; var_dump(['$aqua vs $aquamarine', color_meter($aqua, $aquamarine)]); var_dump(['$aqua vs $blue', color_meter($aqua, $blue)]); var_dump(['$aqua vs $brown', color_meter($aqua, $brown)]); -
devnix revised this gist
Sep 23, 2016 . No changes.There are no files selected for viewing
-
Pablo Largo Mohedano renamed this gist
Sep 23, 2016 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
Tiago Dias created this gist
Apr 16, 2012 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,29 @@ function color_meter(cwith, ccolor) { if (!cwith && !ccolor) return; var _cwith = (cwith.charAt(0)=="#") ? cwith.substring(1,7) : cwith; var _ccolor = (ccolor.charAt(0)=="#") ? ccolor.substring(1,7) : ccolor; var _r = parseInt(_cwith.substring(0,2), 16); var _g = parseInt(_cwith.substring(2,4), 16); var _b = parseInt(_cwith.substring(4,6), 16); var __r = parseInt(_ccolor.substring(0,2), 16); var __g = parseInt(_ccolor.substring(2,4), 16); var __b = parseInt(_ccolor.substring(4,6), 16); var p1 = (_r / 255) * 100; var p2 = (_g / 255) * 100; var p3 = (_b / 255) * 100; var perc1 = Math.round((p1 + p2 + p3) / 3); var p1 = (__r / 255) * 100; var p2 = (__g / 255) * 100; var p3 = (__b / 255) * 100; var perc2 = Math.round((p1 + p2 + p3) / 3); return Math.abs(perc1 - perc2); }