Drawing Graphics on IPhone
<p>I am having problem in drawing a rectangle or triangle on the touch gesture. Here is the code: </p>

<pre><code>-(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event    
{
    UITouch *touch = [touches anyObject];
    CGPoint location = [touch locationInView:self]; 

    // move the cannon to the touched location

    x = location.x; 

    [self moveCannon];  

    [self setNeedsDisplay]; 

}

-(void) moveCannon
{
    // draw the cannot as a triangle for right now


    CGMutablePathRef path = CGPathCreateMutable(); 
    CGPathMoveToPoint(path, NULL, 20.0f, 100.0f); 
    CGPathAddLineToPoint(path, NULL, 50.0f, 100.0f);
    CGPathAddLineToPoint(path, NULL, 50.0f, 20.0f); 
    CGPathAddLineToPoint(path, NULL, 50.0f, 100.0f);
    CGPathCloseSubpath(path);

    CGContextSetFillColorWithColor(self.context, [UIColor redColor].CGColor);
    CGContextAddPath(self.context, path);
    CGContextFillPath(self.context);

}
</code></pre>

<p>What am I missing? </p>
