Re: Quickest Drawing Method
Re: Quickest Drawing Method
- Subject: Re: Quickest Drawing Method
- From: spiderlama <email@hidden>
- Date: Wed, 25 Jul 2007 10:33:44 +1000
Ok here's my updated drawing code. I'm not able to test it in shark
right now because I'm having trouble loading the CGImageRef's. After
pouring over Apple's Quartz drawing guide, I think it can't get any
faster...
- (void)drawRect:(NSRect)rect {
float takeIn = rect.size.height * 3/4; // amount to go in at edges
CGContextRef myContext = [[NSGraphicsContext currentContext]
graphicsPort]; // obtain graphics context for this view
CGContextClearRect(myContext, *(CGRect*)&rect); // clear
// create clipping path
CGContextBeginPath(myContext); // begin path
CGContextMoveToPoint(myContext, 0, 0); // move to start
CGContextAddLineToPoint(myContext, takeIn, rect.size.height); //
left edge
CGContextAddLineToPoint(myContext, rect.size.width - takeIn,
rect.size.height); // right edge
CGContextAddLineToPoint(myContext, rect.size.width, 0); // bottom
right corner
CGContextClosePath(myContext); // close shape
CGContextClip(myContext); // clip to path
CGContextDrawImage(myContext, *(CGRect*)&rect, scurve); // scurve
NSRect frontlineRect;
frontlineRect = NSMakeRect(0, 0, rect.size.width, 2); // we know the
height is 2
CGContextDrawImage(myContext, *(CGRect*)&frontlineRect,
frontline); // frontline
}
And it gets called like this:
- (void)applicationDidFinishLaunching:(NSNotification*)theNotification {
...
[NSTimer scheduledTimerWithTimeInterval:0.1 target:self
selector:@selector(resize) userInfo:nil repeats:YES];
}
- (void)resize {
[window setFrame:rect display:YES animate:NO]; // window contains
our view subclass
}
I wish there was a better way than using NSTimer.
Cheers
Matt
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden