views:

17

answers:

1

Hi;

I am trying to update a UIView subclass to draw individual pixels (rectangles) after calculating if they are in the mandelbrot set.

I am using the following code but am getting a blank screen:

//drawingView.h

...

-(void)drawRect:(CGRect)rect{

    CGContextRef context = UIGraphicsGetCurrentContext(); 

    CGContextSetRGBFillColor(context, r, g, b, 1);
    CGContextSetRGBStrokeColor(context, r, g, b, 1);

    CGRect arect = CGRectMake(x,y,1,1);


    CGContextFillRect(context, arect);

}
...

//viewController.m
...
- (void)viewDidLoad {
    [drawingView setX:10];
    [drawingView setY:10];
    [drawingView setR:0.0];
    [drawingView setG:0.0];
    [drawingView setB:0.0];
    [super viewDidLoad];
    [drawingView setNeedsDisplay];
}

Once I figure out how to display one pixel, I'd like to know how to go about updating the view by adding another pixel (once calculated). Once all the variables change, how do I keep the current view as is but add another pixel?

Thanks, Brett

A: 
CGContextMoveToPoint(context, xcoord, ycoord);
CGContextAddLineToPoint(context, xcoord, ycoord);
CGContextStrokePath(context);
John Smith