Last active
September 8, 2016 08:49
-
-
Save mohayonao/942b2f67993328cf82229f85b64e0513 to your computer and use it in GitHub Desktop.
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 characters
// velocity-for-color | |
// https://github.com/brunchboy/afterglow/blob/master/src/afterglow/controllers/ableton_push.clj#L24 | |
module.exports = (h, s, v) => { | |
if (v < 3) { | |
return 0; | |
} | |
const brightnessShift = (60 < v) ? 0 : (37 < v) ? 1 : (15 < v) ? 2 : 3; | |
if (s < 20) { | |
return Math.min(4 - brightnessShift, 3); | |
} | |
const baseHue = h; | |
const adjustedHue = baseHue > 230 ? Math.min(baseHue * 1.2, 360) : baseHue; | |
const hueSection = 4 + 4 * Math.floor(13 * adjustedHue / 360); | |
return hueSection + brightnessShift; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment