update circle draw (I forgor what I did like 2 months ago)
This commit is contained in:
parent
ebfb6e239a
commit
cebf244da0
62
src/main.cpp
62
src/main.cpp
|
@ -246,9 +246,11 @@ void GenCircleOverlay(MprisPlayer *current_player, RenderTexture tex, bool trans
|
|||
}
|
||||
BeginBlendMode(BLEND_SUBTRACT_COLORS);
|
||||
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 {
|
||||
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();
|
||||
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_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");
|
||||
SetTargetFPS(244);
|
||||
rlImGuiSetup(true);
|
||||
|
@ -297,7 +299,8 @@ int main(int argc, char *argv[]) {
|
|||
RenderTexture recordoverlay = LoadRenderTexture(screenWidth, screenHeight);
|
||||
GenCircleOverlay(¤t_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()) {
|
||||
UnloadRenderTexture(recordoverlay);
|
||||
|
@ -322,17 +325,21 @@ int main(int argc, char *argv[]) {
|
|||
ClearBackground(BLACK);
|
||||
}
|
||||
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 fpos;
|
||||
fpos.x = (winwidth.x * 0.5) - (scaledsize.x * 0.5f);
|
||||
fpos.y = (winwidth.y * 0.5) - (scaledsize.y * 0.5f);
|
||||
// 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 dst = (Rectangle){fpos.x + scaledsize.x / 2, fpos.y + scaledsize.y / 2, scaledsize.x, scaledsize.y};
|
||||
Rectangle src = (Rectangle){0, 0, (float)current_player.tex.tex.width,
|
||||
(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()) {
|
||||
const float buttonsize = 0.1;
|
||||
|
@ -359,29 +366,44 @@ int main(int argc, char *argv[]) {
|
|||
DrawCircleV(back, 0.05 * GetScreenWidth(), transblack);
|
||||
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.playstate = current_player.playstate == "Playing" ? "Paused" : "Playing";
|
||||
} else if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT) && CheckCollisionPointCircle(GetMousePosition(), next, 0.05 * GetScreenWidth())) {
|
||||
current_player.playstate =
|
||||
current_player.playstate == "Playing" ? "Paused" : "Playing";
|
||||
} else if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT) &&
|
||||
CheckCollisionPointCircle(GetMousePosition(), next,
|
||||
0.05 * GetScreenWidth())) {
|
||||
current_player.Next();
|
||||
current_player.playstate = current_player.playstate == "Playing" ? "Paused" : "Playing";
|
||||
} else if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT) && CheckCollisionPointCircle(GetMousePosition(), back, 0.05 * GetScreenWidth())) {
|
||||
current_player.playstate =
|
||||
current_player.playstate == "Playing" ? "Paused" : "Playing";
|
||||
} else if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT) &&
|
||||
CheckCollisionPointCircle(GetMousePosition(), back,
|
||||
0.05 * GetScreenWidth())) {
|
||||
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) {
|
||||
float initmouserot;
|
||||
Vector2 initmousepos;
|
||||
if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) {
|
||||
initmouserot = disc.pos;
|
||||
initmousepos = GetMousePosition();
|
||||
initmousepos = Vector2Add(initmousepos, (Vector2){-screen.x / 2, -screen.y / 2});
|
||||
initmousepos =
|
||||
Vector2Add(initmousepos, (Vector2){-screen.x / 2, -screen.y / 2});
|
||||
goodstate = true;
|
||||
}
|
||||
if (goodstate) {
|
||||
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.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");
|
||||
// rlImGuiImage(¤t_player.tex.tex);
|
||||
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(¤t_player.tex.tex, 300, 300);
|
||||
|
||||
ImGui::Separator();
|
||||
|
@ -528,11 +551,10 @@ int main(int argc, char *argv[]) {
|
|||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
rlImGuiShutdown();
|
||||
|
||||
// De-Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
CloseWindow(); // Close window and OpenGL context
|
||||
//--------------------------------------------------------------------------------------
|
||||
curl_global_cleanup();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue