![]() |
IAIPaint.hGo to the documentation of this file.00001 #ifndef _IAIPAINT_H_ 00002 #define _IAIPAINT_H_ 00003 00004 /* 00005 * Name: IAIPaint.h 00006 * $Revision: 1 $ 00007 * Author: 00008 * Date: 00009 * Purpose: C++ wrapper class for AIColor. 00010 * 00011 * ADOBE SYSTEMS INCORPORATED 00012 * Copyright 1986-2007 Adobe Systems Incorporated. 00013 * All rights reserved. 00014 * 00015 * NOTICE: Adobe permits you to use, modify, and distribute this file 00016 * in accordance with the terms of the Adobe license agreement 00017 * accompanying it. If you have received this file from a source other 00018 * than Adobe, then your use, modification, or distribution of it 00019 * requires the prior written permission of Adobe. 00020 * 00021 */ 00022 00023 #include "AIColor.h" 00024 #include "AIRealMath.h" 00025 00026 namespace ai { 00027 00031 class Paint : public AIColor { 00032 public: 00034 static Paint& cast (AIColor& c); 00036 static const Paint& constcast (const AIColor& c); 00037 00039 Paint (); 00040 00042 bool operator == (const AIColor& b) const; 00043 }; 00044 00045 00046 //-------------------------------------------------------------------------------- 00047 // A partial paint describes a paint that may have some unknown values. 00048 //-------------------------------------------------------------------------------- 00049 00053 class PartialPaint { 00054 public: 00056 PartialPaint (); 00062 PartialPaint (const AIColor& color, const AIColorMap& colormap); 00063 00067 bool IsFullyDefined () const; 00068 00069 protected: 00070 Paint fPaint; 00071 AIColorMap fMap; 00072 }; 00073 00074 00075 //-------------------------------------------------------------------------------- 00076 // Paint implementation 00077 //-------------------------------------------------------------------------------- 00078 00079 inline Paint& Paint::cast (AIColor& c) 00080 { 00081 return static_cast<Paint&>(c); 00082 } 00083 00084 inline const Paint& Paint::constcast (const AIColor& c) 00085 { 00086 return static_cast<const Paint&>(c); 00087 } 00088 00089 inline Paint::Paint () 00090 { 00091 kind = kNoneColor; 00092 } 00093 00094 inline bool Paint::operator == (const AIColor& b) const 00095 { 00096 00097 bool result = false; 00098 00099 if (kind == b.kind) 00100 { 00101 switch (kind) 00102 { 00103 case kGrayColor: 00104 { 00105 if (c.g.gray == b.c.g.gray) 00106 { 00107 result = true; 00108 } 00109 break; 00110 } 00111 case kFourColor: 00112 { 00113 if (c.f.cyan == b.c.f.cyan && 00114 c.f.magenta == b.c.f.magenta && 00115 c.f.yellow == b.c.f.yellow && 00116 c.f.black == b.c.f.black) 00117 { 00118 result = true; 00119 } 00120 break; 00121 } 00122 case kPattern: 00123 { 00124 if (c.p.pattern == b.c.p.pattern && 00125 c.p.shiftDist == b.c.p.shiftDist && 00126 c.p.shiftAngle == b.c.p.shiftAngle && 00127 c.p.scale.h == b.c.p.scale.h && 00128 c.p.scale.v == b.c.p.scale.v && 00129 c.p.rotate == b.c.p.rotate && 00130 c.p.reflect == b.c.p.reflect && 00131 c.p.reflectAngle == b.c.p.reflectAngle && 00132 c.p.shearAngle == b.c.p.shearAngle && 00133 c.p.shearAxis == b.c.p.shearAxis && 00134 sAIRealMath->AIRealMatrixEqual((AIRealMatrix *)&c.p.transform, (AIRealMatrix *)&b.c.p.transform)) 00135 { 00136 result = true; 00137 } 00138 break; 00139 } 00140 case kCustomColor: 00141 { 00142 if (c.c.color == b.c.c.color && 00143 c.c.tint == b.c.c.tint) 00144 { 00145 result = true; 00146 } 00147 break; 00148 } 00149 case kGradient: 00150 { 00151 if (c.b.gradient == b.c.b.gradient && 00152 c.b.gradientOrigin.h == b.c.b.gradientOrigin.h && 00153 c.b.gradientOrigin.v == b.c.b.gradientOrigin.v && 00154 c.b.gradientAngle == b.c.b.gradientAngle && 00155 c.b.gradientLength == b.c.b.gradientLength && 00156 sAIRealMath->AIRealMatrixEqual((AIRealMatrix *)&c.b.matrix, (AIRealMatrix *)&b.c.b.matrix) && 00157 c.b.hiliteAngle == b.c.b.hiliteAngle && 00158 c.b.hiliteLength == b.c.b.hiliteLength) 00159 { 00160 result = true; 00161 } 00162 break; 00163 } 00164 case kThreeColor: 00165 { 00166 if (c.rgb.red == b.c.rgb.red && 00167 c.rgb.green == b.c.rgb.green && 00168 c.rgb.blue == b.c.rgb.blue) 00169 { 00170 result = true; 00171 } 00172 break; 00173 } 00174 } 00175 } 00176 00177 return result; 00178 } 00179 00180 00181 //-------------------------------------------------------------------------------- 00182 // PartialPaint implementation 00183 //-------------------------------------------------------------------------------- 00184 00185 inline PartialPaint::PartialPaint () : 00186 fPaint() 00187 { 00188 fMap.kind = false; 00189 } 00190 00191 inline PartialPaint::PartialPaint (const AIColor& color, const AIColorMap& colormap) : 00192 fPaint(static_cast<const Paint&>(color)), fMap(colormap) 00193 { 00194 } 00195 00196 inline bool PartialPaint::IsFullyDefined () const 00197 { 00198 bool result = false; 00199 00200 if (fMap.kind) 00201 { 00202 switch (fPaint.kind) 00203 { 00204 case kGrayColor: 00205 result = fMap.c.g.gray != 0; 00206 break; 00207 00208 case kThreeColor: 00209 result = fMap.c.rgb.red && 00210 fMap.c.rgb.green && 00211 fMap.c.rgb.blue; 00212 break; 00213 00214 case kFourColor: 00215 result = fMap.c.f.cyan && 00216 fMap.c.f.magenta && 00217 fMap.c.f.yellow && 00218 fMap.c.f.black; 00219 break; 00220 00221 case kCustomColor: 00222 result = fMap.c.c.color && 00223 fMap.c.c.tint; 00224 break; 00225 00226 case kPattern: 00227 result = fMap.c.p.pattern && 00228 fMap.c.p.shiftDist && 00229 fMap.c.p.shiftAngle && 00230 fMap.c.p.scale && 00231 fMap.c.p.rotate && 00232 fMap.c.p.reflect && 00233 fMap.c.p.reflectAngle && 00234 fMap.c.p.shearAngle && 00235 fMap.c.p.shearAxis && 00236 fMap.c.p.transform; 00237 break; 00238 00239 case kGradient: 00240 result = fMap.c.b.gradient && 00241 fMap.c.b.gradientOrigin && 00242 fMap.c.b.gradientAngle && 00243 fMap.c.b.gradientLength && 00244 fMap.c.b.matrix && 00245 fMap.c.b.hiliteAngle && 00246 fMap.c.b.hiliteLength; 00247 break; 00248 } 00249 } 00250 00251 return result; 00252 } 00253 00254 // end of namespace ai 00255 } 00256 00257 00258 #endif |
||||||
|
![]() |
|