void ShapeDetector::report( const std::string &i_name, const std::vector<CGPoint> &i_path ) { Path2D p; for ( auto pt : i_path ) { if ( p.size() == 0 ) p.move_to( pt ); else p.line_to( pt ); } shapeDetected( i_name, p ); }
Path2D Path2D::circle( CGFloat r, const CGPoint &i_center ) { Path2D p; r = std::abs( r ); CGFloat c = r * 0.551915024494; p.move_to( i_center + CGPoint{ r, 0 } ); p.curve_to( i_center + CGPoint{ r, c }, i_center + CGPoint{ c, r }, i_center + CGPoint{ 0, r } ); p.curve_to( i_center + CGPoint{ -c, r }, i_center + CGPoint{ -r, c }, i_center + CGPoint{ -r, 0 } ); p.curve_to( i_center + CGPoint{ -r, -c }, i_center + CGPoint{ -c, -r }, i_center + CGPoint{ 0, -r } ); p.curve_to( i_center + CGPoint{ c, -r }, i_center + CGPoint{ r, -c }, i_center + CGPoint{ r, 0 } ); p.close(); return p; }