MCPcopy Create free account
hub / github.com/MiniZinc/MiniZincIDE / interpolate

Method interpolate

MiniZincIDE/codeeditor.cpp:587–597  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

585}
586
587QColor CodeEditor::interpolate(QColor start,QColor end,double ratio)
588{
589 //From https://stackoverflow.com/questions/3306786/get-intermediate-color-from-a-gradient
590 int r = static_cast<int>(ratio*start.red() + (1-ratio)*end.red());
591 int g = static_cast<int>(ratio*start.green() + (1-ratio)*end.green());
592 int b = static_cast<int>(ratio*start.blue() + (1-ratio)*end.blue());
593 int a = static_cast<int>(ratio*start.alpha() + (1-ratio)*end.alpha());
594 QColor c = QColor::fromRgb(r,g,b);
595 c.setAlpha(a); // Strangely there seems to be no clean way of creating a rgba color, fromRgba does not take 4 parameters as one would expect.
596 return c;
597}
598
599QColor CodeEditor::heatColor(double ratio)
600{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected