Changeset 5785


Ignore:
Timestamp:
May 9, 2008, 1:50:15 PM (14 years ago)
Author:
livings124
Message:

update CTGradient to 1.8

Location:
trunk/macosx/CTGradient
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/CTGradient/CTGradient.h

    r1919 r5785  
    33//
    44//  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.
    76//
    8 //  Version: 1.6
     7//  Released into public domain on 4/10/08.
     8// 
     9//  Version: 1.8
    910
    1011#import <Cocoa/Cocoa.h>
     
    5354- (CTGradient *)gradientWithAlphaComponent:(float)alpha;
    5455
    55 - (void)addElement:(CTGradientElement*)newElement;
    56 
    5756- (CTGradient *)addColorStop:(NSColor *)color atPosition:(float)position;       //positions given relative to [0,1]
    5857- (CTGradient *)removeColorStopAtIndex:(unsigned)index;
  • trunk/macosx/CTGradient/CTGradient.m

    r1919 r5785  
    33//
    44//  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.
    76//
    8 //  Version: 1.6
     7//  Released into public domain on 4/10/08.
     8//
     9//  Version: 1.8
    910
    1011#import "CTGradient.h"
     
    608609 
    609610 
    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]
    613614                                                                   alpha:components[3]];
    614615  }
     
    686687  CGContextRef currentContext = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort];
    687688  CGContextSaveGState(currentContext);
    688           #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
     689          #if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_4
    689690                CGColorSpaceRef colorspace = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB);
    690691          #else
     
    703704- (void)radialFillRect:(NSRect)rect
    704705  {
    705   CGPoint startPoint , endPoint;
     706  CGPoint startPoint, endPoint;
    706707  float startRadius, endRadius;
    707708  float scalex, scaley, transx, transy;
     
    809810
    810811- (void)addElement:(CTGradientElement *)newElement
    811 {
     812  {
    812813  if(elementList == nil || newElement->position < elementList->position)        //inserting at beginning of list
    813814        {
     
    10081009        out[2] = (color2->blue  - color1->blue )*position + color1->blue;
    10091010        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];
    10111017  }
    10121018
     
    10971103   
    10981104  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];
    10991110  }
    11001111
     
    11791190   
    11801191  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  }
    11831198
    11841199
Note: See TracChangeset for help on using the changeset viewer.