Generate colors based on a desired contrast ratio
✨ Refactored core functions into Classes ✨ Class functions allow us to generate color scales only when necessary, such as when key colors or interpolation space change. Previously, these scales would regenerate when any parameter is changed. When using "smooth" interpolation, this dramatically slows down color output.
This architecture makes modification to a theme more performant in that you can set parameters that only affect their dependent functionality, rather than re-running the entire generateAdaptiveTheme
function any time a change is made. This particularly is useful when setting lightness or the contrast of your theme.
This release includes:
generateContrastColors
, generateBaseScale
, and generateAdaptiveTheme
functions with new classesColor
, BackgroundColor
, and Theme
fixColorVaue
to convertColorValue
since the function name did not match what it does.binarySearch
to getMatchingRatioIndex
since the function is more than just a binary search and specific to finding a matching ratio's indexgetMatchingRatioIndex
to find next highest contrast value for positive contrasts and next smallest value for negative contrasts.For more detail see PR #110