rotateByDegrees:
Index>Foundation>NSAffineTransform
変換マトリックスの回転角度を度でセットします
-(void)rotateByDegrees:(float)angle:
解説
変換マトリックスの回転角度を度でセットします。
角度は反時計回りに増えていきます。
(NSAffineTransformクラス、10.3までのAppKitから10.4からFoundationに変更)
返り値
( void )
なし
引数
( float )angle
角度(度)
フレームワーク
Foundation
クラス
NSAffineTransform
Instance Methods
使用可能
10.0
参照
- rotateByRadians:
- scaleBy:
- scaleXBy:yBy:
- translateXBy:yBy:
例文
drawRect:以外で使う場合
//-rotateByDegrees: - (IBAction)method003:(id)sender { //make bezier path NSBezierPath *thePath1 = [NSBezierPath bezierPath]; //make affin transform NSAffineTransform *affin = [NSAffineTransform transform]; //NSAffineTransform *affin2 = [NSAffineTransform transform]; //focus window's view [_window.contentView lockFocus]; //clear window NSRect rect = [_window.contentView frame ]; [[NSColor windowBackgroundColor] set]; NSRectFill(rect); //set winding rule [thePath1 setWindingRule:NSEvenOddWindingRule]; [thePath1 moveToPoint:NSMakePoint(20,20)]; [thePath1 appendBezierPathWithOvalInRect:NSMakeRect(50,50,100,100)]; [thePath1 appendBezierPathWithOvalInRect:NSMakeRect(20,20,80,80)]; //1st drawing [[NSColor blueColor] set]; [thePath1 fill]; //add rotate transform [affin rotateByDegrees:30.0]; [thePath1 transformUsingAffineTransform: affin]; //2nd drawing [[NSColor redColor] set]; [thePath1 fill]; //unlock focus [_window.contentView unlockFocus]; [_window.contentView displayIfNeeded]; }
drawRect:で使う場合
#import "MyView.h" @implementation MyView -(void)drawRect:(NSRect)rect { NSBezierPath *thePath1 = [NSBezierPath bezierPath]; NSAffineTransform *affin = [NSAffineTransform transform]; [thePath1 setWindingRule:NSEvenOddWindingRule]; [thePath1 moveToPoint:NSMakePoint(20,20)]; [thePath1 appendBezierPathWithOvalInRect:NSMakeRect(50,50,100,100)]; [thePath1 appendBezierPathWithOvalInRect:NSMakeRect(20,20,80,80)]; [[NSColor blueColor] set]; [thePath1 fill]; [affin rotateByDegrees:30.0]; [thePath1 transformUsingAffineTransform: affin]; [[NSColor redColor] set]; [thePath1 fill]; } @end