Skip to content

Commit

Permalink
Better clearing of graphic after 1 second
Browse files Browse the repository at this point in the history
  • Loading branch information
Torin Nguyen committed Jul 5, 2012
1 parent 2c24618 commit 3452f7c
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions WTMGlyphDemo/WTMGlyphDetectorView.m
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ - (void)glyphDetected:(WTMGlyph *)glyph withScore:(float)score
//Simply forward it to my parent
if ([self.delegate respondsToSelector:@selector(wtmGlyphDetectorView:glyphDetected:withScore:)])
[self.delegate wtmGlyphDetectorView:self glyphDetected:glyph withScore:score];

[self performSelector:@selector(clearDrawingIfTimeout) withObject:nil afterDelay:1.0f];
}

- (void)glyphResults:(NSArray *)results
Expand Down Expand Up @@ -168,5 +170,19 @@ - (void)drawRect:(CGRect)rect
[self.myPath strokeWithBlendMode:kCGBlendModeNormal alpha:0.5];
}

- (void)clearDrawingIfTimeout
{
if (!self.enableDrawing)
return;

BOOL hasTimeOut = [self.glyphDetector hasTimedOut];
if (!hasTimeOut)
return;

[self.myPath removeAllPoints];

//This is not recommended for production, but it's ok here since we don't have a lot to draw
[self setNeedsDisplay];
}

@end

0 comments on commit 3452f7c

Please sign in to comment.