
want to fill in all the gaps with different colors using touch events
Right now I can fill in the circles that select colors from the picker, but how to fill in the indented part with different colors ...
-(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{ UIColor *cl=[UIColor clearColor]; UITouch *tuch=[touches anyObject]; if ([clr isEqualToString:@"Red"]) { cl=[UIColor redColor]; } else if ([clr isEqualToString:@"Blue"]) { cl=[UIColor blueColor] ; } else if ([clr isEqualToString:@"Green"]) { cl=[UIColor greenColor]; } CGPoint p = [tuch locationInView:self]; float xsq1=px -50; xsq1=xsq1*xsq1; float ysq1=py-110; ysq1=ysq1*ysq1; float h1 = ABS(sqrt(xsq1 + ysq1)); float xsq2=px -100; xsq2=xsq2*xsq2; float ysq2=py-110; ysq2=ysq2*ysq2; float h2 = ABS(sqrt(xsq2 + ysq2)); float xsq3=px -50; xsq3=xsq3*xsq3; float ysq3=py-190; ysq3=ysq3*ysq3; float h3 = ABS(sqrt(xsq3 + ysq3)); if (h1<=40) { NSLog(@"touches inside of first circle"); CGContextSetFillColorWithColor(context, cl.CGColor); CGRect cir1 = CGRectMake(10,266,80,80); CGContextFillEllipseInRect(context, cir1); [self setNeedsDisplayInRect:cir1]; } else if (h2<=40) { NSLog(@"touches inside of second circle"); CGContextSetFillColorWithColor(context, cl.CGColor); CGRect cir2 = CGRectMake(60,266,80,80); CGContextFillEllipseInRect(context, cir2); [self setNeedsDisplayInRect:cir2]; } }
iphone ios4
user972462
source share