Gui: Use a perceptually uniform color map for Std_RandomColor

Using a restricted set of colrs with uniform lightless improves
the appearance of assemblies with randomly-colored parts.
This commit is contained in:
Alex Neufeld
2025-04-21 14:09:12 -06:00
committed by Kacper Donat
parent aec251427e
commit d377d43de5
2 changed files with 112 additions and 4 deletions

View File

@@ -29,6 +29,7 @@
#include <App/GroupExtension.h>
#include <App/Part.h>
#include "Application.h"
#include "cet_lut.hpp"
#include "CommandT.h"
#include "DockWindowManager.h"
#include "Document.h"
@@ -90,10 +91,10 @@ void StdCmdRandomColor::activated(int iMsg)
auto setRandomColor = [](ViewProvider* view) {
// NOLINTBEGIN
auto fMax = (float)RAND_MAX;
auto fRed = (float)rand()/fMax;
auto fGrn = (float)rand()/fMax;
auto fBlu = (float)rand()/fMax;
int colIndex = rand() % (CET::R1.size() / 3) * 3;
float fRed = CET::R1[colIndex] / 255.0F;
float fGrn = CET::R1[colIndex + 1] / 255.0F;
float fBlu = CET::R1[colIndex + 2] / 255.0F;
// NOLINTEND
auto objColor = Base::Color(fRed, fGrn, fBlu);

107
src/Gui/cet_lut.hpp Normal file

File diff suppressed because one or more lines are too long