Changeset 5798
- Timestamp:
- May 10, 2008, 2:05:25 PM (14 years ago)
- Location:
- branches/1.2x/macosx/CTGradient
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/1.2x/macosx/CTGradient/CTGradient.h
r5785 r5798 3 3 // 4 4 // Created by Chad Weider on 2/14/07. 5 // Writtin by Chad Weider. 5 // Copyright (c) 2007 Chad Weider. 6 // Some rights reserved: <http://creativecommons.org/licenses/by/2.5/> 6 7 // 7 // Released into public domain on 4/10/08. 8 // 9 // Version: 1.8 8 // Version: 1.6 10 9 11 10 #import <Cocoa/Cocoa.h> … … 54 53 - (CTGradient *)gradientWithAlphaComponent:(float)alpha; 55 54 55 - (void)addElement:(CTGradientElement*)newElement; 56 56 57 - (CTGradient *)addColorStop:(NSColor *)color atPosition:(float)position; //positions given relative to [0,1] 57 58 - (CTGradient *)removeColorStopAtIndex:(unsigned)index; -
branches/1.2x/macosx/CTGradient/CTGradient.m
r5785 r5798 3 3 // 4 4 // Created by Chad Weider on 2/14/07. 5 // Writtin by Chad Weider. 5 // Copyright (c) 2007 Chad Weider. 6 // Some rights reserved: <http://creativecommons.org/licenses/by/2.5/> 6 7 // 7 // Released into public domain on 4/10/08. 8 // 9 // Version: 1.8 8 // Version: 1.6 10 9 11 10 #import "CTGradient.h" … … 609 608 610 609 611 return [NSColor colorWithCalibratedRed:components[0] /components[3] //undo premultiplication that CG requires612 green:components[1] /components[3]613 blue:components[2] /components[3]610 return [NSColor colorWithCalibratedRed:components[0] 611 green:components[1] 612 blue:components[2] 614 613 alpha:components[3]]; 615 614 } … … 687 686 CGContextRef currentContext = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort]; 688 687 CGContextSaveGState(currentContext); 689 #if MAC_OS_X_VERSION_M IN_REQUIRED >= MAC_OS_X_VERSION_10_4688 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4 690 689 CGColorSpaceRef colorspace = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB); 691 690 #else … … 704 703 - (void)radialFillRect:(NSRect)rect 705 704 { 706 CGPoint startPoint , endPoint;705 CGPoint startPoint , endPoint; 707 706 float startRadius, endRadius; 708 707 float scalex, scaley, transx, transy; … … 810 809 811 810 - (void)addElement:(CTGradientElement *)newElement 812 811 { 813 812 if(elementList == nil || newElement->position < elementList->position) //inserting at beginning of list 814 813 { … … 1009 1008 out[2] = (color2->blue - color1->blue )*position + color1->blue; 1010 1009 out[3] = (color2->alpha - color1->alpha)*position + color1->alpha; 1011 } 1012 1013 //Premultiply the color by the alpha. 1014 out[0] *= out[3]; 1015 out[1] *= out[3]; 1016 out[2] *= out[3]; 1010 } 1017 1011 } 1018 1012 … … 1103 1097 1104 1098 transformHSV_RGB(out); 1105 1106 //Premultiply the color by the alpha.1107 out[0] *= out[3];1108 out[1] *= out[3];1109 out[2] *= out[3];1110 1099 } 1111 1100 … … 1190 1179 1191 1180 transformHSV_RGB(out); 1192 1193 //Premultiply the color by the alpha. 1194 out[0] *= out[3]; 1195 out[1] *= out[3]; 1196 out[2] *= out[3]; 1197 } 1181 } 1182 1198 1183 1199 1184
Note: See TracChangeset
for help on using the changeset viewer.