gpt-3.5-turbo-0613· OpenAI
WildChat-4.8M (AI2)
Rewrite this to actionscript 3 please #define SPINNERHEADER(pos, size, centre,…
- User
Rewrite this to actionscript 3 please #define SPINNER_HEADER(pos, size, centre, num_segments) ImVec2 pos, size, centre; int num_segments; if (!detail::SpinnerBegin(label, radius, pos, size, centre, num_segments)) { return; }; ImGuiWindow *window = ImGui::GetCurrentWindow();
auto circle = [&] (auto point_func, auto dbc, auto dth) { window->DrawList->PathClear(); for (int i = 0; i < num_segments; i++) { ImVec2 p = point_func(i); window->DrawList->PathLineTo(ImVec2(centre.x + p.x, centre.y + p.y)); } window->DrawList->PathStroke(dbc, false, dth); }inline ImColor color_alpha(ImColor c, float alpha) { c.Value.w *= alpha * ImGui::GetStyle().Alpha; return c; } /* const char *label: A string label for the spinner, used to identify it in ImGui. float radius: The radius of the spinner. float thickness: The thickness of the spinner's border. const ImColor &color: The color of the spinner. float speed: The speed of the spinning animation. float ang_min: Minimum angle of spinning. float ang_max: Maximum angle of spinning. int arcs: Number of arcs of the spinner. */ inline void SpinnerRainbow(const char* label, float radius, float thickness, ImColor color, float speed, float ang_min = 0.f, float ang_max = PI_2, int arcs = 1) { SPINNER_HEADER(pos, size, centre, num_segments); for (int i = 0; i < arcs; ++i) { const float rb = (radius / arcs) * (i + 1); const float start = ImAbs(ImSin((float)ImGui::GetTime()) * (num_segments - 5)); const float a_min = ImMax(ang_min, PI_2 * ((float)start) / (float)num_segments + (IM_PI / arcs) * i); const float a_max = ImMin(ang_max, PI_2 * ((float)num_segments + 3 * (i + 1)) / (float)num_segments); static float isRed = 0.0f, isGreen = 0.01f, isBlue = 0.0f; ImVec4 isRGB = ImVec4(isRed, isGreen, isBlue, 1.0f); if (isGreen <= 0.01f && isBlue <= 0.0f) { isRed += 0.01f * speed / 2.0f; } if (isRed > 0.99f && isBlue == 0.0f) { isRed = 1.0f; isGreen += 0.01f * speed / 2.0f; } if (isGreen > 0.99f && isBlue == 0.0f) { isGreen = 1.0f; isRed -= 0.01f * speed / 2.0f; } if (isRed < 0.01f && isGreen == 1.0f) { isRed = 0.0f; isBlue += 0.01f * speed / 2.0f; } if (isBlue > 0.99f && isRed == 0.0f) { isBlue = 1.0f; isGreen -= 0.01f * speed / 2.0f; } if (isGreen < 0.01f && isBlue == 1.0f) { isGreen = 0.0f; isRed += 0.01f * speed / 2.0f; } if (isRed > 0.99f && isGreen == 0.0f) { isRed = 1.0f; isBlue -= 0.01f * speed / 2.0f; } if (isBlue < 0.01f && isGreen == 0.0f) { isBlue = 0.0f; isRed -= 0.01f * speed / 2.0f; if (isRed < 0.01f) isGreen = 0.01f * speed / 2.0f; } color = ImColor(isRed, isGreen, isBlue); circle([&](int i) { const float a = a_min + ((float)i / (float)num_segments) * (a_max - a_min); const float rspeed = a + (float)ImGui::GetTime() * speed; return ImVec2(ImCos(rspeed) * rb, ImSin(rspeed) * rb); }, color_alpha(color, 1.f), thickness); } } - Assistant