Drawing strings at 20fps
Drawing strings at 20fps
- Subject: Drawing strings at 20fps
- From: Jules Bonin-Ducharme <email@hidden>
- Date: Wed, 21 Jul 2004 18:33:50 -0700
Hi list,
I have a 64 X 64 grid of 3 character strings to display at 20 fps. These
strings can (as a worst case) all change from 0 to 127 at the same rate.
The background is white and there is also a grid that9s separates the
strings to be displayed.
I have overridden the isOpaque to return YES. In my drawRect:(NSRect)rect
method, I only draw the background on rect. I have a NSBezierPath defined
with 64 horizontal lines and 64 vertical lines.
I have an array of 64 strings that contain 64 sets of monospaced characters
(ex: @"127 127 127 127 127..." etc) so that I only have to draw 64 strings
instead of 64 X 64 (4096) strings.
I have a method that updates a specific substring using a line like this:
[[inputRows objectAtIndex:inch-1]
replaceCharactersInRange:NSMakeRange((ouch - 1) * 4, 3)
withString:[NSString stringWithFormat:@"%d",level]];
This is called followed by a [view setNeedsDisplay:YES] at 20 fps using a
NSTimer.
I get a really slow result. Things are not updated smoothly especially when
my app is full screen.
How would I go about drawing what is essentially something that looks like a
spreadsheet with changing values at 20fps?
Any help would be appreciated.
Cheers,
Jules Bonin-Ducharme
Here is my drawRect method.
--------------------------------
- (void)drawRect:(NSRect)rect
{
[[NSColor whiteColor] set];
NSFillRect(rect);
paint the grid
[[NSColor blackColor] set];
[grid stroke];
// draw each input row strings
int i;
for (i = 0; i < 64; i++) {
[[inputRows objectAtIndex:i]
drawAtPoint:NSMakePoint(4, ((64 - 1 - i) * 15) + 1)
withAttributes:attributes];
}
}
--------------------------------------
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.