How Convert Rgb Or Cmyk Color To Percentage Cmyk - Javascript
I use this snippet to convert RGB color to CMYK in javascript: function RgbToCmyk(R,G,B) { if ((R == 0) && (G == 0) && (B == 0)) { return [0, 0, 0, 1];
Solution 1:
CMYK and RGB are two different colour models (subtractive and additive models respectively), hence you need to have an algorithm to convert the values (to get closest equivalent of each system in the other one)
I'll suggest you to have a look here:
using an algorithm like that you should be able to convert the values back and forth and then to get the percentage you just need to do a simple calculation, for example this function will return a percentage value of a given system:
functionget_percentage(value, model){
if (model == "CMYK") return value; // CMYK values are 0-100 (if 0-1 just * 100)if (model == "RGB" ) return (value/ 255)* 100;
}
// a call with the value of 66 in RGB model:document.write( get_percentage( 66, "RGB"));
Hope it helps a bit,
Post a Comment for "How Convert Rgb Or Cmyk Color To Percentage Cmyk - Javascript"