开发者

Quartz is drawing on a different window

I am trying to draw some pixels (NSRects that are 1x1) on a NSWindow in mac os, but when I do that it randomly pics a window to draw it o开发者_开发问答n (see below). It is supposed to be on the left window.

Quartz is drawing on a different window


-(void)draw:(NSRect)rect {
NSGraphicsContext *ctx = [[NSGraphicsContext currentContext] graphicsPort];

[NSGraphicsContext saveGraphicsState];

double perlinValue = [[[xValues objectAtIndex:x] objectAtIndex:y] floatValue];
[[NSColor colorWithCalibratedRed:perlinValue green:perlinValue blue:perlinValue alpha:1.0f] set];
NSRectFill(CGRectMake(x, y, 1, 1));

[NSGraphicsContext restoreGraphicsState];
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜