Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Better clearing of graphic after 1 second

  • Loading branch information...
commit 3452f7ca2d371eb0ff7843eb984113c5b6f8c9e6 1 parent 2c24618
Torin Nguyen authored
Showing with 16 additions and 0 deletions.
  1. +16 −0 WTMGlyphDemo/WTMGlyphDetectorView.m
16 WTMGlyphDemo/WTMGlyphDetectorView.m
View
@@ -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
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.