BezierPath issues
BezierPath issues
- Subject: BezierPath issues
- From: Development <email@hidden>
- Date: Sun, 24 Feb 2008 14:53:52 -0700
I'm trying to adapt a part of the sketch example in to a program for
light drawing functions. Unfortunately not being very good with
graphics I'm having a great deal of trouble. I was hoping that it was
possible to create the free form drawing within a bezierpath but if it
is I don't see how. Below is the bezier path creation code I am using
to try and create the freeform drawing.. This code produces a single
angled line (Always the exact same angle) about 5px long and nothing
more no matter how much I move the mouse, then when I release the
mouse button the application crashes with a bad access and I'll mark
the line where it crashes.
- (NSBezierPath *)bezierPath {
NSRect bounds = [self bounds];
if(![self strokeLineWidth]){
NSLog(@"Zero stroke w3idth");
return penPath;
}
[penPath setLineWidth:[self strokeLineWidth]];
if(!lastPointSet){
lastPoint = [self bounds].origin;
lastPointSet= YES;
}
NSRect dot = NSMakeRect(bounds.size.width,bounds.size.height,[self
strokeLineWidth],[self strokeLineWidth]);
NSPoint dotPoint = NSMakePoint(dot.origin.x,dot.origin.y);
if(!penPath){
NSLog(@"returning NULL");
return NULL;
}
[penPath moveToPoint:dotPoint]; //This is where it crashes on mouse up.
[penPath lineToPoint:lastPoint];
lastPoint = dotPoint;
[penPath appendBezierPathWithRect:dot];
return penPath;
}
I'm sure this is a simple problem but I cannot seem to figure it out.
_______________________________________________
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