MCPcopy Create free account
hub / github.com/InteractiveComputerGraphics/SPlisHSPlasH / PathArcTo

Method PathArcTo

extern/imgui/imgui_draw.cpp:1176–1224  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 3

ColorPicker4Method · 0.80

Calls 6

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

Tested by

no test coverage detected