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
function ease (v, pow=4) { | |
return 1 - Math.pow(1 - v, pow); | |
} | |
let easedStep = ease(i / frame); |
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 getBrightness = function(hex) { | |
var rgb = 'rgb(' + (hex = hex.replace('#', '')).match(new RegExp('(.{' + hex.length/3 + '})', 'g')).map(function(l) { return parseInt(hex.length%2 ? l+l : l, 16); }).join(',') + ')'; | |
// Get array of RGB values | |
rgb = rgb.replace(/[^\d,]/g, '').split(','); | |
var r = rgb[0], g = rgb[1], b = rgb[2]; | |
var brightness = Math.floor((r * 299 + g * 587 + b * 114) / 1000); |
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 getContrast = function(background, foreground) { | |
// Convert hex to rgb | |
var backgroundRGB = 'rgb(' + (background = background.replace('#', '')).match(new RegExp('(.{' + background.length/3 + '})', 'g')).map(function(l) { return parseInt(background.length%2 ? l+l : l, 16); }).join(',') + ')'; | |
var foregroundRGB = 'rgb(' + (foreground = foreground.replace('#', '')).match(new RegExp('(.{' + foreground.length/3 + '})', 'g')).map(function(l) { return parseInt(foreground.length%2 ? l+l : l, 16); }).join(',') + ')'; | |
// Get array of RGB values | |
var backgroundRGBArray = backgroundRGB.replace(/[^\d,]/g, '').split(','); | |
var foregroundRGBArray = foregroundRGB.replace(/[^\d,]/g, '').split(','); |
NewerOlder