def onStrokeAdded( self, stroke ): "Watches for Strokes with Circularity > threshold to Annotate" # need at least 6 points to be a circle if stroke.length()<6: return s_norm = GeomUtils.strokeNormalizeSpacing( stroke, 20 ) s_chop = GeomUtils.strokeChopEnds( s_norm, 0.20 ) circ_norm = GeomUtils.strokeCircularity( s_norm ) circ_chop = GeomUtils.strokeCircularity( s_chop ) logger.debug( "stroke: %s", [str(p) for p in s_norm.Points] ) logger.debug( "potential circles (%f,%f) <> %f", circ_norm, circ_chop, self.threshold ) if( circ_norm>self.threshold or circ_chop>self.threshold): cen = stroke.Center avgDist = GeomUtils.averageDistance( cen, stroke.Points ) anno = CircleAnnotation( circ_norm, cen, avgDist ) BoardSingleton().AnnotateStrokes( [stroke], anno)