• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
(no subject)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

(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


  • Prev by Date: Re: detect button selection in NSMatrix
  • Next by Date: NSButton
  • Previous by thread: Re: Prevent resizing of NSWindow
  • Next by thread: (no subject)
  • Index(es):
    • Date
    • Thread