1919// Draws a mux, height/width define the bounding box, scale [0.,1.] controls the slope of the muxes sides
2020ezgl::rectangle draw_mux (ezgl::point2d origin, e_side orientation, float height, float width, float scale, ezgl::renderer* g) {
2121 std::vector<ezgl::point2d> mux_polygon;
22+ mux_polygon.reserve (4 );
2223
2324 switch (orientation) {
2425 case TOP:
25- // Clock-wise from bottom left
26+ // Clock-wise from bottom left
2627 mux_polygon.emplace_back (origin.x - height / 2 , origin.y - width / 2 );
2728 mux_polygon.emplace_back (origin.x - (scale * height) / 2 , origin.y + width / 2 );
2829 mux_polygon.emplace_back (origin.x + (scale * height) / 2 , origin.y + width / 2 );
2930 mux_polygon.emplace_back (origin.x + height / 2 , origin.y - width / 2 );
3031 break ;
3132 case BOTTOM:
32- // Clock-wise from bottom left
33+ // Clock-wise from bottom left
3334 mux_polygon.emplace_back (origin.x - (scale * height) / 2 , origin.y - width / 2 );
3435 mux_polygon.emplace_back (origin.x - height / 2 , origin.y + width / 2 );
3536 mux_polygon.emplace_back (origin.x + height / 2 , origin.y + width / 2 );
3637 mux_polygon.emplace_back (origin.x + (scale * height) / 2 , origin.y - width / 2 );
3738 break ;
3839 case LEFT:
39- // Clock-wise from bottom left
40+ // Clock-wise from bottom left
4041 mux_polygon.emplace_back (origin.x - width / 2 , origin.y - (scale * height) / 2 );
4142 mux_polygon.emplace_back (origin.x - width / 2 , origin.y + (scale * height) / 2 );
4243 mux_polygon.emplace_back (origin.x + width / 2 , origin.y + height / 2 );
4344 mux_polygon.emplace_back (origin.x + width / 2 , origin.y - height / 2 );
4445 break ;
4546 case RIGHT:
46- // Clock-wise from bottom left
47+ // Clock-wise from bottom left
4748 mux_polygon.emplace_back (origin.x - width / 2 , origin.y - height / 2 );
4849 mux_polygon.emplace_back (origin.x - width / 2 , origin.y + height / 2 );
4950 mux_polygon.emplace_back (origin.x + width / 2 , origin.y + (scale * height) / 2 );
@@ -57,7 +58,7 @@ ezgl::rectangle draw_mux(ezgl::point2d origin, e_side orientation, float height,
5758
5859 ezgl::point2d min ((float )mux_polygon[0 ].x , (float )mux_polygon[0 ].y );
5960 ezgl::point2d max ((float )mux_polygon[0 ].x , (float )mux_polygon[0 ].y );
60- for (const auto & point : mux_polygon) {
61+ for (const ezgl::point2d & point : mux_polygon) {
6162 min.x = std::min ((float )min.x , (float )point.x );
6263 min.y = std::min ((float )min.y , (float )point.y );
6364 max.x = std::max ((float )max.x , (float )point.x );
0 commit comments