@@ -48,12 +48,6 @@ of this software and associated documentation files (the "Software"), to deal
48
48
49
49
BOOL usingMATrackingArea = NO ;
50
50
51
- @interface NSBezierPath (MRGradientFill)
52
- -(void )linearGradientFill : (NSRect )thisRect
53
- startColor : (NSColor *)startColor
54
- endColor : (NSColor *)endColor ;
55
- @end
56
-
57
51
@interface CTFClickToFlashPlugin (Internal)
58
52
- (void ) _convertTypesForFlashContainer ;
59
53
- (void ) _convertTypesForFlashContainerAfterDelay ;
@@ -766,22 +760,10 @@ - (void) _drawBackground
766
760
gradient = [CTGradient gradientWithBeginningColor: startingColor
767
761
endingColor: endingColor];
768
762
769
- // angle is reversed
763
+ // angle is reversed compared to NSGradient
770
764
[gradient fillBezierPath: [NSBezierPath bezierPathWithRect: fillRect] angle: -90.0 - ((mouseIsDown && mouseInside) ? 0.0 : 180.0 )];
771
765
772
766
// CTGradient instances are returned autoreleased - no need for explicit release here
773
-
774
- /* Old Tiger gradient code - remove if CTGradient works out
775
- //tweak colors for better compatibility with linearGradientFill
776
- startingColor = [NSColor colorWithDeviceWhite:0.633 alpha:0.15];
777
- endingColor = [NSColor colorWithDeviceWhite:0.333 alpha:0.15];
778
- NSBezierPath *path = [NSBezierPath bezierPath];
779
-
780
- //Draw Gradient
781
- [path linearGradientFill:fillRect
782
- startColor:((mouseIsDown && mouseInside) ? endingColor : startingColor)
783
- endColor:((mouseIsDown && mouseInside) ? startingColor : endingColor)];
784
- [path stroke];*/
785
767
}
786
768
787
769
// Draw stroke
@@ -1192,114 +1174,4 @@ - (void)setLaunchedAppBundleIdentifier:(NSString *)newValue
1192
1174
[_launchedAppBundleIdentifier release ];
1193
1175
_launchedAppBundleIdentifier = newValue;
1194
1176
}
1195
-
1196
- @end
1197
-
1198
-
1199
- // ### globals
1200
- float start_red,
1201
- start_green,
1202
- start_blue,
1203
- start_alpha;
1204
- float end_red,
1205
- end_green,
1206
- end_blue,
1207
- end_alpha;
1208
- float d_red,
1209
- d_green,
1210
- d_blue,
1211
- d_alpha;
1212
-
1213
- @implementation NSBezierPath (MRGradientFill)
1214
-
1215
- static void
1216
- evaluate (void *info, const float *in, float *out)
1217
- {
1218
- // red
1219
- *out++ = start_red + *in * d_red;
1220
-
1221
- // green
1222
- *out++ = start_green + *in * d_green;
1223
-
1224
- // blue
1225
- *out++ = start_blue + *in * d_blue;
1226
-
1227
- // alpha
1228
- *out++ = start_alpha + *in * d_alpha;
1229
- }
1230
-
1231
- float absDiff (float a, float b);
1232
- float absDiff (float a, float b)
1233
- {
1234
- return (a < b) ? b-a : a-b;
1235
- }
1236
-
1237
- -(void )linearGradientFill : (NSRect )thisRect
1238
- startColor : (NSColor *)startColor
1239
- endColor : (NSColor *)endColor
1240
- {
1241
- CGColorSpaceRef colorspace = nil ;
1242
- CGShadingRef shading;
1243
- static CGPoint startPoint = { 0 , 0 };
1244
- static CGPoint endPoint = { 0 , 0 };
1245
- // int k;
1246
- CGFunctionRef function;
1247
- // CGFunctionRef (*getFunction)(CGColorSpaceRef);
1248
- // CGShadingRef (*getShading)(CGColorSpaceRef, CGFunctionRef);
1249
-
1250
- // get my context
1251
- CGContextRef currentContext =
1252
- (CGContextRef )[[NSGraphicsContext currentContext ] graphicsPort ];
1253
-
1254
-
1255
- NSColor *s = [startColor colorUsingColorSpaceName: NSDeviceRGBColorSpace ];
1256
- NSColor *e = [endColor colorUsingColorSpaceName: NSDeviceRGBColorSpace ];
1257
-
1258
- // set up colors for gradient
1259
- start_red = [s redComponent ];
1260
- start_green = [s greenComponent ];
1261
- start_blue = [s blueComponent ];
1262
- start_alpha = [s alphaComponent ];
1263
-
1264
- end_red = [e redComponent ];
1265
- end_green = [e greenComponent ];
1266
- end_blue = [e blueComponent ];
1267
- end_alpha = [e alphaComponent ];
1268
-
1269
- d_red = absDiff (end_red, start_red);
1270
- d_green = absDiff (end_green, start_green);
1271
- d_blue = absDiff (end_blue, start_blue);
1272
- d_alpha = absDiff (end_alpha ,start_alpha);
1273
-
1274
-
1275
- // draw gradient
1276
- colorspace = CGColorSpaceCreateDeviceRGB ();
1277
-
1278
- size_t components;
1279
- static const float domain[2 ] = { 0.0 , 1.0 };
1280
- static const float range[10 ] = { 0 , 1 , 0 , 1 , 0 , 1 , 0 , 1 , 0 , 1 };
1281
- static const CGFunctionCallbacks callbacks = { 0 , &evaluate, NULL };
1282
-
1283
- components = 1 + CGColorSpaceGetNumberOfComponents (colorspace);
1284
- function = CGFunctionCreate ((void *)components, 1 , domain, components,
1285
- range, &callbacks);
1286
-
1287
- // function = getFunction(colorspace);
1288
- startPoint.x = 0 ;
1289
- startPoint.y = thisRect.origin .y ;
1290
- endPoint.x = 0 ;
1291
- endPoint.y = NSMaxY (thisRect);
1292
-
1293
-
1294
- shading = CGShadingCreateAxial (colorspace,
1295
- startPoint, endPoint,
1296
- function,
1297
- NO , NO );
1298
-
1299
- CGContextDrawShading (currentContext, shading);
1300
-
1301
- CGFunctionRelease (function);
1302
- CGShadingRelease (shading);
1303
- CGColorSpaceRelease (colorspace);
1304
- }
1305
1177
@end
0 commit comments