still cant get bezier paths working for me.
still cant get bezier paths working for me.
- Subject: still cant get bezier paths working for me.
- From: Development <email@hidden>
- Date: Mon, 25 Feb 2008 21:55:16 -0700
Well... bezierpaths have officially confused me beyond reason... I am
hoping that some one will be able to help me based on the amount of
code that I can paste in to an email with out it getting bounced.
First, I am trying to create a pen tool similar to something you'd
find in photoshop. After more reading and trial and error I have
gotten a tad closer but not much. This code is based on the sketch
example code, I figured that would be a good place to start. However I
am thinking that it is not possible to use bezier paths for this.
First time through I've tried to use an instance variable to maintain
the path, but it had two problems, the first is that the rectangle
around the path shifted size, even though I had though append path
would prevent this. When the rect shifted sizes it cut out the edges
of what ever I drew. Second, as soon as I let off the mouse button the
application would crash. The instance variable was the cause. I
attempted to NSLog it to get some information but that would cause the
application to crash also. The variable however was not NULL or nil so
I honestly do not know how to deal with this... I could not find the
reason for it.
Next I just return the current part of the path but then I only end up
with a dot chasing the cursor. But no crash.
I tried using a point array but apparently I don't understand how they
work, I thought it was like any plain old char array. below is the
code that produces the single dot... if some one could suggest how I
could make the line persistent I'd be grateful. Should I be trying to
keep an array of point returning newPath with appendPoints?
- (NSBezierPath *)bezierPath {
if(![self strokeLineWidth]){
return NULL;
}
if(!lastPointSet){
lastPoint = [self bounds].origin;
lastPointSet= YES;
}
NSPoint dotPoint = [[[[self
document]windowController]graphicView]currentPoint];
NSBezierPath * newPath =[NSBezierPath bezierPath];
[[self fillColor]set];
[newPath moveToPoint:dotPoint];
[newPath lineToPoint:lastPoint];
[newPath stroke];
lastPoint = dotPoint;
return newPath;
}
_______________________________________________
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