Silver Challenge



I just expanded the drawrect. To get a more uniform colour spread, you’ll have to think up a better algorithm to create the colours from the RAD number.
Essentially rad in Objective C goes from -pi to +pi, and I wanted it to go from 0 to 2pi. Thus the “if rads < 0” part.

- (void)drawRect:(CGRect)rect
    //draw finished lines in black
    //[[UIColor blackColor]set];
    for (BNRLine *line in self.finishedLines)
        int x1 = line.begin.x;
        int y1 = line.begin.y;
        int x2 = line.end.x;
        int y2 = line.end.y;
        double rads = atan2(x2-x1, y2-y1);
        if( rads < 0)
            rads = ( M_PI *2 ) + rads;
        NSLog(@"The rad of the line is: %f", rads);
        [[UIColor colorWithRed:rads/(M_PI*2) green:1-(rads/(M_PI*2)) blue:1 alpha:1]set];
        [ self strokeLine:line];
    [[UIColor redColor] set];
    for (NSValue *key in self.linesInProgress) {
        [self strokeLine:self.linesInProgress[key]];