Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > bezierpath problems

bezierpath problems
Thread Tools
Senior User
Join Date: Jun 2002
Location: UK
Status: Offline
Reply With Quote
Jan 22, 2003, 10:36 AM
 
- (void)drawRectNSRect)frameRect
{
NSPoint point0;
NSPoint point1;
int i;
bezier = [NSBezierPath bezierPath];

minMaxArray = [...];

NSMutableArray *minMaxDate;
minMaxDate = [[NSMutableArray alloc] init];
[minMaxDate setArray:[...]];

point0.x = frameRect.origin.x;
point0.y = (frameRect.size.height * ([[[minMaxDate objectAtIndex: 0] objectForKey:@"KEY"] intValue]) / ([[[minMaxArray objectAtIndex[minMaxArray count] -1)] objectForKey: @"KEY"] intValue] - [[[minMaxArray objectAtIndex:0] objectForKey: @"KEY"] intValue]));

for(i=1; i < ([minMaxDate count]); i++)
{
point1.x = point0.x + (frameRect.size.width / ([minMaxDate count]));
point1.y = (frameRect.size.height * ([[[minMaxDate objectAtIndex: i] objectForKey:@"KEY"] intValue]) / ([[[minMaxArray objectAtIndex[minMaxArray count] -1)] objectForKey: @"KEY"] intValue] - [[[minMaxArray objectAtIndex:0] objectForKey: @"KEY"] intValue]));

[bezier moveToPointoint0];
[bezier lineToPointoint1];

[NSBezierPath strokeLineFromPointoint0 toPointoint1];

/* Also tried this

[bezier moveToPointoint0];

[bezier lineToPointoint1];
*/
point0.x = point1.x;
point0.y = point1.y;
}
}
     
Posting Junkie
Join Date: Feb 2000
Location: Washington, DC
Status: Offline
Reply With Quote
Jan 22, 2003, 10:46 AM
 
Wow, I don't code much, but that's a hard sell... perhaps you should have used the code/text tag or something...
     
Mac Enthusiast
Join Date: Sep 2000
Location: Vermont, USA
Status: Offline
Reply With Quote
Jan 22, 2003, 12:45 PM
 
What exactly is the problem?
     
Mac Elite
Join Date: Sep 2000
Location: Tempe, AZ
Status: Offline
Reply With Quote
Jan 22, 2003, 12:57 PM
 
Yeah, between the smilies, the lack of whitespace formatting, and the not telling us what the problem is, that's a toughie.
Geekspiff - generating spiffdiddlee software since before you began paying attention.
     
VEGAN  (op)
Senior User
Join Date: Jun 2002
Location: UK
Status: Offline
Reply With Quote
Jan 22, 2003, 12:58 PM
 
Originally posted by macrophyllum:
What exactly is the problem?
How about this "No lines appear on the view" for a problem?
     
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status: Offline
Reply With Quote
Jan 22, 2003, 03:24 PM
 
Well, you do realize that you can't normally predict what the argument for drawRect: will be, right? It could be any arbitrary rectangle within your view. Using its properties for anything other than clipping is an iffy proposition.

With the utter lack of explanation as to what you intend for the code to do and what the variables represent, that's about all anyone could possibly say.
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
     
Mac Elite
Join Date: Sep 2000
Location: Tempe, AZ
Status: Offline
Reply With Quote
Jan 22, 2003, 09:46 PM
 
It might help to add an '[[NSColor blackColor] set]' in there before you do the drawing.
Geekspiff - generating spiffdiddlee software since before you began paying attention.
     
VEGAN  (op)
Senior User
Join Date: Jun 2002
Location: UK
Status: Offline
Reply With Quote
Jan 23, 2003, 08:57 AM
 
Originally posted by Chuckit:
Well, you do realize that you can't normally predict what the argument for drawRect: will be, right? It could be any arbitrary rectangle within your view. Using its properties for anything other than clipping is an iffy proposition.

With the utter lack of explanation as to what you intend for the code to do and what the variables represent, that's about all anyone could possibly say.
I'm trying to draw a line that connects points that are given by minMaxArray and minMaxDate [that take the values from a NSDictionary.
     
VEGAN  (op)
Senior User
Join Date: Jun 2002
Location: UK
Status: Offline
Reply With Quote
Jan 23, 2003, 09:07 AM
 
Originally posted by smeger:
It might help to add an '[[NSColor blackColor] set]' in there before you do the drawing.
Nope, didn't do much good
     
Mac Enthusiast
Join Date: Sep 2000
Location: Vermont, USA
Status: Offline
Reply With Quote
Jan 23, 2003, 01:02 PM
 
After calling
[bezier moveToPoint:point0];
[bezier lineToPoint:point1];

try putting:
[bezier stroke];

Also, in case the points aren't comming from the dictionary so well, try making up some arbitrary points first.

For example:
point0 = NSMakePoint(10, 50);
point1 = NSMakePoint(30, 100);

Of course, define your points before you use call the moveTo, lineTo and stroke methods.

Goodluck.
     
Mac Enthusiast
Join Date: Sep 2000
Location: Vermont, USA
Status: Offline
Reply With Quote
Jan 23, 2003, 01:23 PM
 
After calling
[bezier moveToPoint:point0];
[bezier lineToPoint:point1];

try putting:
[bezier stroke];

Also, in case the points aren't comming from the dictionary so well, try making up some arbitrary points first.

For example:
point0 = NSMakePoint(10, 50);
point1 = NSMakePoint(30, 100);

Of course, define your points before you use call the moveTo, lineTo and stroke methods.

Goodluck.
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 02:05 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2