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