macOS/iOS API解説

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

目次

bezierPathByReversingPath

INDEX>AppKit>NSBezier

パスを逆向きにして新しいベジエパスオブジェクトを作って返します

解説

レシーバのパスを逆向きにして新しいベジエパスオブジェクトを作って返します。
(逆というのは、描画順が逆。PostScriptと同じく向きが逆になることで、重なった塗りオブジェクトがくりぬかれます。)

重なった図形が違う描画方向だとくり抜かれる
f:id:jjj777:20150301215440p:plain

重なった画像が同じ描画方向だとくり抜かれない
f:id:jjj777:20150301215433p:plain

返り値

( NSBezierPath * )

逆にしたパス

引数

フレームワーク

ApplicationKit

クラス

NSBezierPath

使用可能

10.0

参照

例文

//NSViewのサブクラス MyViewのDrawRectに上書き
-(void)drawRect:(NSRect)rect
{

NSBezierPath *thePath = [NSBezierPath bezierPath];
NSBezierPath *revPath = [NSBezierPath bezierPath];


[thePath appendBezierPath:[NSBezierPath bezierPathWithOvalInRect:NSMakeRect(50,50,150,100)]];
[[NSColor redColor] set];


[revPath appendBezierPath:[NSBezierPath bezierPathWithOvalInRect:NSMakeRect(60,60,100,100)]];
revPath = [revPath bezierPathByReversingPath];

[thePath appendBezierPath:revPath];
[[NSColor redColor] set];

[thePath fill];


}