MCPcopy Create free account
hub / github.com/VitalAudio/visage / roundedRectangle

Function roundedRectangle

visage_graphics/path.cpp:53–87  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

51
52 template<typename T>
53 static void roundedRectangle(T& t, float x, float y, float width, float height, float rx_top_left,
54 float ry_top_left, float rx_top_right, float ry_top_right,
55 float rx_bottom_right, float ry_bottom_right, float rx_bottom_left,
56 float ry_bottom_left) {
57 float scale = 1.0f;
58 if (rx_top_left + rx_top_right)
59 scale = std::min(scale, width / (rx_top_left + rx_top_right));
60 if (rx_bottom_left + rx_bottom_right)
61 scale = std::min(scale, width / (rx_bottom_left + rx_bottom_right));
62 if (ry_top_left + ry_bottom_left)
63 scale = std::min(scale, height / (ry_top_left + ry_bottom_left));
64 if (ry_top_right + ry_bottom_right)
65 scale = std::min(scale, height / (ry_top_right + ry_bottom_right));
66
67 rx_top_left *= scale;
68 ry_top_left *= scale;
69 rx_top_right *= scale;
70 ry_top_right *= scale;
71 rx_bottom_right *= scale;
72 ry_bottom_right *= scale;
73 rx_bottom_left *= scale;
74 ry_bottom_left *= scale;
75
76 t.moveTo(x + rx_top_left, y);
77 t.lineTo(x + width - rx_top_right, y);
78 t.arcTo(rx_top_right, ry_top_right, 0.0f, false, true, Point(x + width, y + ry_top_right), false);
79 t.lineTo(x + width, y + height - ry_bottom_right);
80 t.arcTo(rx_bottom_right, ry_bottom_right, 0.0f, false, true,
81 Point(x + width - rx_bottom_right, y + height), false);
82 t.lineTo(x + rx_bottom_left, y + height);
83 t.arcTo(rx_bottom_left, ry_bottom_left, 0.0f, false, true, Point(x, y + height - ry_bottom_left), false);
84 t.lineTo(x, y + ry_top_left);
85 t.arcTo(rx_top_left, ry_top_left, 0.0f, false, true, Point(x + rx_top_left, y), false);
86 t.close();
87 }
88
89 template<typename T>
90 static void roundedRectangle(T& t, float x, float y, float width, float height, float rx, float ry) {

Callers 1

addRoundedRectangleMethod · 0.85

Calls 4

moveToMethod · 0.45
lineToMethod · 0.45
arcToMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected