MCPcopy Create free account
hub / github.com/cinder/Cinder / PathArcTo

Method PathArcTo

src/imgui/imgui_draw.cpp:1258–1306  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1256}
1257
1258void ImDrawList::PathArcTo(const ImVec2& center, float radius, float a_min, float a_max, int num_segments)
1259{
1260 if (radius < 0.5f)
1261 {
1262 _Path.push_back(center);
1263 return;
1264 }
1265
1266 if (num_segments > 0)
1267 {
1268 _PathArcToN(center, radius, a_min, a_max, num_segments);
1269 return;
1270 }
1271
1272 // Automatic segment count
1273 if (radius <= _Data->ArcFastRadiusCutoff)
1274 {
1275 const bool a_is_reverse = a_max < a_min;
1276
1277 // We are going to use precomputed values for mid samples.
1278 // Determine first and last sample in lookup table that belong to the arc.
1279 const float a_min_sample_f = IM_DRAWLIST_ARCFAST_SAMPLE_MAX * a_min / (IM_PI * 2.0f);
1280 const float a_max_sample_f = IM_DRAWLIST_ARCFAST_SAMPLE_MAX * a_max / (IM_PI * 2.0f);
1281
1282 const int a_min_sample = a_is_reverse ? (int)ImFloor(a_min_sample_f) : (int)ImCeil(a_min_sample_f);
1283 const int a_max_sample = a_is_reverse ? (int)ImCeil(a_max_sample_f) : (int)ImFloor(a_max_sample_f);
1284 const int a_mid_samples = a_is_reverse ? ImMax(a_min_sample - a_max_sample, 0) : ImMax(a_max_sample - a_min_sample, 0);
1285
1286 const float a_min_segment_angle = a_min_sample * IM_PI * 2.0f / IM_DRAWLIST_ARCFAST_SAMPLE_MAX;
1287 const float a_max_segment_angle = a_max_sample * IM_PI * 2.0f / IM_DRAWLIST_ARCFAST_SAMPLE_MAX;
1288 const bool a_emit_start = ImAbs(a_min_segment_angle - a_min) >= 1e-5f;
1289 const bool a_emit_end = ImAbs(a_max - a_max_segment_angle) >= 1e-5f;
1290
1291 _Path.reserve(_Path.Size + (a_mid_samples + 1 + (a_emit_start ? 1 : 0) + (a_emit_end ? 1 : 0)));
1292 if (a_emit_start)
1293 _Path.push_back(ImVec2(center.x + ImCos(a_min) * radius, center.y + ImSin(a_min) * radius));
1294 if (a_mid_samples > 0)
1295 _PathArcToFastEx(center, radius, a_min_sample, a_max_sample, 0);
1296 if (a_emit_end)
1297 _Path.push_back(ImVec2(center.x + ImCos(a_max) * radius, center.y + ImSin(a_max) * radius));
1298 }
1299 else
1300 {
1301 const float arc_length = ImAbs(a_max - a_min);
1302 const int circle_segment_count = _CalcCircleAutoSegmentCount(radius);
1303 const int arc_segment_count = ImMax((int)ImCeil(circle_segment_count * arc_length / (IM_PI * 2.0f)), (int)(2.0f * IM_PI / arc_length));
1304 _PathArcToN(center, radius, a_min, a_max, arc_segment_count);
1305 }
1306}
1307
1308void ImDrawList::PathEllipticalArcTo(const ImVec2& center, const ImVec2& radius, float rot, float a_min, float a_max, int num_segments)
1309{

Callers 5

RenderMouseCursorMethod · 0.80
ColorPicker4Method · 0.80

Calls 6

ImFloorFunction · 0.85
ImMaxFunction · 0.85
ImAbsFunction · 0.85
ImVec2Function · 0.85
push_backMethod · 0.45
reserveMethod · 0.45

Tested by

no test coverage detected