Hi guys,
I'm trying to make a "MSPaint" app in iPhone. I am trying to use circles to draw solid circles (which i've done successfully), and then build an eraser by drawing transparent circles.
Can someone help me out here? I am kind of stuck. Thanks guys.
#import "ImageView.h"
#import "EraseViewController.h"
@implementation ImageView
@synthesize x, y, width, height, scaling, editing, secondX, secondY, eraseX, eraseY, eraseWidth, eraseHeight;
- (id)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) {
newRect = CGRectMake(0,0,0,0);
editing = false;
scaling = false;
}
return self;
}
- (void)drawRect:(CGRect)rect {
static int counter = 0;
CGRect veryNewRect = CGRectMake(30.0, 210.0, 60.0, 60.0);
NSLog(@"I'm being redrawn.");
CGContextRef ref = UIGraphicsGetCurrentContext();
if (!editing){
if (counter == 0){
CGContextFillEllipseInRect(ref, veryNewRect);
}
else{
CGRect newRect = CGRectMake(x,y,width,height);
CGContextFillEllipseInRect(ref, newRect);
}
}
else{
if (counter > 1){
CGRect eraseRect = CGRectMake(eraseX, eraseY, 15, 15);
CGContextFillEllipseInRect(ref, eraseRect);
}
}
counter++;
NSLog(@"New value of counter is %d", counter);
}
- (void)dealloc {
[super dealloc];
}
@end