This commit is contained in:
2025-12-28 15:58:02 +01:00
parent acbda14a43
commit d8e178fe06
2 changed files with 36 additions and 5 deletions

39
main.c
View File

@ -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);
@ -217,9 +218,39 @@ void DrawControlPanel(Michelson *mic) {
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

BIN
michelson

Binary file not shown.