00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 @import "CGColorSpace.j"
00025
00026
00027
00028 var CFTypeGlobalCount = 0;
00029
00030 function CFHashCode(aCFObject)
00031 {
00032 if (!aCFObject.hash)
00033 aCFObject.hash = ++CFTypeGlobalCount;
00034
00035 return aCFObject;
00036 }
00037
00038 kCGColorWhite = "kCGColorWhite";
00039 kCGColorBlack = "kCGColorBlack";
00040 kCGColorClear = "kCGColorClear";
00041
00042 var _CGColorMap = { };
00043
00044 function CGColorGetConstantColor(aColorName)
00045 {
00046 alert("FIX ME");
00047 }
00048
00052 function CGColorRetain(aColor)
00053 {
00054 return aColor;
00055 }
00056
00060 function CGColorRelease()
00061 {
00062 }
00063
00071 function CGColorCreate(aColorSpace, components)
00072 {
00073 if (!aColorSpace || !components)
00074 return NULL;
00075
00076 var components = components.slice();
00077
00078 CGColorSpaceStandardizeComponents(aColorSpace, components);
00079
00080 var UID = CFHashCode(aColorSpace) + components.join("");
00081
00082 if (_CGColorMap[UID])
00083 return _CGColorMap[UID];
00084
00085 return _CGColorMap[UID] = { colorspace:aColorSpace, pattern:NULL, components:components };
00086 }
00087
00096 function CGColorCreateCopy(aColor)
00097 {
00098
00099 return aColor;
00100 }
00101
00109 function CGColorCreateGenericGray(gray, alpha)
00110 {
00111 return CGColorCreate(0, [gray, alpha]);
00112 }
00113
00123 function CGColorCreateGenericRGB(red, green, blue, alpha)
00124 {
00125 return CGColorCreate(0, [red, green, blue, alpha]);
00126 }
00127
00138 function CGColorCreateGenericCMYK(cyan, magenta, yellow, black, alpha)
00139 {
00140 return CGColorCreate(0, [cyan, magenta, yellow, black, alpha]);
00141 }
00142
00150 function CGColorCreateCopyWithAlpha(aColor, anAlpha)
00151 {
00152 var components = aColor.components;
00153
00154 if (!aColor || anAlpha == components[components.length - 1])
00155 return aColor;
00156
00157 if (aColor.pattern)
00158 var copy = CGColorCreateWithPattern(aColor.colorspace, aColor.pattern, components);
00159 else
00160 var copy = CGColorCreate(aColor.colorspace, components);
00161
00162 copy.components[components.length - 1] = anAlpha;
00163
00164 return copy;
00165 }
00166
00175 function CGColorCreateWithPattern(aColorSpace, aPattern, components)
00176 {
00177 if (!aColorSpace || !aPattern || !components)
00178 return NULL;
00179
00180 return { colorspace:aColorSpace, pattern:aPattern, components:components.slice() };
00181 }
00182
00190 function CGColorEqualToColor(lhs, rhs)
00191 {
00192 if (lhs == rhs)
00193 return true;
00194
00195 if (!lhs || !rhs)
00196 return false;
00197
00198 var lhsComponents = lhs.components,
00199 rhsComponents = rhs.components,
00200 lhsComponentCount = lhsComponents.length;
00201
00202 if (lhsComponentCount != rhsComponents.length)
00203 return false;
00204
00205 while (lhsComponentCount--)
00206 if (lhsComponents[lhsComponentCount] != rhsComponents[lhsComponentCount])
00207 return false;
00208
00209 if (lhs.pattern != rhs.pattern)
00210 return false;
00211
00212 if (CGColorSpaceEqualToColorSpace(lhs.colorspace, rhs.colorspace))
00213 return false;
00214
00215 return true;
00216 }
00217
00224 function CGColorGetAlpha(aColor)
00225 {
00226 var components = aColor.components;
00227
00228 return components[components.length - 1];
00229 }
00230
00236 function CGColorGetColorSpace(aColor)
00237 {
00238 return aColor.colorspace;
00239 }
00240
00247 function CGColorGetComponents(aColor)
00248 {
00249 return aColor.components;
00250 }
00251
00259 function CGColorGetNumberOfComponents(aColor)
00260 {
00261 return aColor.components.length;
00262 }
00263
00270 function CGColorGetPattern(aColor)
00271 {
00272 return aColor.pattern;
00273 }
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288