This small javascript library calculates a gradient of multiple colors. The result and whole gradient can be accessed via percentage. The gradient will only be calculated once to save execution time.
1.) Include library:
<script type="text/javascript" src="color.gradient.min.js"></script>
2.) Initialize by pass a color array for the gradient and read the values by percentage selector:
var gradient = new ColorGradient(["#f00", "#0f0", "#00f"]);
var color = gradient.getHexColorAtPercentage([0...100]);
Take a look at the example for more details.
Please report bugs and feel free to ask for new features directly on GitHub.
js.colorGradient is dual-licensed under MIT and GPL-2.0 license.