diff --git a/main.c b/main.c index b8d7327..b209605 100644 --- a/main.c +++ b/main.c @@ -190,7 +190,8 @@ void DrawControlPanel(Michelson *mic) { int startY = 30; int contentWidth = UI_WIDTH - 40; int btnSize = 30; - int sliderWidth = contentWidth - (btnSize * 2) - 10; + int spectrumWidth = contentWidth - (btnSize * 2) - 10; + int sliderWidth = spectrumWidth; GuiSetStyle(DEFAULT, TEXT_SIZE, 16); GuiSetStyle(DEFAULT, BASE_COLOR_NORMAL, 0x2D2D2DFF); @@ -215,11 +216,41 @@ void DrawControlPanel(Michelson *mic) { 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)); + + Rectangle spectrumRect = {startX + btnSize + 5, startY + 30, spectrumWidth, 25}; + + for (int i = 0; i < spectrumRect.width; i++) { + float prog = (float)i / spectrumRect.width; + float l = 380.0f + prog * (780.0f - 380.0f); + Color c = WavelengthToColor(l); + DrawLine(spectrumRect.x + i, spectrumRect.y, spectrumRect.x + i, spectrumRect.y + spectrumRect.height, c); + } + DrawRectangleLinesEx(spectrumRect, 1, DARKGRAY); + + if (CheckCollisionPointRec(GetMousePosition(), spectrumRect)) { + if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) { + float mouseX = GetMouseX() - spectrumRect.x; + float ratio = mouseX / spectrumRect.width; + mic->lambda = 380.0f + ratio * (780.0f - 380.0f); + } + } + + float currentRatio = (mic->lambda - 380.0f) / (780.0f - 380.0f); + if (currentRatio < 0) currentRatio = 0; + if (currentRatio > 1) currentRatio = 1; + + float cursorX = spectrumRect.x + currentRatio * spectrumRect.width; + + DrawLine(cursorX - 1, spectrumRect.y, cursorX - 1, spectrumRect.y + spectrumRect.height, BLACK); + DrawLine(cursorX + 1, spectrumRect.y, cursorX + 1, spectrumRect.y + spectrumRect.height, BLACK); + DrawLine(cursorX, spectrumRect.y, cursorX, spectrumRect.y + spectrumRect.height, WHITE); + + if (GuiButtonRepeat((Rectangle){startX + btnSize + spectrumWidth + 10, startY + 30, btnSize, 25}, "+", shouldRepeat)) mic->lambda += stepLambda; + + if (mic->lambda < 380) mic->lambda = 380; + if (mic->lambda > 780) mic->lambda = 780; // Pos M1 diff --git a/michelson b/michelson index 808344e..11f75cb 100755 Binary files a/michelson and b/michelson differ