NSGradient:initWithColors:atLocations:colorSpace:
Home 目次>ApplicationKit>NSGradient
10.5

initWithColors:atLocations:colorSpace:

指定したカラーの配列と位置の配列でグラデーションオブジェクトを初期化して返します


-(id) initWithColors:(NSArray *)colorArray
   atLocations:(CGFloat *)locations
   colorSpace:(NSColorSpace *)colorSpace


【返り値】
   idグラデーションオブジェクト(NSGradient)
【パラメータ】
   colorArrayカラーの配列
   locationsカラーの配列に対応する位置の配列(それぞれ0.0から1.0の範囲内)
   colorSpaceカラースペース


【解説】

指定したカラーの配列と位置の配列でグラデーションオブジェクトを初期化して返します。



【例文】


#import "MyObject.h"

@implementation MyObject

- (IBAction)myAction:(id)sender
{
CGFloat colorLocations[3];
colorLocations[0]= 0.0;
colorLocations[1]= 0.3;
colorLocations[2]= 1.0;

NSGradient *gradient = [[NSGradient alloc] initWithColors:
[NSArray arrayWithObjects:
[NSColor redColor],
[NSColor blueColor],
[NSColor greenColor],
nil
]
atLocations: colorLocations
colorSpace: [NSColorSpace deviceRGBColorSpace]
];
[theView lockFocus];
[gradient drawInRect: NSMakeRect(0,0,100,100) angle:(CGFloat)[theSlider floatValue]];
[theView unlockFocus];
}

@end


(C) 2000-2007 Satoshi Oomori.
[Apple]

Google
Webwww.oomori.com
Apple_Store_40x120

[ad:Usual day in Japan]

この記事を評価してください。 

良い 

間違いがある 説明がわかりにくい 例文がわかりにくい  

Home 目次>ApplicationKit>NSGradient
修正日2006.12.26