Skip navigation.
 
mlBezierPath issues
FROM : Development
DATE : Sun Feb 24 22:53:52 2008

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.

Related mailsAuthorDate
mlBezierPath issues Development Feb 24, 22:53
mlRe: BezierPath issues Ricky Sharp Feb 25, 00:26
mlRe: BezierPath issues John C. Randolph Feb 25, 23:10
mlRe: BezierPath issues Graham Feb 25, 23:31