| 1231 | } |
| 1232 | |
| 1233 | void ImDrawList::PathArcTo(const ImVec2& center, float radius, float a_min, float a_max, int num_segments) |
| 1234 | { |
| 1235 | if (radius < 0.5f) |
| 1236 | { |
| 1237 | _Path.push_back(center); |
| 1238 | return; |
| 1239 | } |
| 1240 | |
| 1241 | if (num_segments > 0) |
| 1242 | { |
| 1243 | _PathArcToN(center, radius, a_min, a_max, num_segments); |
| 1244 | return; |
| 1245 | } |
| 1246 | |
| 1247 | // Automatic segment count |
| 1248 | if (radius <= _Data->ArcFastRadiusCutoff) |
| 1249 | { |
| 1250 | const bool a_is_reverse = a_max < a_min; |
| 1251 | |
| 1252 | // We are going to use precomputed values for mid samples. |
| 1253 | // Determine first and last sample in lookup table that belong to the arc. |
| 1254 | const float a_min_sample_f = IM_DRAWLIST_ARCFAST_SAMPLE_MAX * a_min / (IM_PI * 2.0f); |
| 1255 | const float a_max_sample_f = IM_DRAWLIST_ARCFAST_SAMPLE_MAX * a_max / (IM_PI * 2.0f); |
| 1256 | |
| 1257 | const int a_min_sample = a_is_reverse ? (int)ImFloor(a_min_sample_f) : (int)ImCeil(a_min_sample_f); |
| 1258 | const int a_max_sample = a_is_reverse ? (int)ImCeil(a_max_sample_f) : (int)ImFloor(a_max_sample_f); |
| 1259 | const int a_mid_samples = a_is_reverse ? ImMax(a_min_sample - a_max_sample, 0) : ImMax(a_max_sample - a_min_sample, 0); |
| 1260 | |
| 1261 | const float a_min_segment_angle = a_min_sample * IM_PI * 2.0f / IM_DRAWLIST_ARCFAST_SAMPLE_MAX; |
| 1262 | const float a_max_segment_angle = a_max_sample * IM_PI * 2.0f / IM_DRAWLIST_ARCFAST_SAMPLE_MAX; |
| 1263 | const bool a_emit_start = ImAbs(a_min_segment_angle - a_min) >= 1e-5f; |
| 1264 | const bool a_emit_end = ImAbs(a_max - a_max_segment_angle) >= 1e-5f; |
| 1265 | |
| 1266 | _Path.reserve(_Path.Size + (a_mid_samples + 1 + (a_emit_start ? 1 : 0) + (a_emit_end ? 1 : 0))); |
| 1267 | if (a_emit_start) |
| 1268 | _Path.push_back(ImVec2(center.x + ImCos(a_min) * radius, center.y + ImSin(a_min) * radius)); |
| 1269 | if (a_mid_samples > 0) |
| 1270 | _PathArcToFastEx(center, radius, a_min_sample, a_max_sample, 0); |
| 1271 | if (a_emit_end) |
| 1272 | _Path.push_back(ImVec2(center.x + ImCos(a_max) * radius, center.y + ImSin(a_max) * radius)); |
| 1273 | } |
| 1274 | else |
| 1275 | { |
| 1276 | const float arc_length = ImAbs(a_max - a_min); |
| 1277 | const int circle_segment_count = _CalcCircleAutoSegmentCount(radius); |
| 1278 | const int arc_segment_count = ImMax((int)ImCeil(circle_segment_count * arc_length / (IM_PI * 2.0f)), (int)(2.0f * IM_PI / arc_length)); |
| 1279 | _PathArcToN(center, radius, a_min, a_max, arc_segment_count); |
| 1280 | } |
| 1281 | } |
| 1282 | |
| 1283 | void ImDrawList::PathEllipticalArcTo(const ImVec2& center, const ImVec2& radius, float rot, float a_min, float a_max, int num_segments) |
| 1284 | { |
no test coverage detected