variation de valeur précise (lent) / accel)

This commit is contained in:
2025-12-28 11:42:32 +01:00
parent 088d5b7739
commit 37b5ce3951
2 changed files with 71 additions and 31 deletions

102
main.c
View File

@ -3,7 +3,7 @@
#define RAYGUI_IMPLEMENTATION
#include "raygui.h"
#define UI_WIDTH 400
#define UI_WIDTH 450
#define COLOR_BG (Color){ 25, 25, 30, 255 }
#define COLOR_PANEL (Color){ 40, 40, 45, 255 }
#define COLOR_ACCENT (Color){ 0, 120, 240, 255 }
@ -41,6 +41,12 @@ void DrawLaserBeam(Vector2 start, Vector2 end, Color color, float thickness) {
DrawLineEx(start, end, thickness, color);
}
bool GuiButtonRepeat(Rectangle bounds, const char* text, bool shouldRepeat) {
bool clicked = GuiButton(bounds, text);
bool held = CheckCollisionPointRec(GetMousePosition(), bounds) && IsMouseButtonDown(MOUSE_LEFT_BUTTON) && shouldRepeat;
return clicked || held;
}
void DrawInterferenceViewCPU(Michelson *mic, Rectangle rec) {
DrawRectangleRec((Rectangle){rec.x - 4, rec.y - 30, rec.width + 8, rec.height + 34}, COLOR_PANEL);
//DrawText("ECRAN", rec.x, rec.y - 30, 20, WHITE);
@ -196,42 +202,77 @@ void DrawControlPanel(Michelson *mic) {
DrawRectangle(0, 0, UI_WIDTH, GetScreenHeight(), Fade(COLOR_PANEL, 0.95f));
DrawLine(UI_WIDTH, 0, UI_WIDTH, GetScreenHeight(), Fade(WHITE, 0.1f));
int startX = 30;
static int holdTimer = 0;
if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) holdTimer++;
else holdTimer = 0;
bool shouldRepeat = (holdTimer > 30 && (holdTimer % 3 == 0)); // Répète / 3 frames
int startX = 20;
int startY = 30;
int buttonWidth = 70;
int spacing = 20;
int contentWidth = UI_WIDTH - 60;
int sliderWidth = contentWidth - buttonWidth - spacing - 15;
int contentWidth = UI_WIDTH - 40;
int btnSize = 30;
int sliderWidth = contentWidth - (btnSize * 2) - 10;
GuiSetStyle(DEFAULT, TEXT_SIZE, 16);
GuiSetStyle(DEFAULT, BASE_COLOR_NORMAL, 0x2D2D2DFF); // Gris foncé boutons
GuiSetStyle(DEFAULT, BASE_COLOR_FOCUSED, 0x454545FF); // Gris clair hover
GuiSetStyle(DEFAULT, BASE_COLOR_PRESSED, 0x1A1A1AFF); // Très foncé click
GuiSetStyle(DEFAULT, TEXT_COLOR_NORMAL, 0xFFFFFFFF); // Texte blanc
GuiSetStyle(DEFAULT, BASE_COLOR_NORMAL, 0x2D2D2DFF);
GuiSetStyle(DEFAULT, BASE_COLOR_FOCUSED, 0x454545FF);
GuiSetStyle(DEFAULT, BASE_COLOR_PRESSED, 0x1A1A1AFF);
GuiSetStyle(DEFAULT, TEXT_COLOR_NORMAL, 0xFFFFFFFF);
GuiSetStyle(DEFAULT, BORDER_COLOR_NORMAL, 0x505050FF);
GuiSetStyle(DEFAULT, BORDER_COLOR_FOCUSED, 0x0078D7FF); // Bordures bleues (focus)
GuiSetStyle(DEFAULT, BORDER_COLOR_FOCUSED, 0x0078D7FF);
GuiSetStyle(DEFAULT, BACKGROUND_COLOR, 0x1E1E1EFF);
DrawText("PARAMETRES", startX, startY, 30, WHITE);
DrawLine(startX, startY + 35, startX + contentWidth, startY + 35, COLOR_ACCENT);
// Sliders
startY += 70;
DrawText(TextFormat("Longueur d'onde: %.0f nm", mic->lambda), startX, startY, 20, COLOR_TEXT_SEC);
GuiSlider((Rectangle){startX, startY + 30, contentWidth - 45, 25}, NULL, NULL, &mic->lambda, 380, 780);
DrawRectangle(startX + contentWidth - 35, startY + 30, 35, 25, WavelengthToColor(mic->lambda));
startY += 90;
DrawText(TextFormat("Position M1 (d1): %.1f um", mic->d1), startX, startY, 20, ORANGE);
GuiSlider((Rectangle){startX, startY + 30, sliderWidth, 25}, NULL, NULL, &mic->d1, 100, 600);
if (GuiButton((Rectangle){startX + sliderWidth + spacing + 15, startY + 30, buttonWidth, 25}, "Egal")) mic->d1 = mic->d2;
startY += 90;
DrawText(TextFormat("Inclinaison M1: %.2f deg", mic->angleM1), startX, startY, 20, ORANGE);
GuiSlider((Rectangle){startX, startY + 30, sliderWidth, 25}, "-1", "+1", &mic->angleM1, -1.0f, 1.0f);
if (GuiButton((Rectangle){startX + sliderWidth + spacing + 15, startY + 30, buttonWidth, 25}, "0.0")) mic->angleM1 = 0.0f;
bool speedMode = IsKeyDown(KEY_LEFT_SHIFT) || IsKeyDown(KEY_RIGHT_SHIFT);
bool isLameAir = (fabs(mic->angleM1) < 0.01f);
const char* modeTxtStatus = speedMode ? "(SHIFT ACTIF: VITESSE RAPIDE)" : "(Maintenir SHIFT pour accelerer)";
Color statusColor = speedMode ? ORANGE : GRAY;
DrawText(modeTxtStatus, startX, startY + 45, 10, statusColor);
// Longueur d'onde
startY += 80;
DrawText(TextFormat("Longueur d'onde: %.0f nm", mic->lambda), startX, startY, 20, COLOR_TEXT_SEC);
float stepLambda = speedMode ? 10.0f : 1.0f;
if (GuiButtonRepeat((Rectangle){startX, startY + 30, btnSize, 25}, "-", shouldRepeat)) mic->lambda -= stepLambda;
GuiSlider((Rectangle){startX + btnSize + 5, startY + 30, sliderWidth - 40, 25}, NULL, NULL, &mic->lambda, 380, 780);
if (GuiButtonRepeat((Rectangle){startX + btnSize + sliderWidth - 30, startY + 30, btnSize, 25}, "+", shouldRepeat)) mic->lambda += stepLambda;
DrawRectangle(startX + contentWidth - 30, startY + 30, 30, 25, WavelengthToColor(mic->lambda));
// Pos M1
startY += 90;
DrawText(TextFormat("Position M1 : %.2f um", mic->d1), startX, startY, 20, ORANGE);
// Pas des + et -
float stepD1 = speedMode ? 0.5f : 0.005f;
if (GuiButtonRepeat((Rectangle){startX, startY + 30, btnSize, 25}, "-", shouldRepeat)) mic->d1 -= stepD1;
GuiSlider((Rectangle){startX + btnSize + 5, startY + 30, sliderWidth - 75, 25}, NULL, NULL, &mic->d1, 100, 600);
if (GuiButtonRepeat((Rectangle){startX + btnSize + sliderWidth - 65, startY + 30, btnSize, 25}, "+", shouldRepeat)) mic->d1 += stepD1;
if (GuiButton((Rectangle){startX + contentWidth - 60, startY + 30, 60, 25}, "Egal")) mic->d1 = mic->d2;
// Angle M1
startY += 90;
DrawText(TextFormat("Inclinaison M1: %.3f deg", mic->angleM1), startX, startY, 20, ORANGE);
float stepAngle = speedMode ? 0.05f : 0.001f;
if (GuiButtonRepeat((Rectangle){startX, startY + 30, btnSize, 25}, "-", shouldRepeat)) mic->angleM1 -= stepAngle;
GuiSlider((Rectangle){startX + btnSize + 5, startY + 30, sliderWidth - 75, 25}, 0, 0, &mic->angleM1, -1.0f, 1.0f);
if (GuiButtonRepeat((Rectangle){startX + btnSize + sliderWidth - 65, startY + 30, btnSize, 25}, "+", shouldRepeat)) mic->angleM1 += stepAngle;
if (GuiButton((Rectangle){startX + contentWidth - 60, startY + 30, 60, 25}, "Zero")) mic->angleM1 = 0.0f;
// Status
bool isLameAir = (fabs(mic->angleM1) < 0.001f);
const char* modeTxt = isLameAir ? "MODE: LAME D'AIR" : "MODE: COIN D'AIR";
Color modeColor = isLameAir ? SKYBLUE : GREEN;
@ -239,7 +280,7 @@ void DrawControlPanel(Michelson *mic) {
DrawRectangleLines(startX, startY + 70, contentWidth, 30, modeColor);
DrawText(modeTxt, startX + 10, startY + 78, 18, modeColor);
// Données
// Données
startY += 150;
DrawLine(startX, startY - 20, startX + contentWidth, startY - 20, GRAY);
DrawText("DONNEES TEMPS REEL", startX, startY, 20, GRAY);
@ -250,14 +291,13 @@ void DrawControlPanel(Michelson *mic) {
float p = (delta * 1000.0f) / mic->lambda;
DrawText(TextFormat("Ordre p = %.2f", p), startX, startY + 65, 20, WHITE);
// Bas
int bottomY = GetScreenHeight() - 40;
DrawLine(0, bottomY, UI_WIDTH, bottomY, Fade(WHITE, 0.1f));
int fps = GetFPS();
Color fpsColor = (fps >= 100) ? COLOR_ACCENT : (fps >= 60 ? GREEN : (fps >= 30 ? ORANGE : RED));
DrawText("STATUT:", startX, bottomY + 12, 20, COLOR_TEXT_DIM);
DrawText(TextFormat("%i FPS", fps), startX + 100, bottomY + 12, 20, fpsColor);
DrawText(TextFormat("GPU MODE | %i FPS", fps), startX + 100, bottomY + 12, 20, fpsColor);
}
int main () {