454{
455 NSUInteger i;
456 NSPoint left, right, next;
457 double gradientleft, gradientright;
459 BOOL first_segment = YES;
460 NSMutableArray *new_segments = [NSMutableArray arrayWithCapacity: ([controlPoints count] + 1)];
461
462 left.x = 0.0;
463 left.y = 0.0;
464 if ([controlPoints
count] == 0)
465 {
466 right.x = 1.0;
467 right.y = 1.0;
469 [new_segments addObject:segment];
470 }
471 else
472 {
473 gradientleft = 1.0;
474 right = [[controlPoints objectAtIndex: 0] pointValue];
475 for (i = 0; i < [controlPoints count]; i++)
476 {
477 next = [self pointAtIndex: i + 1];
478 if (next.x - left.x > 0.0)
479 {
480
481 gradientright = (next.y - left.y)/(next.x - left.x);
482 if (first_segment)
483 {
484 segment = [OOJoystickSplineSegment segmentWithData: left right: right gradientright: gradientright];
485 }
486 else
487 {
488 segment = [OOJoystickSplineSegment segmentWithData: left right: right gradientleft: gradientleft gradientright: gradientright];
489 }
491 {
492 return NO;
493 }
494 else
495 {
496 [new_segments addObject: segment];
497 gradientleft = gradientright;
498 first_segment = NO;
499 left = right;
500 }
501 }
502 right = next;
503 }
504 right.x = 1.0;
505 right.y = 1.0;
508 {
509 return NO;
510 }
511 [new_segments addObject: segment];
512 }
513 [segments release];
514 segments = [[NSArray arrayWithArray: new_segments] retain];
515 return YES;
516}
517
id segmentWithData:right:(NSPoint left,[right] NSPoint right)
id segmentWithData:right:gradientleft:(NSPoint left,[right] NSPoint right,[gradientleft] double gradientleft)