Changeset 370 for trunk/Cocoa/AntiRSI/CTBadge
- Timestamp:
- 12/08/07 06:07:14 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Cocoa/AntiRSI/CTBadge/CTGradient.m
r332 r370 779 779 - (void)setBlendingMode:(CTGradientBlendingMode)mode; 780 780 { 781 blendingMode = mode;782 783 781 //Choose what blending function to use 784 782 void *evaluationFunction; 785 switch( blendingMode)783 switch(mode) 786 784 { 787 785 case CTLinearBlendingMode: … … 791 789 case CTInverseChromaticBlendingMode: 792 790 evaluationFunction = &inverseChromaticEvaluation; break; 793 } 794 791 default: 792 NSParameterAssert("blending mode not supported" && NO); 793 return; // unreachable, satisfy compiler 794 } 795 796 blendingMode = mode; 797 795 798 //replace the current CoreGraphics Function with new one 796 799 if(gradientFunction != NULL) … … 1183 1186 1184 1187 1185 void transformRGB_HSV(float *components) //H,S,B -> R,G,B 1186 { 1187 float H, S, V; 1188 void transformRGB_HSV(float *components) //H,S,B <- R,G,B 1189 { 1188 1190 float R = components[0], 1189 1191 G = components[1], … … 1193 1195 MIN = R < G ? (R < B ? R : B) : (G < B ? G : B); 1194 1196 1195 if(MAX == MIN) 1196 H = NAN; 1197 else if(MAX == R) 1198 if(G >= B) 1199 H = 60*(G-B)/(MAX-MIN)+0; 1200 else 1201 H = 60*(G-B)/(MAX-MIN)+360; 1202 else if(MAX == G) 1203 H = 60*(B-R)/(MAX-MIN)+120; 1204 else if(MAX == B) 1205 H = 60*(R-G)/(MAX-MIN)+240; 1206 1207 S = MAX == 0 ? 0 : 1 - MIN/MAX; 1208 V = MAX; 1197 float H = NAN; 1198 1199 if(MAX != MIN) 1200 { 1201 if(MAX == R) 1202 if(G >= B) 1203 H = 60*(G-B)/(MAX-MIN)+0; 1204 else 1205 H = 60*(G-B)/(MAX-MIN)+360; 1206 else if(MAX == G) 1207 H = 60*(B-R)/(MAX-MIN)+120; 1208 else if(MAX == B) 1209 H = 60*(R-G)/(MAX-MIN)+240; 1210 } 1211 1212 float S = MAX == 0 ? 0 : 1 - MIN/MAX; 1213 float V = MAX; 1209 1214 1210 1215 components[0] = H; … … 1234 1239 case 4: R=t;G=p;B=V; break; 1235 1240 case 5: R=V;G=p;B=q; break; 1241 default: R=0;G=0;B=0; // unreachable, satisfy compiler 1236 1242 } 1237 1243
Note:
See TracChangeset
for help on using the changeset viewer.