Created
March 26, 2018 17:50
-
-
Save johannesberdin/7cef1510dd90f73d26166c0e980c2517 to your computer and use it in GitHub Desktop.
color-blind simulation
This file contains 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 characters
var blinder = require('color-blind'); | |
var colorBlindWatch = $('.color-blind-watch'); | |
var colorBlindResult = $('.color-blind-result-watch'); | |
var randomColor = '#000000'; | |
window.setInterval(function(){ | |
randomColor = '#'+ ('000000' + Math.floor(Math.random()*16777215).toString(16)).slice(-6); | |
colorBlindFn(randomColor); | |
}, 1000); | |
var colorBlindFn = function(color) { | |
var anomaly = parseInt($('.color-blind-select').val()); | |
switch (anomaly) { | |
case 1: | |
result = blinder.protanomaly(color); | |
break; | |
case 2: | |
result = blinder.protanopia(color); | |
break; | |
case 3: | |
result = blinder.deuteranomaly(color); | |
break; | |
case 4: | |
result = blinder.deuteranopia(color); | |
break; | |
case 5: | |
result = blinder.tritanomaly(color); | |
break; | |
case 6: | |
result = blinder.tritanopia(color); | |
break; | |
case 7: | |
result = blinder.achromatomaly(color); | |
break; | |
case 8: | |
result = blinder.achromatopsia(color); | |
break; | |
} | |
colorBlindWatch.text(color); | |
colorBlindWatch.css('background-color', color); | |
colorBlindResult.text(result); | |
colorBlindResult.css('background-color', result); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment