update circle draw (I forgor what I did like 2 months ago)

This commit is contained in:
Inventor Xtreme 2025-04-03 23:41:34 -04:00
parent ebfb6e239a
commit cebf244da0

View file

@ -246,9 +246,11 @@ void GenCircleOverlay(MprisPlayer *current_player, RenderTexture tex, bool trans
} }
BeginBlendMode(BLEND_SUBTRACT_COLORS); BeginBlendMode(BLEND_SUBTRACT_COLORS);
if (trans) { if (trans) {
DrawCircle(GetScreenWidth() / 2, GetScreenHeight() / 2, std::min(GetScreenWidth() / 2, GetScreenHeight() / 2), WHITE); DrawCircle(GetScreenWidth() / 2, GetScreenHeight() / 2,
std::min(GetScreenWidth() / 2, GetScreenHeight() / 2), WHITE);
} else { } else {
DrawCircle(GetScreenWidth() / 2, GetScreenHeight() / 2, std::min(GetScreenWidth() / 2, GetScreenHeight() / 2), (Color{0, 0, 0, 0})); DrawCircle(GetScreenWidth() / 2, GetScreenHeight() / 2,
std::min(GetScreenWidth() / 2, GetScreenHeight() / 2), (Color{0, 0, 0, 0}));
} }
EndBlendMode(); EndBlendMode();
EndTextureMode(); EndTextureMode();
@ -262,7 +264,7 @@ int main(int argc, char *argv[]) {
// SetConfigFlags(FLAG_MSAA_4X_HINT | FLAG_WINDOW_RESIZABLE); // SetConfigFlags(FLAG_MSAA_4X_HINT | FLAG_WINDOW_RESIZABLE);
// SetConfigFlags(FLAG_MSAA_4X_HINT | FLAG_VSYNC_HINT | FLAG_WINDOW_RESIZABLE); // SetConfigFlags(FLAG_MSAA_4X_HINT | FLAG_VSYNC_HINT | FLAG_WINDOW_RESIZABLE);
SetConfigFlags(FLAG_WINDOW_TRANSPARENT | FLAG_MSAA_4X_HINT | FLAG_WINDOW_RESIZABLE | FLAG_VSYNC_HINT); SetConfigFlags(FLAG_WINDOW_TRANSPARENT | FLAG_MSAA_4X_HINT | FLAG_WINDOW_RESIZABLE);
InitWindow(screenWidth, screenHeight, "raylib-Extras [ImGui] example - Docking"); InitWindow(screenWidth, screenHeight, "raylib-Extras [ImGui] example - Docking");
SetTargetFPS(244); SetTargetFPS(244);
rlImGuiSetup(true); rlImGuiSetup(true);
@ -297,7 +299,8 @@ int main(int argc, char *argv[]) {
RenderTexture recordoverlay = LoadRenderTexture(screenWidth, screenHeight); RenderTexture recordoverlay = LoadRenderTexture(screenWidth, screenHeight);
GenCircleOverlay(&current_player, recordoverlay, trans, accent); GenCircleOverlay(&current_player, recordoverlay, trans, accent);
while (!WindowShouldClose() && run) // Detect window close button or ESC key, or a quit from the menu while (!WindowShouldClose() &&
run) // Detect window close button or ESC key, or a quit from the menu
{ {
if (IsWindowResized()) { if (IsWindowResized()) {
UnloadRenderTexture(recordoverlay); UnloadRenderTexture(recordoverlay);
@ -322,17 +325,21 @@ int main(int argc, char *argv[]) {
ClearBackground(BLACK); ClearBackground(BLACK);
} }
Vector2 winwidth = (Vector2){(float)GetScreenWidth(), (float)GetScreenHeight()}; Vector2 winwidth = (Vector2){(float)GetScreenWidth(), (float)GetScreenHeight()};
Vector2 imagesize = (Vector2){(float)current_player.tex.tex.width, (float)current_player.tex.tex.height}; Vector2 imagesize =
(Vector2){(float)current_player.tex.tex.width, (float)current_player.tex.tex.height};
Vector2 scaledsize = Vector2Scale(imagesize, ScaleToFit(imagesize, winwidth)); Vector2 scaledsize = Vector2Scale(imagesize, ScaleToFit(imagesize, winwidth));
Vector2 fpos; Vector2 fpos;
fpos.x = (winwidth.x * 0.5) - (scaledsize.x * 0.5f); fpos.x = (winwidth.x * 0.5) - (scaledsize.x * 0.5f);
fpos.y = (winwidth.y * 0.5) - (scaledsize.y * 0.5f); fpos.y = (winwidth.y * 0.5) - (scaledsize.y * 0.5f);
// DrawTextureEx(current_player.tex.tex, fpos, 0, ScaleToFit(imagesize, winwidth), WHITE); // DrawTextureEx(current_player.tex.tex, fpos, 0, ScaleToFit(imagesize, winwidth), WHITE);
Rectangle src = (Rectangle){0, 0, (float)current_player.tex.tex.width, (float)current_player.tex.tex.height}; Rectangle src = (Rectangle){0, 0, (float)current_player.tex.tex.width,
Rectangle dst = (Rectangle){fpos.x + scaledsize.x / 2, fpos.y + scaledsize.y / 2, scaledsize.x, scaledsize.y}; (float)current_player.tex.tex.height};
Rectangle dst = (Rectangle){fpos.x + scaledsize.x / 2, fpos.y + scaledsize.y / 2,
scaledsize.x, scaledsize.y};
DrawTexturePro(current_player.tex.tex, src, dst, (Vector2){dst.width / 2, dst.height / 2}, disc.pos, WHITE); DrawTexturePro(current_player.tex.tex, src, dst, (Vector2){dst.width / 2, dst.height / 2},
disc.pos, WHITE);
if (IsWindowFocused()) { if (IsWindowFocused()) {
const float buttonsize = 0.1; const float buttonsize = 0.1;
@ -359,29 +366,44 @@ int main(int argc, char *argv[]) {
DrawCircleV(back, 0.05 * GetScreenWidth(), transblack); DrawCircleV(back, 0.05 * GetScreenWidth(), transblack);
DrawBack(back, 0.1 * GetScreenWidth(), WHITE); DrawBack(back, 0.1 * GetScreenWidth(), WHITE);
if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT) && CheckCollisionPointCircle(GetMousePosition(), centerline, 0.05 * GetScreenWidth())) { if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT) &&
CheckCollisionPointCircle(GetMousePosition(), centerline,
0.05 * GetScreenWidth())) {
current_player.PausePlay(); current_player.PausePlay();
current_player.playstate = current_player.playstate == "Playing" ? "Paused" : "Playing"; current_player.playstate =
} else if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT) && CheckCollisionPointCircle(GetMousePosition(), next, 0.05 * GetScreenWidth())) { current_player.playstate == "Playing" ? "Paused" : "Playing";
} else if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT) &&
CheckCollisionPointCircle(GetMousePosition(), next,
0.05 * GetScreenWidth())) {
current_player.Next(); current_player.Next();
current_player.playstate = current_player.playstate == "Playing" ? "Paused" : "Playing"; current_player.playstate =
} else if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT) && CheckCollisionPointCircle(GetMousePosition(), back, 0.05 * GetScreenWidth())) { current_player.playstate == "Playing" ? "Paused" : "Playing";
} else if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT) &&
CheckCollisionPointCircle(GetMousePosition(), back,
0.05 * GetScreenWidth())) {
current_player.Prev(); current_player.Prev();
current_player.playstate = current_player.playstate == "Playing" ? "Paused" : "Playing"; current_player.playstate =
current_player.playstate == "Playing" ? "Paused" : "Playing";
} else if (IsMouseButtonDown(MOUSE_BUTTON_LEFT) && disc.enabled) { } else if (IsMouseButtonDown(MOUSE_BUTTON_LEFT) && disc.enabled) {
float initmouserot; float initmouserot;
Vector2 initmousepos; Vector2 initmousepos;
if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) { if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) {
initmouserot = disc.pos; initmouserot = disc.pos;
initmousepos = GetMousePosition(); initmousepos = GetMousePosition();
initmousepos = Vector2Add(initmousepos, (Vector2){-screen.x / 2, -screen.y / 2}); initmousepos =
Vector2Add(initmousepos, (Vector2){-screen.x / 2, -screen.y / 2});
goodstate = true; goodstate = true;
} }
if (goodstate) { if (goodstate) {
Vector2 mouse = GetMousePosition(); Vector2 mouse = GetMousePosition();
Vector2 mousecentered = Vector2Add(mouse, (Vector2){-screen.x / 2, -screen.y / 2}); Vector2 mousecentered =
Vector2Add(mouse, (Vector2){-screen.x / 2, -screen.y / 2});
disc.velo = 0; disc.velo = 0;
disc.UpdatePos(initmouserot + (((180.0f * atan2(mousecentered.y, mousecentered.x)) / M_PI) - ((180.0f * atan2(initmousepos.y, initmousepos.x)) / M_PI)), GetFrameTime()); disc.UpdatePos(
initmouserot +
(((180.0f * atan2(mousecentered.y, mousecentered.x)) / M_PI) -
((180.0f * atan2(initmousepos.y, initmousepos.x)) / M_PI)),
GetFrameTime());
} }
} }
} }
@ -498,7 +520,8 @@ int main(int argc, char *argv[]) {
// ImGui::SliderFloat("erm", &rotation, -180, 180, "Rotation"); // ImGui::SliderFloat("erm", &rotation, -180, 180, "Rotation");
// rlImGuiImage(&current_player.tex.tex); // rlImGuiImage(&current_player.tex.tex);
ImGui::Separator(); ImGui::Separator();
ImGui::LabelText("Disc Info", "P: %f, V: %f, A: %f", disc.pos, disc.velo, disc.accel); ImGui::LabelText("Disc Info", "P: %f, V: %f, A: %f", disc.pos, disc.velo,
disc.accel);
rlImGuiImageSize(&current_player.tex.tex, 300, 300); rlImGuiImageSize(&current_player.tex.tex, 300, 300);
ImGui::Separator(); ImGui::Separator();
@ -528,7 +551,6 @@ int main(int argc, char *argv[]) {
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
} }
rlImGuiShutdown(); rlImGuiShutdown();
// De-Initialization // De-Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
CloseWindow(); // Close window and OpenGL context CloseWindow(); // Close window and OpenGL context