macOS/iOS API解説

iOS , Mac アプリケーション開発のために使われる主要フレームワークの日本語情報です。2010年代に書かれた内容です。今後更新はありません。

目次

transformBezierPath:

Index>Foundation>NSAffineTransform

ベジエパスをレシーバの変換マトリックスで座標変換して新しいベジエパスを返します
-(NSBezierPath *)transformBezierPath:(NSBezierPath *)aPath:

解説

ベジエパス(aPath)をレシーバの変換マトリックスで座標変換して新しいベジエパスを返します。
(NSAffineTransformクラス、10.3までのAppKitから10.4からFoundationに変更)

返り値

( NSBezierPath * )

変換後のベジエパス

引数

( NSBezierPath * )aPath

変換前のベジエパス

クラス

NSAffineTransform

Instance Methods

使用可能

10.0

参照

- transformPoint:
- transformSize:

例文

#import "MyView.h"

@implementation MyView

//NSViewのサブクラス MyViewのDrawRectに上書き
-(void)drawRect:(NSRect)rect
{
	
	NSBezierPath *thePath1 = [NSBezierPath bezierPath];
	NSBezierPath *thePath2 = [NSBezierPath bezierPath];
	NSAffineTransform *affin = [NSAffineTransform transform];
	NSAffineTransform *affin2 = [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 translateXBy: 10.0 yBy: 10.0];
	[affin2 translateXBy: 10.0 yBy: 10.0];
	
	[affin appendTransform:affin2];
	
	thePath2 = [affin transformBezierPath: thePath1];
	
	[[NSColor redColor] set];
	[thePath2 fill];

}

@end