MCPcopy Create free account
hub / github.com/KebsCS/KBotExt / PathArcTo

Method PathArcTo

KBotExt/imgui/imgui_draw.cpp:1170–1218  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1168}
1169
1170void ImDrawList::PathArcTo(const ImVec2& center, float radius, float a_min, float a_max, int num_segments)
1171{
1172 if (radius < 0.5f)
1173 {
1174 _Path.push_back(center);
1175 return;
1176 }
1177
1178 if (num_segments > 0)
1179 {
1180 _PathArcToN(center, radius, a_min, a_max, num_segments);
1181 return;
1182 }
1183
1184 // Automatic segment count
1185 if (radius <= _Data->ArcFastRadiusCutoff)
1186 {
1187 const bool a_is_reverse = a_max < a_min;
1188
1189 // We are going to use precomputed values for mid samples.
1190 // Determine first and last sample in lookup table that belong to the arc.
1191 const float a_min_sample_f = IM_DRAWLIST_ARCFAST_SAMPLE_MAX * a_min / (IM_PI * 2.0f);
1192 const float a_max_sample_f = IM_DRAWLIST_ARCFAST_SAMPLE_MAX * a_max / (IM_PI * 2.0f);
1193
1194 const int a_min_sample = a_is_reverse ? (int)ImFloorSigned(a_min_sample_f) : (int)ImCeil(a_min_sample_f);
1195 const int a_max_sample = a_is_reverse ? (int)ImCeil(a_max_sample_f) : (int)ImFloorSigned(a_max_sample_f);
1196 const int a_mid_samples = a_is_reverse ? ImMax(a_min_sample - a_max_sample, 0) : ImMax(a_max_sample - a_min_sample, 0);
1197
1198 const float a_min_segment_angle = a_min_sample * IM_PI * 2.0f / IM_DRAWLIST_ARCFAST_SAMPLE_MAX;
1199 const float a_max_segment_angle = a_max_sample * IM_PI * 2.0f / IM_DRAWLIST_ARCFAST_SAMPLE_MAX;
1200 const bool a_emit_start = ImAbs(a_min_segment_angle - a_min) >= 1e-5f;
1201 const bool a_emit_end = ImAbs(a_max - a_max_segment_angle) >= 1e-5f;
1202
1203 _Path.reserve(_Path.Size + (a_mid_samples + 1 + (a_emit_start ? 1 : 0) + (a_emit_end ? 1 : 0)));
1204 if (a_emit_start)
1205 _Path.push_back(ImVec2(center.x + ImCos(a_min) * radius, center.y + ImSin(a_min) * radius));
1206 if (a_mid_samples > 0)
1207 _PathArcToFastEx(center, radius, a_min_sample, a_max_sample, 0);
1208 if (a_emit_end)
1209 _Path.push_back(ImVec2(center.x + ImCos(a_max) * radius, center.y + ImSin(a_max) * radius));
1210 }
1211 else
1212 {
1213 const float arc_length = ImAbs(a_max - a_min);
1214 const int circle_segment_count = _CalcCircleAutoSegmentCount(radius);
1215 const int arc_segment_count = ImMax((int)ImCeil(circle_segment_count * arc_length / (IM_PI * 2.0f)), (int)(2.0f * IM_PI / arc_length));
1216 _PathArcToN(center, radius, a_min, a_max, arc_segment_count);
1217 }
1218}
1219
1220ImVec2 ImBezierCubicCalc(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, float t)
1221{

Callers 3

ColorPicker4Method · 0.80

Calls 5

ImFloorSignedFunction · 0.85
ImMaxFunction · 0.85
ImAbsFunction · 0.85
ImVec2Function · 0.85
reserveMethod · 0.80

Tested by

no test coverage detected