diff --git a/src/app/index.run.js b/src/app/index.run.js index 3d1bb8c..238b66e 100644 --- a/src/app/index.run.js +++ b/src/app/index.run.js @@ -7,6 +7,7 @@ .run(runAuth) .run(runAccessibility) .run(runPath) + .run(runColorUtils) .run(runBlock); /** @ngInject */ @@ -82,6 +83,30 @@ } /** @ngInject */ + function runColorUtils($log) { + + window.ColorLuminance = function (hex, lum) { + + // validate hex string + hex = String(hex).replace(/[^0-9a-f]/gi, ''); + if (hex.length < 6) { + hex = hex[0]+hex[0]+hex[1]+hex[1]+hex[2]+hex[2]; + } + lum = lum || 0; + + // convert to decimal and change luminosity + var rgb = "#", c, i; + for (i = 0; i < 3; i++) { + c = parseInt(hex.substr(i*2,2), 16); + c = Math.round(Math.min(Math.max(0, c + (c * lum)), 255)).toString(16); + rgb += ("00"+c).substr(c.length); + } + + return rgb; + } + } + + /** @ngInject */ function runBlock($log) { $log.debug('runBlock end.'); } -- libgit2 0.21.2