CMYK (Cyan,Magenta,Yellow,Key (Black) Color model

Here is CMYK (Cyan,Magenta,Yellow,Key (Black)) Color model.

use framework "Foundation"
use framework "JavaScriptCore"
use scripting additions

(**
* The CMYK color model (also known as process color, or four color) is a 
* subtractive color model, based on the CMY color model, used in color printing,
* and is also used to describe the printing process itself. 
* 
* CMYK refers to the four ink plates used in some color printing: 
* cyan, magenta, yellow, and key (black).
*)

-- RGB -> CMYK

set {red, green, blue} to {110, 195, 100}

-- Devide with 255 so the color is in range 0-1
set {red, green, blue} to {red / 255, green / 255, blue / 255}

set _key to 1 - doJsMath("max", {red, green, blue})

if (_key < 1) then
	set f to 1 / (1 - _key)
else
	set f to 0
end if

set cyan to (1 - red - _key) * f
set magenta to (1 - green - _key) * f
set yellow to (1 - blue - _key) * f

set {cyan, magenta, yellow, _key} to {round (cyan * 100), round (magenta * 100), round (yellow * 100), round (_key * 100)}
return {cyan, magenta, yellow, _key}

on doJsMath(theMethod, argsList)
	if class of argsList is not list then set argsList to {argsList}
	set theContext to current application's JSContext's new()
	set theMathObject to theContext's objectForKeyedSubscript:"Math"
	return (theMathObject's invokeMethod:theMethod withArguments:argsList)'s toDouble()
end doJsMath

CMYK to RGB

(**
* Cyan, Magenta, Yellow, Key (black) -> RGB
*)

-- CMYK -> RGB

set {cyan, magenta, yellow, _key} to {44, 0, 49, 24}

set {cyan, magenta, yellow, _key} to {cyan / 100, magenta / 100, yellow / 100, _key / 100}

if (_key = 1) then
	return {0, 0, 0, alpha}
else
	if (cyan ≥ 1) then
		set red to 0
	else
		set red to 255 * (1 - cyan) * (1 - _key)
	end if
	if (magenta ≥ 1) then
		set green to 0
	else
		set green to 255 * (1 - magenta) * (1 - _key)
	end if
	if (yellow ≥ 1) then
		set blue to 0
	else
		set blue to 255 * (1 - yellow) * (1 - _key)
	end if
end if
return {round (red), round (green), round (blue)}