#!/bin/sh # MetaCard 2.4 stack # The following is not ASCII text, # so now would be a good time to q out of more exec mc $0 "$@"  libColor9function libColor_Convert pColorReference,pConvertTo,pConvertFrom if pConvertFrom is "" then put priv_libColor_ConvertFrom(pColorReference) into pConvertFrom switch pConvertFrom case "text" case "colorName" case "name" switch pConvertTo case "text" case "colorName" case "name" return pColorReference break case "RGB" return priv_libColor_ColorNametoRGB(pColorReference) break case "HEX" case "HTML" return priv_libColor_ColorNametoHEX(pColorReference) break case "HSV" return priv_libColor_RGBtoHSV(priv_libColor_ColorNametoRGB(pColorReference)) break case "CMYK" return priv_libColor_RGBtoCMYK(priv_libColor_ColorNametoRGB(pColorReference)) break case "CMYK Decimal" return priv_libColor_ConvertToDecimal(priv_libColor_RGBtoCMYK(priv_libColor_ColorNametoRGB(pColorReference))) break case "Pantone" case "PMS" return priv_libColor_ClosestMatchingPantone(priv_libColor_ColorNametoRGB(pColorReference)) break end switch break case "RGB" switch pConvertTo case "name" case "text" case "colorName" return priv_libColor_ClosestMatchingColorName(pColorReference) break case "RGB" return pColorReference break case "HEX" case "HTML" return priv_libColor_RGBtoHEX(pColorReference) break case "HSV" return priv_libColor_RGBtoHSV(pColorReference) break case "CMYK" return priv_libColor_RGBtoCMYK(pColorReference) break case "CMYK Decimal" return priv_libColor_ConvertToDecimal(priv_libColor_RGBtoCMYK(pColorReference)) break case "Pantone" case "PMS" return priv_libColor_ClosestMatchingPantone(pColorReference) break end switch break case "RGB Decimal" switch pConvertTo case "name" case "text" case "colorName" return priv_libColor_ClosestMatchingColorName(priv_libColor_ConvertFromDecimal(pColorReference)) break case "RGB" return priv_libColor_ConvertFromDecimal(pColorReference) break case "RGB Decimal" return pColorReference break case "HEX" case "HTML" return priv_libColor_RGBtoHEX(priv_libColor_ConvertFromDecimal(pColorReference)) break case "HSV" return priv_libColor_RGBtoHSV(priv_libColor_ConvertFromDecimal(pColorReference)) break case "CMYK" return priv_libColor_RGBtoCMYK(priv_libColor_ConvertFromDecimal(pColorReference)) break case "CMYK Decimal" return priv_libColor_ConvertToDecimal(priv_libColor_RGBtoCMYK(priv_libColor_ConvertFromDecimal(pColorReference))) break case "Pantone" case "PMS" return priv_libColor_ClosestMatchingPantone(priv_libColor_ConvertFromDecimal(pColorReference)) break end switch break case "HEX" case "HTML" switch pConvertTo case "name" case "text" case "colorName" return priv_libColor_HEXtoColorName(pColorReference) break case "RGB" return priv_libColor_HEXtoRGB(pColorReference) break case "HEX" case "HTML" return pColorReference break case "HSV" return priv_libColor_RGBtoHSV(priv_libColor_HEXtoRGB(pColorReference)) break case "CMYK" return priv_libColor_RGBtoCMYK(priv_libColor_HEXtoRGB(pColorReference)) break case "CMYK Decimal" return priv_libColor_ConvertToDecimal(priv_libColor_RGBtoCMYK(priv_libColor_HEXtoRGB(pColorReference))) break case "Pantone" case "PMS" return priv_libColor_ClosestMatchingPantone(priv_libColor_HEXtoRGB(pColorReference)) break end switch break case "HSV" switch pConvertTo case "name" case "text" case "colorName" return priv_libColor_ClosestMatchingColorName(priv_libColor_HSVtoRGB(pColorReference)) break case "RGB" return priv_libColor_HSVtoRGB(pColorReference) break case "HEX" case "HTML" return priv_libColor_RGBtoHEX(priv_libColor_HSVtoRGB(pColorReference)) break case "HSV" return pColorReference break case "CMYK" return priv_libColor_RGBtoCMYK(priv_libColor_HSVtoRGB(pColorReference)) break case "CMYK Decimal" return priv_libColor_ConvertToDecimal(priv_libColor_RGBtoCMYK(priv_libColor_HSVtoRGB(pColorReference))) break case "Pantone" case "PMS" return priv_libColor_ClosestMatchingPantone(priv_libColor_HSVtoRGB(pColorReference)) break end switch break case "CMYK" switch pConvertTo case "name" case "text" case "colorName" return priv_libColor_ClosestMatchingColorName(priv_libColor_CMYKtoRGB(pColorReference)) break case "RGB" return priv_libColor_CMYKtoRGB(pColorReference) break case "HEX" case "HTML" return priv_libColor_RGBtoHEX(priv_libColor_CMYKtoRGB(pColorReference)) break case "CMYK" return pColorReference break case "CMYK Decimal" return priv_libColor_ConvertToDecimal(pColorReference) break case "HSV" return priv_libColor_RGBtoHSV(priv_libColor_CMYKtoRGB(pColorReference)) break case "Pantone" case "PMS" return priv_libColor_ClosestMatchingPantone(priv_libColor_CMYKtoRGB(pColorReference)) break end switch break case "CMYK Decimal" switch pConvertTo case "name" case "text" case "colorName" return priv_libColor_ClosestMatchingColorName(priv_libColor_CMYKtoRGB(priv_libColor_ConvertFromDecimal(pColorReference))) break case "RGB" return priv_libColor_CMYKtoRGB(priv_libColor_ConvertFromDecimal(pColorReference)) break case "RGB Decimal" return priv_libColor_ConvertToDecimal(priv_libColor_CMYKtoRGB(priv_libColor_ConvertFromDecimal(pColorReference))) break case "HEX" case "HTML" return priv_libColor_RGBtoHEX(priv_libColor_CMYKtoRGB(priv_libColor_ConvertFromDecimal(pColorReference))) break case "HSV" return priv_libColor_RGBtoHSV(priv_libColor_CMYKtoRGB(priv_libColor_ConvertFromDecimal(pColorReference))) break case "CMYK" return priv_libColor_ConvertFromDecimal(pColorReference) break case "CMYK Decimal" return priv_libColor_ClosestMatchingPantone(priv_libColor_CMYKtoRGB(priv_libColor_ConvertFromDecimal(pColorReference))) break case "Pantone" case "PMS" return pColorReference break end switch break case "Pantone" case "PMS" switch pConvertTo case "text" case "colorName" case "name" return priv_libColor_ClosestMatchingColorName(priv_libColor_PantonetoRGB(pColorReference)) break case "RGB" return priv_libColor_PantonetoRGB(pColorReference) break case "HEX" case "HTML" return priv_libColor_RGBtoHEX(priv_libColor_PantonetoRGB(pColorReference)) break case "HSV" return priv_libColor_RGBtoHSV(priv_libColor_PantonetoRGB(pColorReference)) break case "CMYK" return priv_libColor_RGBtoCMYK(priv_libColor_PantonetoRGB(pColorReference)) break case "CMYK Decimal" return priv_libColor_ConvertToDecimal(priv_libColor_RGBtoCMYK(priv_libColor_PantonetoRGB(pColorReference))) break case "Pantone" case "PMS" return pColorReference break end switch break default return pConvertFrom end switch end libColor_Convert function priv_libColor_ConvertFrom @pColorReference switch case char 1 of pColorReference is "#" return "HEX" break case pColorReference is among the lines of the colorNames return "text" break case the number of items of pColorReference is 3 return "RGB" break case the number of items of pColorReference is 4 return "CMYK" break case pColorReference is among the lines of the customKeys["cPantoneReference"] of this stack return "Pantone" break end switch try put priv_libColor_ConvertFromDecimal(pColorReference) into pColorReference catch error return "Unknown Color Reference" end try switch case the number of items of pColorReference is 3 return "RGB" break case the number of items of pColorReference is 4 return "CMYK" break end switch end priv_libColor_ConvertFrom function priv_libColor_ConvertFromDecimal pColorReference replace " " with "," in pColorReference repeat with x=1 to the number of items of pColorReference put trunc(item X of pColorReference * 255) into item X of pColorReference end repeat return pColorReference end priv_libColor_ConvertFromDecimal function priv_libColor_ConvertToDecimal pColorReference repeat with x=1 to the number of items of pColorReference put item X of pColorReference / 255 into item X of pColorReference end repeat replace "," with " " in pColorReference return pColorReference end priv_libColor_ConvertToDecimal on priv_libColor_BuildColorNameReference set the visible of stack "libColor" to true repeat for each line tColor in the colorNames set the backColor of cd 1 of stack "libColor" to tColor set the backPixel of cd 1 of stack "libColor" to the effective backPixel of cd 1 of stack "libColor" put the backColor of cd 1 of stack "libColor" into tColorNameReference[tColor] end repeat set the customProperties["cColorNameReference"] of stack "libColor" to tColorNameReference set the visible of stack "libColor" to false save stack "libColor" end priv_libColor_BuildColorNameReference function priv_libColor_RGBtoHEX RGB put format("#%2x%2x%2x",item 1 of RGB,item 2 of RGB,item 3 of RGB) into tHEX return replaceText(tHEX," ","0") end priv_libColor_RGBtoHEX function priv_libColor_HEXtoRGB HEX if char 1 of HEX is "#" then delete char 1 of HEX put baseConvert(char 1 to 2 of HEX,16,10) into item 1 of RGB put baseConvert(char 3 to 4 of HEX,16,10) into item 2 of RGB put baseConvert(char 5 to 6 of HEX,16,10) into item 3 of RGB return RGB end priv_libColor_HEXtoRGB function priv_libColor_ColorNametoRGB pName return the cColorNameReference[pName] of stack "libColor" end priv_libColor_ColorNametoRGB function priv_libColor_ColorNametoHEX pName return priv_libColor_RGBtoHEX(the cColorNameReference[pName] of stack "libColor") end priv_libColor_ColorNametoHEX function priv_libColor_ClosestMatchingColorName RGB put the customProperties["cColorNameReference"] of me into tColors repeat for each line tColorName in keys(tColors) put abs(item 1 of RGB-item 1 of tColors[tColorName]) into tDistance add abs(item 2 of RGB-item 2 of tColors[tColorName]) to tDistance add abs(item 3 of RGB-item 3 of tColors[tColorName]) to tDistance put tColorName,tDistance & cr after tResult end repeat delete last char of tResult sort lines of tResult numeric by item 2 of each return item 1 of tResult end priv_libColor_ClosestMatchingColorName function priv_libColor_HEXtoColorName HEX return priv_libColor_ClosestMatchingColorName(priv_libColor_HEXtoRGB(HEX)) end priv_libColor_HEXtoColorName -- HSV function priv_libColor_RGBtoHSV rgb put (item 1 of rgb / 255) into r put (item 2 of rgb / 255) into g put (item 3 of rgb / 255) into b put max(r,g,b) into theMax put theMax into v put min(r,g,b) into theMin put theMax - theMin into delta if delta = 0 then -- grey multiply v by 255 return "0,0," & round(v) else if theMax <> 0 then put delta / theMax into s else -- r & g & b all = 0 put 0 into s put 0 into h -- don't really know but this will do return "0,0,0" end if if r = theMax then put (g - b) / delta into h -- between yellow & magenta else if g = theMax then put 2 + (b - r) / delta into h -- between cyan & yellow else put 4 + (r - g) / delta into h -- between magenta & cyan end if multiply h by 60 -- convert to degrees if h < 0 then add 360 to h multiply s by 100 -- convert to percent multiply v by 100 -- convert to percent put round(h) & comma & round(s) & comma & round(v) into hsv return hsv end priv_libColor_RGBtoHSV -- h = 0-360, s = 0-100, v = 0-100 -- function priv_libColor_HSVtoRGB hsv put item 1 of hsv into h put (item 2 of hsv / 100) into s put (item 3 of hsv / 100) into v if s = 0 then -- grey put v * 100 into temp return temp & comma & temp & comma & temp end if divide h by 60 put trunc(h) into i put h - i into f -- fractional part of h put v * (1 - s) into p put v * (1 - s * f) into q put v * (1 - s * (1 - f)) into t switch i case 0 put v into r put t into g put p into b break case 1 put q into r put v into g put p into b break case 2 put p into r put v into g put t into b break case 3 put p into r put q into g put v into b break case 4 put t into r put p into g put v into b break case 5 put v into r put p into g put q into b break end switch put round(r * 255) & comma & round(g * 255) & comma & round(b * 255) into rgb return rgb end priv_libColor_HSVtoRGB -- CMYK function priv_libColor_CMYKtoRGB CMYK if (item 1 of CMYK + item 4 of CMYK) < 255 then put 255 - (item 1 of CMYK + item 4 of CMYK) into R else put 0 into R end if if (item 2 of CMYK + item 4 of CMYK) < 255 then put 255 - (item 2 of CMYK + item 4 of CMYK) into G else put 0 into G end if if (item 3 of CMYK + item 4 of CMYK) < 255 then put 255 - (item 3 of CMYK + item 4 of CMYK) into B else put 0 into B end if return R & "," & G & "," & B end priv_libColor_CMYKtoRGB function priv_libColor_RGBtoCMYK RGB put 255-item 1 of RGB into C put 255-item 2 of RGB into M put 255-item 3 of RGB into Y put min(C,M,Y) into K if K > 0 then subtract K from C subtract K from M subtract K from Y end if return C & "," & M & "," & Y & "," & K end priv_libColor_RGBtoCMYK -- Pantone function priv_libColor_PantoneToRGB Pantone return the cPantoneReference[pName] of stack "libColor" end priv_libColor_PantoneToRGB function priv_libColor_ClosestMatchingPantone RGB put the customProperties["cPantoneReference"] of me into tColors repeat for each line tColorName in keys(tColors) put abs(item 1 of RGB-item 1 of tColors[tColorName]) into tDistance add abs(item 2 of RGB-item 2 of tColors[tColorName]) to tDistance add abs(item 3 of RGB-item 3 of tColors[tColorName]) to tDistance put tColorName,tDistance & cr after tResult end repeat delete last char of tResult sort lines of tResult numeric by item 2 of each return item 1 of tResult end priv_libColor_ClosestMatchingPantone  cVersion0.4.1cContributingAuthorsMonte Goulding, mailto:monte@sweattechnologies.com, http://www.sweattechnologies.com; Sarah Reichelt, mailto:sarahr@genesearch.com.au; Roger Eller, roger.e.eller@sealedair.com; James Cass, james.cass@sealedair.com; Direction from Ken Ray and Alejandro TejadacLibraryPurposeThis library provides color reference conversion functions. Note that HSV, CMYK and Pantone are supported in the convert function but are not supported by Revolution as a color references. It also provides a handler to build a color reference so if a new version of rev includes more colors in the color names then just call: "priv_libColor_BuildColorNameReference" from the message box. cDescriptionSupported Color Reference Types "text" | "colorName" | "name", "RGB", "RGB Decimal", "HEX" | "HTML" ,"HSV" , "CMYK", "CMYK Decimal" and "Pantone" | "PMS" RGB and CMYK decimal formats use space as the item delimiter. For example "0.25 0.5 0.75". cParametersthe color reference, what you want to covert it to any of "text" | "colorName" | "name","RGB", "HEX" | "HTML" | "HSV" or "CMYK", what you are converting from (same format types as what you are converting to) The final (convert from) parameter is optional and only needed for converting from HSV. The function will also handle cases where the RGB or CMYK color reference is in decimal format eg "0.25 0.25 0.5". If it's in decimal format it must use space as the item delimiter not comma. cPantoneReference5005 188,135,1355015 216,173,168807_2X 191,0,1405025 226,188,1835035 237,206,198116_2X 247,181,12497568,30,284985 132,73,734995 165,107,109511579,33,585125 117,71,965135 147,107,127299_2X 0,127,2045145 173,135,153375_2X84,188,05155 204,175,1835165 224,201,2045175 232,214,209518571,40,53811_2X 255,84,222365 247,196,216519589,51,685205 142,104,1192375 234,107,191803_2X 255,216,225215 181,147,1552385 219,40,1655225 204,173,1752395 196,0,1402405 168,0,1225235 221,198,196485_2X204,12,02415 155,0,112185_2X209,22,05245 229,211,2042425135,0,91525553,38,79526573,61,995275 96,86,1195285 140,130,1535295 178,168,1815305 204,193,1985315 219,211,211814_2X 112,63,175806_2X 247,2,1242562 216,168,2161205 247,232,1702563 209,160,2043935 242,237,1092567 191,147,20453952,40,585405 63,96,1172572 198,135,2091215 249,224,1402573 186,124,1883945 239,234,72577 170,114,1915415 96,124,1402582 170,71,1861225 255,204,732583 158,79,1653955 237,226,172587 142,71,1735425 132,153,1652592 147,15,1652602 130,12,1421235 252,181,202593 135,43,1472603 112,20,1223965 232,221,172597 102,0,140260791,2,122100 244,237,1245435 175,188,191101 244,237,71102 249,232,202612 112,30,1141245 191,145,12103 198,173,152613 102,17,109104 173,155,12105 130,117,15106 247,232,893975 181,168,12107 249,229,382617 86,12,112108 249,221,22109 249,214,22110 216,181,175445 196,204,204111 170,147,10112 153,132,10262296,45,891255 163,127,20113 249,229,91262391,25,94114 249,226,76115 249,224,76116 252,209,223985 153,140,10117 198,160,12262776,20,94118 170,142,10120 249,226,127119 137,119,255455 214,216,211121 249,224,112122 252,216,86123 255,198,301265 124,99,22124 224,170,15125 181,140,102635 201,173,216126 163,130,53995109,96,2127 244,226,13554630,53,58128 244,219,96129 242,209,61130 234,175,15131 198,147,10132 158,124,10546725,56,51133 112,91,10134 255,216,127135 252,201,992645 181,145,209136 252,191,73137 252,163,175473 38,104,109138 216,140,2165_2X234,79,0139 175,117,5140 122,91,17141 242,206,104142 242,191,73547758,86,79143 239,178,45144 226,140,5145 198,127,72655 155,109,198146 158,107,5147 114,94,385483 96,145,145148 255,214,155382_2X 158,196,0150 252,173,86149 252,204,147151 247,127,0152 221,117,05487 102,124,114153 188,109,10154153,89,52665 137,79,191155 244,219,1702592_2X 114,0,130156 242,198,140157 237,160,795493 140,175,1735503 170,196,191158 232,117,17160 158,84,10159198,96,516199,58,17162 249,198,1705497 145,163,1535507 175,186,178163 252,158,112164 252,127,63165249,99,2166221,89,0167188,79,75513 206,216,209168 109,48,17170 249,137,114169 249,186,170171 249,96,58172247,73,25517 201,206,196173 209,68,20174 147,51,17268586,0,140175 109,51,33176 249,175,173177 249,130,1275523 214,221,214178 249,94,89180 193,56,40179 226,61,40181 124,45,35182 249,191,1935527 206,209,198183 252,140,153184 252,94,1142705 173,158,211269568,35,94185 232,17,452706 209,206,221186 206,17,382707 191,209,229187 175,30,452708 175,188,219188 124,33,40189 255,163,178190 252,117,142200 196,30,58553533,61,48191 244,71,107201 163,38,56192229,5,58202 140,38,511345 255,214,145193 219,130,140203 242,175,193194 153,33,53204 237,122,1582715 147,122,204205 229,76,1242716 165,160,214196 244,201,201206211,5,712717 165,186,224197 239,153,163207 186,170,1582718 91,119,204198 119,45,53208 142,35,68199 216,28,63209 117,38,61210 255,160,1915545 79,109,94211 255,119,168212 249,79,1421355 252,206,135213 234,15,107214204,2,862725 114,81,188215165,5,682726 102,86,188216 124,30,632727 94,104,196217 244,191,209809_2X 214,214,12810_2X 255,188,332728 48,68,181218 237,114,170219 226,40,130220170,0,795555 119,145,130221147,0,66222 112,25,611365 252,186,94223 249,147,196224 244,107,175273579,0,147225 237,40,1472736 73,48,173226 214,2,112227173,0,91273845,0,142228140,0,76229 109,33,63230 255,160,2045565 150,170,153231 252,112,186232 244,63,1651375 249,155,12233 206,0,124234 170,0,102274563,0,119235142,5,842746 63,40,147236 249,175,211802_2X 28,206,402747 28,20,107237 244,132,1962748 30,28,119238 237,79,175239 224,33,158240 196,15,1375575 175,191,173241 173,0,117242 124,28,811385 204,122,2243 242,186,216244 237,160,211275553,0,109245 232,127,2012756 51,40,117246 204,0,160275720,22,84247 183,0,1422758 25,33,104248 163,5,127249 127,40,96250 237,196,2215585 196,206,191251 226,158,214252 211,107,1981395153,96,71405 107,71,20253 175,35,165254 160,45,150276543,12,86255 119,45,107276643,38,91256 229,196,214276720,33,61257 211,165,201276817,33,81258 155,79,150259 114,22,107260 104,30,915595 216,219,204560535,58,4526194,33,8426284,35,68263 224,206,224264 198,170,219265 150,99,196266 109,40,170267 89,17,142268 79,33,112270 186,175,21126968,35,895615 84,104,86271 158,145,198272 137,119,186273 56,25,122274 43,17,10227538,15,8427643,33,71277 181,209,232278 153,186,2212800,43,127279 102,137,2045625 114,132,1122810,40,1042820,38,84283 155,196,226284 117,170,219285 58,117,1962860,56,1682870,56,1472880,51,127300 0,114,198290 196,216,2262890,38,735635 158,170,1533010,91,153291 168,206,226327_2X 0,137,1193020,79,109292 117,178,2213030,63,842930,81,186304 165,221,2262940,63,135305 112,206,2262950,56,107306 0,188,2262960,45,71307 0,122,165297 130,198,2263080,96,124298 81,181,224310 114,209,2213090,63,73299 0,163,2215645 188,193,178311 40,196,216312 0,173,198313 0,153,181314 0,130,155315 0,107,1193160,73,79317 201,232,221318 147,221,219320 0,158,160319 76,206,2095655 198,204,186321 0,135,137320_2X 0,127,130322 0,114,1143230,102,99324 170,221,214325 86,201,193326 0,178,170327 0,140,130328 0,119,1123300,89,81329 0,109,1025665 214,214,198331 186,234,214332 160,229,206333 94,221,193334 0,153,124335 0,124,1023360,104,84337 155,219,193338 122,209,181340 0,153,119339 0,178,1403410,122,943420,107,843430,86,631485 255,183,119344 181,226,191345 150,216,175346 112,206,1553470,158,963480,135,8135035,79,513490,107,63351 181,232,191352 153,229,178353 132,226,1681505 244,124,01495 255,153,633540,183,963550,158,733560,122,6135733,91,51358 170,221,150360 96,198,89359 160,219,142361 30,181,58362 51,158,53363 61,142,51364 58,119,40365 211,232,163366 196,229,142367 170,221,109368 91,191,33370 86,142,20369 86,170,28371 86,107,33372 216,237,150373 206,234,1301525181,84,0374 186,232,96375 140,214,0376 127,186,0377 112,147,237886,99,20380 214,229,66379 224,234,104381 204,226,38382 186,216,10813_2X 209,0,132383 163,175,71535140,68,0384 147,153,5385 112,112,203005 0,132,2012905 147,198,224386 232,237,96387 224,237,68388 214,232,15400 209,198,181390 186,196,5389 206,224,7401 193,181,165391 158,158,7402 175,165,147392 132,130,5403 153,140,124393 242,239,135154576,40,15404 130,117,102394 234,237,53405 107,94,79395 229,232,173015 0,112,1582915 96,175,221406 206,193,181396 224,226,12397 193,191,10574363,73,38408 168,153,140398 175,168,10410 124,109,99409 153,137,124399 153,142,7411 102,89,76805_2X 249,58,4341261,48,40574766,71,22413 198,193,1781555 249,191,158414 181,175,160415 163,158,14030250,84,1072925 0,142,214416 142,140,122417 119,114,995753 94,102,5841896,94,79130_2X 226,145,0420 209,204,19141940,40,33421 191,186,175422 175,170,1635757 107,112,43423 150,147,1421788_2X214,33,01565 252,165,119424 130,127,11942596,96,9130350,68,8429350,91,19142643,43,40427 221,219,2095763 119,124,79428 209,206,198429 173,175,170430 145,150,147431 102,109,11243268,79,815767 140,145,791575 252,135,6843348,56,58434 224,209,19829450,84,160435 211,191,183436 188,165,158437 140,112,1075773 155,158,11443889,63,6143973,53,5144063,48,43441 209,209,198442 186,191,1835777 170,173,1171585 249,107,7443 163,168,163444 137,142,14029550,61,10744586,89,8944673,76,7344763,63,565783 181,181,14244884,71,4544984,71,3845096,84,43451 173,160,122452 196,183,1505787 198,198,1531605 160,79,171595209,91,5453 214,204,175454 226,216,19129650,51,76455 102,86,20456 153,135,20457 181,155,125793 198,198,1655803 216,214,183458 221,204,107459 226,214,124460 234,221,150461 237,229,17346291,71,355797 211,209,1705807 224,221,1881615 132,63,15463 117,84,38464 135,96,402975 186,224,226465 193,168,117466 209,191,145467 221,204,165468 226,214,18146996,51,17470 155,79,25581573,68,17471 188,94,30472 234,170,1221625 249,165,140473 244,196,160474 244,204,1702985 81,191,226475 247,211,18147689,61,4347799,56,38478 122,63,40479 175,137,112480 211,183,1635825 117,112,43481 224,204,186482 229,211,1931635 249,142,109483 107,48,33484 155,48,283105 127,214,2192995 0,165,219485216,30,5486 237,158,132487 239,181,160488 242,196,175489 242,209,19149091,38,38500 206,137,1405835 158,153,89491 117,40,40501 234,178,178464_2X 112,66,20492 145,51,56502 242,198,1961645 249,114,66503 244,209,204494 242,173,17850481,30,383115 45,198,214495 244,188,191505 102,30,43496 247,201,198506 122,38,5649781,40,38507 216,137,155498 109,51,43508 232,165,175499 122,56,45509 242,186,191510 244,198,2015845 178,170,112239_2X 196,5,12451196,33,68512 132,33,1071655249,86,2513 158,35,135514 216,132,1883125 0,183,198515 232,163,201516 242,186,211448596,76,17517 244,204,21651881,45,6851999,48,94520 112,53,1145855 204,198,147521 181,140,178522 198,163,1931665221,79,5523 211,183,204524 226,204,2113135 0,155,17052581,38,84526 104,33,1224495 135,117,484505 160,145,81527 122,30,153528 175,114,193529 206,163,211530 214,175,2145865 214,206,163531 229,198,21953253,56,661675 165,63,1553353,63,91534 58,73,1143145 0,132,142535 155,163,183536 173,178,1934515 188,173,117537 196,198,206538 214,211,2145390,48,735400,51,915875 224,219,1815410,63,119542 102,147,1881685 132,53,17543 147,183,209544 183,204,2193155 0,109,117545 196,211,22154612,56,684525 204,191,1425470,63,845480,68,89549 94,153,170550 135,175,191551 163,193,201552 196,214,21455335,68,5355425,94,7131650,86,915557,109,84556 122,168,1454535 219,206,165557 163,193,173558 183,206,188559 198,214,19656043,76,63561 38,102,89562 30,122,109563 127,188,1705645,112,94565 188,219,204566 209,226,2114545 229,219,18656738,81,66569 0,135,114570 127,198,178571 170,219,198572 188,226,206573 204,229,21457473,89,40575 84,119,48808_2X 0,160,135576 96,142,58433_2X10,12,17577 181,204,142578 198,214,160579 201,214,163580 216,221,18158196,94,17582 135,137,5583 170,186,10584 206,214,73585 219,224,107586 226,229,132587 232,232,155600 244,237,175601 242,237,158602 242,234,135603 237,232,91604 232,221,33801_2X 0,137,175605 221,206,17606 211,191,17607 242,234,188608 239,232,173609 234,229,150610 226,219,114611 214,206,73612 196,186,0613 175,160,12614 234,226,183615 226,219,170616 221,214,155617 204,196,124618 181,170,89619 150,140,40620 132,119,17621 216,221,206622 193,209,1911765 249,158,163623 165,191,170624 127,160,1401767 249,178,183625 91,135,11462633,84,6362712,48,38628 204,226,221629 178,216,216630 140,204,211631 84,183,1983242 135,221,209632 0,160,1861775 249,132,142633 0,127,153634 0,102,1273245 140,224,2091777 252,102,117635 186,224,224636 153,214,221637 107,201,2193248 122,211,193638 0,181,214639 0,160,196640 0,140,178641 0,122,1653252 86,214,201642 209,216,2161785 252,79,89643 198,209,214644 155,175,1963255 71,214,1931787 244,63,79645 119,150,1781788 239,43,45646 94,130,163462571,35,17647 38,84,1243258 53,196,1756480,48,94649 214,214,216650 191,198,209651 155,170,1913262 0,193,181652 109,135,1681805 175,38,381795 214,40,40653 51,86,13565415,43,913265 0,198,1781797 204,45,481807 160,48,5165512,28,71656 214,219,2241810 124,33,304635 140,89,51657 193,201,2213268 0,175,153658 165,175,214659 127,140,191660 89,96,168661 45,51,1423272 0,170,158662 12,25,117663 226,211,214664 216,204,2093275 0,178,160181791,45,40665 198,181,196666 168,147,1734645 178,130,96667 127,102,1373278 0,155,132668 102,73,11766971,43,89670 242,214,216671 239,198,2113282 0,140,130672 234,170,196673 224,140,178674 211,107,1583285 0,153,135675 188,56,119676160,0,844655 196,153,119677 237,214,2143288 0,130,112678 234,204,206679 229,191,198680 211,158,175681 183,114,14233020,73,6332920,96,86682 160,81,117683 127,40,79684 239,204,20633050,79,663295 0,130,114685 234,191,196686 224,170,1864665 216,181,150687 201,137,15833080,68,5632980,107,91688 178,102,132689 147,66,102690 112,35,66700 242,165,170691 239,209,201701 232,135,142692 232,191,186702 214,96,109693 219,168,165703 183,56,68694 201,140,140704 158,40,40695 178,107,112705 249,221,214696 142,71,73706 252,201,1984675 229,198,170697 127,56,58707 252,173,175698 247,209,204708 249,142,153699 247,191,191709 242,104,119710 224,66,81711 209,45,51712 255,211,170713 249,201,163452_2X 176,153,130714 249,186,130715 252,158,73716 242,132,174685 237,211,188717 211,109,0718191,91,0719 244,209,175720 239,196,158721 232,178,130722 209,142,84723 186,117,48724142,73,5725117,56,2726 237,211,181469581,38,284705 124,81,61727 226,191,155728 211,168,124368_2X0,158,15729 193,142,96730 170,117,63731 114,63,1073296,51,104715 153,112,914725 181,145,124812_2X252,7,791895 252,191,2011905 252,155,1784735 204,175,1551915 244,84,1243375 142,226,1884745 216,191,170804_2X 255,127,301925224,7,713385 84,216,1684755 226,204,1861935193,5,563405 0,178,1223395 0,201,147801 0,170,204802 96,221,731945 168,12,53803 255,237,56804 255,147,5634150,124,89805 249,89,81806 255,0,147807 214,0,158808 0,181,155809 221,224,15810 255,204,30811 255,114,71812 252,35,1021955 147,22,56813 229,0,153814 140,96,19334250,104,7134352,73,48471_2X163,68,2306_2X 0,163,209cColorNameReference(Brown152,5,23Khaki1 255,243,128Khaki2 237,226,117 Honeydew 240,254,238Khaki3 201,190,98Red255,0,0Khaki4 130,120,57Orange 248,122,23 PaleGreen1 154,255,154DarkSeaGreen1 193,255,193 PaleGreen2 144,238,144DarkSeaGreen2 180,238,180 PaleGreen3 124,205,124DarkSeaGreen3 153,198,142 PaleGreen4 78,124,65DarkSeaGreen4 105,139,105Cyan 0,255,255 DarkSalmon 225,139,107Maroon129,5,65Snow1 255,250,250Snow2 236,231,230 LightPink 250,175,186Snow3 200,196,194MediumSeaGreen 48,103,84Snow4 129,124,123Gray1021,5,23Gray1121,5,23Gray1221,5,23Gray1321,5,23Gray1421,5,23LavenderBlush1 255,240,245Gray1521,5,23LavenderBlush2 235,221,226Gray1621,5,23Ivory1 255,255,238LavenderBlush3 200,187,190Gray1721,5,23Ivory2 236,236,220LavenderBlush4 129,118,121Gray1837,5,23Ivory3 201,199,185Gray2037,5,23Gray1937,5,23Ivory4 129,125,116Gray2143,27,23 RosyBrown1 251,187,185Gray2243,27,23 DarkOrange1 248,114,23 RosyBrown2 232,173,170Gray2348,34,23 DarkOrange2 229,103,23 RosyBrown3 197,144,142Gray2448,34,38 DarkOrange3 195,86,23 RosyBrown4 127,90,88Gray2552,40,38 DarkOrange4 126,49,23Gray2652,40,44Gray2756,45,44PaleTurquoise1 187,255,255Gray2859,49,49PaleTurquoise2 173,235,236Gray3065,56,57Gray2962,53,53PaleTurquoise3 146,199,199Gray3165,56,60PaleTurquoise4 102,139,139Gray3270,62,63Gray3370,62,65Brown1 246,53,38Gray3474,67,68Brown2 228,45,23Gray3576,70,70Brown3 194,34,23Pink1 255,181,197Gray3678,72,72Brown4126,5,23Pink2 231,161,176Gray3780,74,75Pink3 196,135,147Gray3884,78,79Pink4 127,82,93Gray40 102,102,102Gray3986,80,81Gray41 105,105,105Gray42 107,107,107Gray43 110,110,110Gray44 100,96,96Gray45 102,99,98Gray46 105,101,101 VioletRed 208,32,144Gray47 109,105,104Gray48 110,106,107Gray50 116,113,112Gray49 114,110,109Gray51 120,116,115Gray52 122,119,119Gray53 124,121,121Gray54 128,125,124Gray55 130,128,126DimGray70,62,65Gray56 133,131,129Gray57 135,133,131Gray58 139,137,135Gray60 143,142,141Gray59 141,139,137Gray61 147,145,144MediumTurquoise 72,204,205Gray62 149,148,146 Honeydew1 240,255,240Gray63 153,151,149Red1 246,34,23Gray64 154,153,152 Honeydew2 222,235,220Red2 228,27,23Gray65 158,156,155 Honeydew3 188,199,185Red3 193,27,23Gray66 160,159,157 Honeydew4 122,125,116Red4126,5,23Gray67 163,162,160Gray68 165,164,163PaleVioletRed1 247,120,161Gray70 172,171,169Gray69 169,168,166PaleVioletRed2 229,110,148Gray71 174,173,172PaleVioletRed3 194,90,124Gray72 177,177,175PaleVioletRed4 126,53,77Gray73 179,179,177Orange1 250,155,23Gray74 183,182,180Orange2 231,142,23Gray75 185,184,182Orange3 197,119,23Gray76 188,187,186Orange4 127,72,23Green0,255,0Gray77 190,190,188 DeepPink1 255,20,147Gray78 193,193,191 DeepPink2 228,40,124 Seashell1 255,245,238Gray80 199,199,197Gray79 195,196,194 DeepPink3 193,34,103 Seashell2 238,229,222Gray81 202,202,201 DeepPink4125,5,63 Seashell3 205,197,191Gray82 204,204,203 Seashell4 139,134,130Gray83 208,207,207 IndianRed 205,92,92Gray84 210,210,209Gray85 213,213,212Gray86 215,215,215 MediumBlue0,0,205Gray87 219,219,217Gray88 221,221,220Gray90 226,227,225Gray89 224,224,224Gray91 229,230,228 DarkGray 169,169,169Gray92 232,233,232Gray93 235,235,234Gray94 238,238,238Gray95 240,241,240Gray96 244,244,243Gray97 246,246,245Gray98 249,249,250 Gainsboro 216,217,215Gray99 251,251,251Pink 250,175,190Yellow 255,255,0Beige 245,243,215 CadetBlue 87,134,147 Chartreuse1 127,255,0 Chartreuse2 118,238,0 Chartreuse3 102,205,0Wheat1 254,228,177 Chartreuse4 67,124,23Wheat2 235,211,163 DarkGreen0,100,0Tan 210,180,140Wheat3 200,177,137Yellow1 255,255,0Wheat4 129,111,84Yellow2 238,233,23Navy0,0,128Yellow3 202,197,23Yellow4 130,124,23 LightBlue1 189,237,255 LightBlue2 175,220,236DarkOliveGreen1 202,255,112 LightBlue3 149,185,199Cyan1 87,254,255DarkOliveGreen2 188,233,84 LightBlue4 104,131,139Cyan2 80,235,236DarkOliveGreen3 160,197,68Cyan3 70,199,199DarkOliveGreen4 102,124,38Cyan4 48,125,126Maroon1 245,53,170Gold 212,160,23Maroon2 227,49,157Maroon3 193,34,131Maroon4125,5,82 PowderBlue 173,220,227 CornSilk 255,247,215 Lavender 227,228,250MediumSlateBlue 123,104,238MediumGoldenrod 204,185,84 CadetBlue1 152,245,255 CadetBlue2 142,226,236 CadetBlue3 119,191,199 CadetBlue4 76,120,126Sienna1 248,116,49SkyBlue 102,152,255Sienna2 230,108,44Sienna3 195,88,23Sienna4 126,53,23 DeepSkyBlue 0,191,255Purple 142,53,239Salmon1 248,129,88Salmon2 230,116,81Salmon3 195,98,65Salmon4 126,56,23 MediumOrchid 176,72,181 LightPink1 249,167,176 LightPink2 231,153,163 LightPink3 196,129,137 LightPink4 127,78,82 DarkBlue0,0,139 LightGray 160,159,157PaleTurquoise 174,235,236 Magenta1 255,0,255 Magenta2 226,56,236 DeepPink 245,40,135 Magenta3 192,49,199 Magenta4 125,27,126 FloralWhite 255,249,238 BlueViolet 138,43,226 DarkViolet 132,45,206 LightGreen 144,238,144 RoyalBlue 43,96,222 NavyBlue0,0,128Tan1 250,155,60Tan2 231,142,53Tan3 197,119,38Tan4 127,72,23 OliveDrab 101,128,23 Chocolate1 248,114,23Gray100 255,255,255 Chocolate2 229,103,23 Chocolate3 195,86,23 Chocolate4 126,49,23 Burlywood 216,175,121 LightCyan1 224,255,255 LightCyan2 207,236,236 LightCyan3 175,199,199 LightCyan4 113,125,125CornflowerBlue 100,149,237Coral 247,101,65Gray 190,190,190Thistle 210,185,211 SteelBlue1 92,179,255 SteelBlue2 86,165,236Khaki 173,169,110PaleGoldenrod 237,228,158 SteelBlue3 72,138,199 SteelBlue4 43,84,126 Moccasin 253,224,172 LightBlue 173,216,230 SandyBrown 238,154,77 RoyalBlue1 48,110,255 RoyalBlue2 43,101,236 RoyalBlue3 37,84,199 RoyalBlue4 21,49,126 SteelBlue 70,130,180 SlateGray1 194,223,255 SlateGray2 180,207,236 SlateGray3 152,175,199 SlateGray4 108,123,139 DarkKhaki 183,173,89 MidnightBlue21,27,84 SpringGreen 0,255,127 DarkOrchid 125,27,126Plum 185,59,143Linen 249,238,226 MediumPurple 132,103,215Gold1 253,208,23Gold2 234,193,23Azure1 239,255,255Blue0,0,255Gold3 199,163,23Azure2 222,236,236Gold4 128,101,23Azure3 188,199,199Azure4 122,125,125Black0,0,0 GhostWhite 247,247,255 DarkOrange 248,128,23OldLace 252,243,226 SaddleBrown 126,49,23Wheat 243,218,169DarkOliveGreen74,65,23 LightCoral 231,116,113 SlateBlue1 115,105,255 SlateBlue2 105,96,236 SlateBlue3 105,89,205 SlateBlue4 52,45,126 SlateGray 101,115,131 CornSilk1 255,247,215 CornSilk2 236,229,198 CornSilk3 200,194,167 Turquoise 64,224,208 CornSilk4 129,122,104 Goldenrod1 251,185,23 Goldenrod2 233,171,23 Goldenrod3 198,142,23 Goldenrod4 128,88,23LightSteelBlue 114,143,206 MistyRose1 255,228,225 MistyRose2 234,208,204 MistyRose3 198,175,172 MistyRose4 128,111,108 LightYellow 255,254,220 SpringGreen1 94,251,110 SpringGreen2 0,238,118 DarkMagenta 139,0,139 SpringGreen3 0,205,102 SpringGreen40,139,69AntiqueWhite1 254,237,214AntiqueWhite2 235,219,197AntiqueWhite3 200,185,166AntiqueWhite4 129,116,104BlanchedAlmond 254,232,198 AliceBlue 239,247,255 PeachPuff 252,213,176 DarkSeaGreen 139,179,129 YellowGreen 154,205,50LavenderBlush 253,238,244 Turquoise1 0,245,255 Turquoise2 0,229,238 Turquoise3 0,197,205 Turquoise4 0,134,139 LawnGreen 124,252,0Salmon 225,139,107 ForestGreen 34,139,34Magenta 244,62,255 OliveDrab1 192,255,62 OliveDrab2 179,238,58 OliveDrab3 153,197,23 OliveDrab4 105,139,34 VioletRed1 246,53,138 VioletRed2 228,49,127 VioletRed3 193,40,105 VioletRed4125,5,65 SlateBlue 106,90,205 Goldenrod 218,165,32 MistyRose 253,225,221 AntiqueWhite 249,232,210DarkSlateGray1 151,255,255DarkSlateGray2 141,238,238DarkSlateGray3 120,199,199DarkSlateGray4 76,125,126MediumVioletRed 199,21,133LightSkyBlue1 173,223,255 NavajoWhite 253,218,163LightSkyBlue2 160,207,236LightSkyBlue3 135,175,199LightSkyBlue4 86,109,126LightSlateGray 109,123,141 SeaGreen1 106,251,146 SeaGreen2 100,233,134DarkRed139,0,0HotPink 246,96,171 SeaGreen3 67,205,128 SeaGreen4 46,139,87 PapayaWhip 254,236,207MediumSpringGreen 0,250,154Snow 255,249,250Ivory 255,255,238LightGoldenrodYellow 250,248,204 LimeGreen 50,205,50 OrangeRed1255,69,0 OrangeRed2 228,49,23 OrangeRed3 194,40,23 OrangeRed4126,5,23Azure 239,255,255 WhiteSmoke 244,244,243 Burlywood1 252,206,142 Burlywood2 234,190,131 Burlywood3 198,160,109 Burlywood4 128,99,65 SkyBlue1 130,202,255LemonChiffon1 255,250,205 SkyBlue2 121,186,236LemonChiffon2 238,233,191 SkyBlue3 101,158,199LemonChiffon3 205,201,165 SkyBlue4 65,98,126 DarkOrchid1 176,65,255LemonChiffon4 139,137,112 DarkOrchid2 162,59,236 DarkOrchid3 139,49,199LightSteelBlue1 198,222,255 DarkOrchid4 104,34,139LightSteelBlue2 183,206,236LightSteelBlue3 154,173,199LightSteelBlue4 100,109,126 LemonChiffon 255,248,198 NavajoWhite1 255,222,173 NavajoWhite2 234,201,149 NavajoWhite3 199,170,125Tomato 247,84,49 NavajoWhite4 128,106,75Plum1 249,183,255Plum2 230,169,236LightSlateBlue 115,106,255Plum3 195,142,199Plum4 126,88,126 Aquamarine 67,183,186Tomato1 255,99,71 DodgerBlue 21,137,255Tomato2 229,76,44LightGoldenrod 236,216,114Tomato3 194,62,23Tomato4 126,34,23DarkGoldenrod1 251,177,23DarkGoldenrod2 232,163,23DarkGoldenrod3 197,137,23DarkGoldenrod4 127,82,23Orchid1 246,125,250Orchid2 228,115,231Orchid3 193,96,195Orchid4 125,56,124 DeepSkyBlue1 59,185,255 DeepSkyBlue2 0,178,238 DeepSkyBlue3 0,154,205 MintCream 245,255,249PaleVioletRed 209,101,135 DeepSkyBlue4 0,104,139 Seashell 254,243,235 Chartreuse 127,255,0 DarkCyan 0,139,139 LightYellow1 255,255,224 LightYellow2 237,235,203 LightYellow3 201,199,170 LightYellow4 130,125,107Violet 141,56,201Purple1 137,59,255Purple2 127,56,236Purple3 108,45,199Purple4 70,27,126 GreenYellow 173,255,47Green1 95,251,23Green20,238,0Green30,205,0Green40,139,0Peru 197,119,38DarkSlateGray37,56,60 LightSkyBlue 130,202,250 Firebrick1 246,40,23 Firebrick2 228,34,23 Firebrick3 193,27,23 Firebrick4126,5,23MediumForestGreen 52,114,53 OrangeRed 246,56,23 LightSalmon1 255,160,122 LightSalmon2 231,138,97 LightSalmon3 196,116,81 HotPink1 246,101,171 LightSalmon4 127,70,44 HotPink2 228,94,157 HotPink3 194,82,131 HotPink4 125,34,82Bisque1 253,224,188LightSeaGreen 32,178,170Bisque2 234,208,174DarkTurquoise 59,156,156Bisque3 199,175,146Bisque4 129,110,89Bisque 255,228,196Coral1 247,101,65Coral2 229,91,60Coral3 195,74,44Coral4 126,40,23 IndianRed1 247,93,89 IndianRed2 229,84,81 IndianRed3 194,70,65 IndianRed4 126,34,23Gray021,5,23Gray121,5,23Gray221,5,23 RosyBrown 179,132,129Gray321,5,23Gray410,10,10Gray513,13,13Gray615,15,15Gray718,18,18Gray820,20,20MediumOrchid1 212,98,255Gray921,5,23MediumOrchid2 196,90,236MediumOrchid3 167,74,199MediumOrchid4 106,40,126 Aquamarine1 127,255,212MediumAquamarine 102,205,170 Thistle1 252,223,255 Aquamarine2 118,238,198Sienna 160,82,45 Thistle2 233,207,236 Aquamarine3 102,205,170 Thistle3 198,174,199 Aquamarine4 65,124,100 Thistle4 128,109,126 DodgerBlue1 30,144,255 DodgerBlue2 28,134,238 DodgerBlue3 24,116,205 DodgerBlue4 16,78,139 Chocolate 200,90,23 LightCyan 224,255,255LightGoldenrod1 255,232,124LightGoldenrod2 236,214,114White 255,255,255LightGoldenrod3 200,181,96LightGoldenrod4 129,115,57MediumPurple1 171,130,255MediumPurple2 159,121,238MediumPurple3 137,104,205MediumPurple4 93,71,139 SeaGreen 46,139,87DarkSlateBlue43,56,86DarkGoldenrod 175,120,23Orchid 218,112,214 Firebrick128,5,23 LightSalmon 249,150,107Blue1 21,53,255 Transparent21,5,23Blue2 21,49,236Blue3 21,40,199 PeachPuff1 255,218,185Blue4 21,27,126 PeachPuff2 234,197,163 PeachPuff3 198,166,136 PeachPuff4 128,103,82 PaleGreen 121,216,103 cDescriptionlibColor_ConvertSupported Color Reference Types "text" | "colorName" | "name", "RGB", "RGB Decimal", "HEX" | "HTML" ,"HSV" or "CMYK", "CMYK Decimal", RGB and CMYK decimal formats use space as the item delimiter. For example "0.25 0.5 0.75". cReturnslibColor_ConvertCconverted color reference Error report = "Unknown Color Reference" cParameterslibColor_Convert9the color reference, what you want to covert it to, what you are converting from (same format types as what you are converting to) The final (convert from) parameter is optional and only needed for converting from HSV. RGB and CMYK decimal formats with space as the item delimiter. For example "0.25 0.5 0.75". cREVGeneralscriptChecksum%f}ԝE+! bookmarks handlerListlibColor_Convert priv_libColor_ConvertFrom priv_libColor_ConvertFromDecimal priv_libColor_ConvertToDecimal priv_libColor_BuildColorNameReference priv_libColor_RGBtoHEX priv_libColor_HEXtoRGB priv_libColor_ColorNametoRGB priv_libColor_ColorNametoHEX priv_libColor_ClosestMatchingColorName priv_libColor_HEXtoColorName priv_libColor_RGBtoHSV priv_libColor_HSVtoRGB priv_libColor_CMYKtoRGB priv_libColor_RGBtoCMYK priv_libColor_PantoneToRGB priv_libColor_ClosestMatchingPantone prevHandlerlibColor_Convert tempScriptscriptSelectionchar 10568 to 10567script}

function libColor_Convert pColorReference,pConvertTo,pConvertFrom

if pConvertFrom is "" then put priv_libColor_ConvertFrom(pColorReference) into pConvertFrom

switch pConvertFrom

case "text"

case "colorName"

case "name"

switch pConvertTo

case "text"

case "colorName"

case "name"

return pColorReference

break

case "RGB"

return priv_libColor_ColorNametoRGB(pColorReference)

break

case "HEX"

case "HTML"

return priv_libColor_ColorNametoHEX(pColorReference)

break

case "HSV"

return priv_libColor_RGBtoHSV(priv_libColor_ColorNametoRGB(pColorReference))

break

case "CMYK"

return priv_libColor_RGBtoCMYK(priv_libColor_ColorNametoRGB(pColorReference))

break

case "CMYK Decimal"

return priv_libColor_ConvertToDecimal(priv_libColor_RGBtoCMYK(priv_libColor_ColorNametoRGB(pColorReference)))

break

case "Pantone"

case "PMS"

return priv_libColor_ClosestMatchingPantone(priv_libColor_ColorNametoRGB(pColorReference))

break

end switch

break

case "RGB"

switch pConvertTo

case "name"

case "text"

case "colorName"

return priv_libColor_ClosestMatchingColorName(pColorReference)

break

case "RGB"

return pColorReference

break

case "HEX"

case "HTML"

return priv_libColor_RGBtoHEX(pColorReference)

break

case "HSV"

return priv_libColor_RGBtoHSV(pColorReference)

break

case "CMYK"

return priv_libColor_RGBtoCMYK(pColorReference)

break

case "CMYK Decimal"

return priv_libColor_ConvertToDecimal(priv_libColor_RGBtoCMYK(pColorReference))

break

case "Pantone"

case "PMS"

return priv_libColor_ClosestMatchingPantone(pColorReference)

break

end switch

break

case "RGB Decimal"

switch pConvertTo

case "name"

case "text"

case "colorName"

return priv_libColor_ClosestMatchingColorName(priv_libColor_ConvertFromDecimal(pColorReference))

break

case "RGB"

return priv_libColor_ConvertFromDecimal(pColorReference)

break

case "RGB Decimal"

return pColorReference

break

case "HEX"

case "HTML"

return priv_libColor_RGBtoHEX(priv_libColor_ConvertFromDecimal(pColorReference))

break

case "HSV"

return priv_libColor_RGBtoHSV(priv_libColor_ConvertFromDecimal(pColorReference))

break

case "CMYK"

return priv_libColor_RGBtoCMYK(priv_libColor_ConvertFromDecimal(pColorReference))

break

case "CMYK Decimal"

return priv_libColor_ConvertToDecimal(priv_libColor_RGBtoCMYK(priv_libColor_ConvertFromDecimal(pColorReference)))

break

case "Pantone"

case "PMS"

return priv_libColor_ClosestMatchingPantone(priv_libColor_ConvertFromDecimal(pColorReference))

break

end switch

break

case "HEX"

case "HTML"

switch pConvertTo

case "name"

case "text"

case "colorName"

return priv_libColor_HEXtoColorName(pColorReference)

break

case "RGB"

return priv_libColor_HEXtoRGB(pColorReference)

break

case "HEX"

case "HTML"

return pColorReference

break

case "HSV"

return priv_libColor_RGBtoHSV(priv_libColor_HEXtoRGB(pColorReference))

break

case "CMYK"

return priv_libColor_RGBtoCMYK(priv_libColor_HEXtoRGB(pColorReference))

break

case "CMYK Decimal"

return priv_libColor_ConvertToDecimal(priv_libColor_RGBtoCMYK(priv_libColor_HEXtoRGB(pColorReference)))

break

case "Pantone"

case "PMS"

return priv_libColor_ClosestMatchingPantone(priv_libColor_HEXtoRGB(pColorReference))

break

end switch

break

case "HSV"

switch pConvertTo

case "name"

case "text"

case "colorName"

return priv_libColor_ClosestMatchingColorName(priv_libColor_HSVtoRGB(pColorReference))

break

case "RGB"

return priv_libColor_HSVtoRGB(pColorReference)

break

case "HEX"

case "HTML"

return priv_libColor_RGBtoHEX(priv_libColor_HSVtoRGB(pColorReference))

break

case "HSV"

return pColorReference

break

case "CMYK"

return priv_libColor_RGBtoCMYK(priv_libColor_HSVtoRGB(pColorReference))

break

case "CMYK Decimal"

return priv_libColor_ConvertToDecimal(priv_libColor_RGBtoCMYK(priv_libColor_HSVtoRGB(pColorReference)))

break

case "Pantone"

case "PMS"

return priv_libColor_ClosestMatchingPantone(priv_libColor_HSVtoRGB(pColorReference))

break

end switch

break

case "CMYK"

switch pConvertTo

case "name"

case "text"

case "colorName"

return priv_libColor_ClosestMatchingColorName(priv_libColor_CMYKtoRGB(pColorReference))

break

case "RGB"

return priv_libColor_CMYKtoRGB(pColorReference)

break

case "HEX"

case "HTML"

return priv_libColor_RGBtoHEX(priv_libColor_CMYKtoRGB(pColorReference))

break

case "CMYK"

return pColorReference

break

case "CMYK Decimal"

return priv_libColor_ConvertToDecimal(pColorReference)

break

case "HSV"

return priv_libColor_RGBtoHSV(priv_libColor_CMYKtoRGB(pColorReference))

break

case "Pantone"

case "PMS"

return priv_libColor_ClosestMatchingPantone(priv_libColor_CMYKtoRGB(pColorReference))

break

end switch

break

case "CMYK Decimal"

switch pConvertTo

case "name"

case "text"

case "colorName"

return priv_libColor_ClosestMatchingColorName(priv_libColor_CMYKtoRGB(priv_libColor_ConvertFromDecimal(pColorReference)))

break

case "RGB"

return priv_libColor_CMYKtoRGB(priv_libColor_ConvertFromDecimal(pColorReference))

break

case "RGB Decimal"

return priv_libColor_ConvertToDecimal(priv_libColor_CMYKtoRGB(priv_libColor_ConvertFromDecimal(pColorReference)))

break

case "HEX"

case "HTML"

return priv_libColor_RGBtoHEX(priv_libColor_CMYKtoRGB(priv_libColor_ConvertFromDecimal(pColorReference)))

break

case "HSV"

return priv_libColor_RGBtoHSV(priv_libColor_CMYKtoRGB(priv_libColor_ConvertFromDecimal(pColorReference)))

break

case "CMYK"

return priv_libColor_ConvertFromDecimal(pColorReference)

break

case "CMYK Decimal"

return priv_libColor_ClosestMatchingPantone(priv_libColor_CMYKtoRGB(priv_libColor_ConvertFromDecimal(pColorReference)))

break

case "Pantone"

case "PMS"

return pColorReference

break

end switch

break

case "Pantone"

case "PMS"

switch pConvertTo

case "text"

case "colorName"

case "name"

return priv_libColor_ClosestMatchingColorName(priv_libColor_PantonetoRGB(pColorReference))

break

case "RGB"

return priv_libColor_PantonetoRGB(pColorReference)

break

case "HEX"

case "HTML"

return priv_libColor_RGBtoHEX(priv_libColor_PantonetoRGB(pColorReference))

break

case "HSV"

return priv_libColor_RGBtoHSV(priv_libColor_PantonetoRGB(pColorReference))

break

case "CMYK"

return priv_libColor_RGBtoCMYK(priv_libColor_PantonetoRGB(pColorReference))

break

case "CMYK Decimal"

return priv_libColor_ConvertToDecimal(priv_libColor_RGBtoCMYK(priv_libColor_PantonetoRGB(pColorReference)))

break

case "Pantone"

case "PMS"

return pColorReference

break

end switch

break

default

return pConvertFrom

end switch

end libColor_Convert

function priv_libColor_ConvertFrom @pColorReference

switch

case char 1 of pColorReference is "#"

return "HEX"

break

case pColorReference is among the lines of the colorNames

return "text"

break

case the number of items of pColorReference is 3

return "RGB"

break

case the number of items of pColorReference is 4

return "CMYK"

break

case pColorReference is among the lines of the customKeys["cPantoneReference"] of this stack

return "Pantone"

break

end switch

try

put priv_libColor_ConvertFromDecimal(pColorReference) into pColorReference

catch error

return "Unknown Color Reference"

end try

switch

case the number of items of pColorReference is 3

return "RGB"

break

case the number of items of pColorReference is 4

return "CMYK"

break

end switch

end priv_libColor_ConvertFrom

function priv_libColor_ConvertFromDecimal pColorReference

replace " " with "," in pColorReference

repeat with x=1 to the number of items of pColorReference

put trunc(item X of pColorReference * 255) into item X of pColorReference

end repeat

return pColorReference

end priv_libColor_ConvertFromDecimal

function priv_libColor_ConvertToDecimal pColorReference

repeat with x=1 to the number of items of pColorReference

put item X of pColorReference / 255 into item X of pColorReference

end repeat

replace "," with " " in pColorReference

return pColorReference

end priv_libColor_ConvertToDecimal

on priv_libColor_BuildColorNameReference

set the visible of stack "libColor" to true

repeat for each line tColor in the colorNames

set the backColor of cd 1 of stack "libColor" to tColor

set the backPixel of cd 1 of stack "libColor" to the effective backPixel of cd 1 of stack "libColor"

put the backColor of cd 1 of stack "libColor" into tColorNameReference[tColor]

end repeat

set the customProperties["cColorNameReference"] of stack "libColor" to tColorNameReference

set the visible of stack "libColor" to false

save stack "libColor"

end priv_libColor_BuildColorNameReference

function priv_libColor_RGBtoHEX RGB

put format("#%2x%2x%2x",item 1 of RGB,item 2 of RGB,item 3 of RGB) into tHEX

return replaceText(tHEX," ","0")

end priv_libColor_RGBtoHEX

function priv_libColor_HEXtoRGB HEX

if char 1 of HEX is "#" then delete char 1 of HEX

put baseConvert(char 1 to 2 of HEX,16,10) into item 1 of RGB

put baseConvert(char 3 to 4 of HEX,16,10) into item 2 of RGB

put baseConvert(char 5 to 6 of HEX,16,10) into item 3 of RGB

return RGB

end priv_libColor_HEXtoRGB

function priv_libColor_ColorNametoRGB pName

return the cColorNameReference[pName] of stack "libColor"

end priv_libColor_ColorNametoRGB

function priv_libColor_ColorNametoHEX pName

return priv_libColor_RGBtoHEX(the cColorNameReference[pName] of stack "libColor")

end priv_libColor_ColorNametoHEX

function priv_libColor_ClosestMatchingColorName RGB

put the customProperties["cColorNameReference"] of me into tColors

repeat for each line tColorName in keys(tColors)

put abs(item 1 of RGB-item 1 of tColors[tColorName]) into tDistance

add abs(item 2 of RGB-item 2 of tColors[tColorName]) to tDistance

add abs(item 3 of RGB-item 3 of tColors[tColorName]) to tDistance

put tColorName,tDistance & cr after tResult

end repeat

delete last char of tResult

sort lines of tResult numeric by item 2 of each

return item 1 of tResult

end priv_libColor_ClosestMatchingColorName

function priv_libColor_HEXtoColorName HEX

return priv_libColor_ClosestMatchingColorName(priv_libColor_HEXtoRGB(HEX))

end priv_libColor_HEXtoColorName

-- HSV

function priv_libColor_RGBtoHSV rgb

put (item 1 of rgb / 255) into r

put (item 2 of rgb / 255) into g

put (item 3 of rgb / 255) into b

put max(r,g,b) into theMax

put theMax into v

put min(r,g,b) into theMin

put theMax - theMin into delta

if delta = 0 then

-- grey

multiply v by 255

return "0,0," & round(v)

else if theMax <> 0 then

put delta / theMax into s

else

-- r & g & b all = 0

put 0 into s

put 0 into h -- don't really know but this will do

return "0,0,0"

end if

if r = theMax then

put (g - b) / delta into h -- between yellow & magenta

else if g = theMax then

put 2 + (b - r) / delta into h -- between cyan & yellow

else

put 4 + (r - g) / delta into h -- between magenta & cyan

end if

multiply h by 60 -- convert to degrees

if h < 0 then add 360 to h

multiply s by 100 -- convert to percent

multiply v by 100 -- convert to percent

put round(h) & comma & round(s) & comma & round(v) into hsv

return hsv

end priv_libColor_RGBtoHSV

-- h = 0-360, s = 0-100, v = 0-100

--

function priv_libColor_HSVtoRGB hsv

put item 1 of hsv into h

put (item 2 of hsv / 100) into s

put (item 3 of hsv / 100) into v

if s = 0 then

-- grey

put v * 100 into temp

return temp & comma & temp & comma & temp

end if

divide h by 60

put trunc(h) into i

put h - i into f -- fractional part of h

put v * (1 - s) into p

put v * (1 - s * f) into q

put v * (1 - s * (1 - f)) into t

switch i

case 0

put v into r

put t into g

put p into b

break

case 1

put q into r

put v into g

put p into b

break

case 2

put p into r

put v into g

put t into b

break

case 3

put p into r

put q into g

put v into b

break

case 4

put t into r

put p into g

put v into b

break

case 5

put v into r

put p into g

put q into b

break

end switch

put round(r * 255) & comma & round(g * 255) & comma & round(b * 255) into rgb

return rgb

end priv_libColor_HSVtoRGB

-- CMYK

function priv_libColor_CMYKtoRGB CMYK

if (item 1 of CMYK + item 4 of CMYK) < 255 then

put 255 - (item 1 of CMYK + item 4 of CMYK) into R

else

put 0 into R

end if

if (item 2 of CMYK + item 4 of CMYK) < 255 then

put 255 - (item 2 of CMYK + item 4 of CMYK) into G

else

put 0 into G

end if

if (item 3 of CMYK + item 4 of CMYK) < 255 then

put 255 - (item 3 of CMYK + item 4 of CMYK) into B

else

put 0 into B

end if

return R & "," & G & "," & B

end priv_libColor_CMYKtoRGB

function priv_libColor_RGBtoCMYK RGB

put 255-item 1 of RGB into C

put 255-item 2 of RGB into M

put 255-item 3 of RGB into Y

put min(C,M,Y) into K

if K > 0 then

subtract K from C

subtract K from M

subtract K from Y

end if

return C & "," & M & "," & Y & "," & K

end priv_libColor_RGBtoCMYK

-- Pantone

function priv_libColor_PantoneToRGB Pantone

return the cPantoneReference[pName] of stack "libColor"

end priv_libColor_PantoneToRGB

function priv_libColor_ClosestMatchingPantone RGB

put the customProperties["cPantoneReference"] of me into tColors

repeat for each line tColorName in keys(tColors)

put abs(item 1 of RGB-item 1 of tColors[tColorName]) into tDistance

add abs(item 2 of RGB-item 2 of tColors[tColorName]) to tDistance

add abs(item 3 of RGB-item 3 of tColors[tColorName]) to tDistance

put tColorName,tDistance & cr after tResult

end repeat

delete last char of tResult

sort lines of tResult numeric by item 2 of each

return item 1 of tResult

end priv_libColor_ClosestMatchingPantone

 @22