ApCoCoA

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: Setting line width
PostPosted: Thu Jan 08, 2009 4:00 pm 
Offline

Joined: Thu Jan 08, 2009 3:25 pm
Posts: 1
I am learning cocoa from the book: building cocoa application... I have followed the instruction in chapter 16 which allows me to plot any function: display is the drawRect method below:

-(void)drawRect:(NSRect )rect
{
id obj=nil;
NSEnumerator *en;
NSSize sz;

[ [NSColor whiteColor] set];
NSRectFill(rect);

sz = [self convertSize:NSMakeSize(1,1) fromView:nil];
[NSBezierPath setDefaultLineWidth:MAX(sz.width,sz.height)];

en = [displayList objectEnumerator];
while (obj = [en nextObject]) {
if (NSIntersectsRect(rect,[obj bounds]) ) {
[obj stroke];
}
}
}

This method first initializes the background to white then determine the appropriate line width for drawing the graph and sets the current line width accordingly. This is where problem lies: If xmin=ymin, xmax=ymax that is |xmin|=|ymin| =|xmax|=|ymax| such that you have a square box then everything is ok. However If xmin=-1 xmax=1 ymin=-10 ymax=10 the width of y axis is about ten times the width of x axis... I would like the axes to always have the same size. If you would like me to send the whole program folder then you can email me at hcrogman@yahoo.com.

Thanks


Report this post
Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
[ Time : 0.128s | 9 Queries | GZIP : Off ]