(no subject)
(no subject)
- Subject: (no subject)
- From: Akira8 <email@hidden>
- Date: Mon, 8 Oct 2007 12:27:34 +0200
Hi!
How can I create simple program that draws rectangle in every x
second. My actual app redraws NSView every x second. How can I just
add new points instead of redrawing all of them with for statement?
#import "AnimationView.h"
@implementation AnimationView
- (id)initWithFrame:(NSRect)frame {
self = [super initWithFrame:frame];
if (self) {
iterator = 1;
[NSTimer scheduledTimerWithTimeInterval:0.1
target:self
selector:@selector(stepAnimation:)
userInfo:nil
repeats:YES];
}
return self;
}
- (void)drawRect:(NSRect)rect {
iterator++;
NSRect shape;
NSBezierPath *bp;
[[NSColor redColor] set];
for(i=0; i < iterator; i++) {
shape = NSMakeRect(5, 5, 1, 1+i);
bp = [[NSBezierPath bezierPathWithRect:shape] retain];
[bp fill];
}
}
- (void)stepAnimation:(NSTimer *)timer
{
[self setNeedsDisplay:YES];
}
@end
Thanks.
_______________________________________________
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