Re: Trouble drawing a polygon...
Re: Trouble drawing a polygon...
- Subject: Re: Trouble drawing a polygon...
- From: "Brian O'Brien" <email@hidden>
- Date: Tue, 26 Apr 2005 16:02:15 -0600
On Apr 26, 2005, at 2:54 PM, Shawn Erickson wrote:
On Apr 26, 2005, at 1:29 PM, Brian O'Brien wrote:
My first polygon! :)
But nothing is drawing....
NSPoint p;
int i;
NSBezier * path = [NSBezierPath alloc] init];
Try using the following place of the above...
NSBezierPath* path = [NSBezierPath bezierPath];
[path setLineWidth:1.0];
<<<< you don't define a starting point here likely should
(moveToPoint:)
Yes I found that bug.. :)
// draw first set of points. green
for (i=0; i < npoints; ++i)
{
p = [self getAPoint:i];
[path lineToPoint:p];
}
[path closePath];
[[NSColor greenColor] set];
[path stroke];
<<<< should clear the prior path points here before the below or use a
different NSBezierPath
[path removeAllPoints];
or
path = [NSBezierPath bezierPath];
// draw second set of points. red
for (i=0; i < npoints; ++i)
{
p = [self getBPoint:i];
[path lineToPoint:p];
}
[path closePath];
[[NSColor redColor] set];
[path stroke];
The following isn't needed if you use +bezierPath above.
I don't follow what you mean about +bezierPath...
Are you saying the dealloc isn't necessary if I construct the path as
you recommended?
[path dealloc];
Have I misunderstood something?
Anyway are you sure you are getting valid points back from your
getAPoint: and getBPoint:?
Also stepping back even farther... you sure your drawRect: method is
getting called?
What is the difference between this and say
appendBezierPathWithPoints?
Well not much other then you can pass an buffer full of points in one
shot getting line segments between those, performance gain potentially
(and less code to manage in theory).
How do you add one point at a time with the append method?
Well what do you mean by point here?
I mean how do I call appendBezierPathWithPoints if I only have one
point.
You append points while also defining what the arc should look like
from the last end point to the new point you are adding. Normally you
use moveToPoint:, lineToPoint:, closePath:, curveToPoint:::, and
friends. Or use the various appendBezierPathWithXxx methods.
Or do you just want dots and not lines?
I may have misunderstood the purpose of appendBezierPathWithPoints. I
thought it would be identical to my moveTo lineTo for loop, but more
efficient.
curveToPoint might be interesting.. maybe my polygon would be rounder?
-Shawn
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden