MCPcopy Create free account
hub / github.com/VictorGordan/opengl-tutorials / PathArcTo

Method PathArcTo

ImGUI GLFW Tutorial/imgui/imgui_draw.cpp:1161–1209  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 3

ColorPicker4Method · 0.45

Calls 6

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

Tested by

no test coverage detected