I’m using jquery colors to transform a color from hex to hsl, modify it’s hue by adding a number from 0 to 360 to it, then doing a mod 360 to get the new hue value that i’m actually interested in obtaining
Problem is I can’t figure out how to transform it back to RGB correctly
Given the following example (you can test it on jsfiddle here), why does hslAfter have a different value than hsl?
From what I can see, I’m just transforming originalColor which is in HEX, to a HSL array of values, then trying to make a string from it, in hslAfter.
function testHue() {
var originalColor = $.colors($("#originalColor").val());
var hsl = $.colors(originalColor).model('HSL').get();
var hslAfter = $.colors(hsl).toString('hsl');
var hex = $.colors(hsl).toString('hex');
}
shouldn’t hslAfter have the same values as hsl? (I’m not even mentioning the new hex value here, which of course in turn, should be the same as the original hex color)
Am I missing something here (anyway to fix this)?
You just missed some parameters as per the documentation…
Here’s a DEMO, where the HEX output is now the same as the HEX input…
http://jsfiddle.net/uEUJq/9/