diff options
author | Loïc Vital <mugulmotion@gmail.com> | 2022-10-11 12:46:32 +0300 |
---|---|---|
committer | Loïc Vital <mugulmotion@gmail.com> | 2022-10-11 12:46:32 +0300 |
commit | 24f31213cdbe673de5c51b051992ca21b57ab1f4 (patch) | |
tree | cf352e6f831daa13965b0c9fe6f0dec8c15c4180 | |
parent | 3a654ca8f8daaf5d15c483ea68c0797e465483cd (diff) |
[ui] use grey-green-yellow-red for duration color scale
-rw-r--r-- | meshroom/ui/qml/Controls/TextFileViewer.qml | 2 | ||||
-rw-r--r-- | meshroom/ui/qml/Utils/Colors.qml | 30 |
2 files changed, 27 insertions, 5 deletions
diff --git a/meshroom/ui/qml/Controls/TextFileViewer.qml b/meshroom/ui/qml/Controls/TextFileViewer.qml index 345ec312..bde6c87c 100644 --- a/meshroom/ui/qml/Controls/TextFileViewer.qml +++ b/meshroom/ui/qml/Controls/TextFileViewer.qml @@ -208,7 +208,7 @@ Item { Rectangle { width: 4 Layout.fillHeight: true - color: Colors.interpolate(Colors.grey, Colors.red, logLine.duration/180) + color: Colors.durationColor(logLine.duration) } // Line number Label { diff --git a/meshroom/ui/qml/Utils/Colors.qml b/meshroom/ui/qml/Utils/Colors.qml index 8f2d0972..5df40295 100644 --- a/meshroom/ui/qml/Utils/Colors.qml +++ b/meshroom/ui/qml/Utils/Colors.qml @@ -39,6 +39,13 @@ QtObject { "SUBMITTED": "#2196F3" } + readonly property var durationColorScale: [ + {"time": 0, "color": grey}, + {"time": 60, "color": green}, + {"time": 180, "color": yellow}, + {"time": 600, "color": red} + ] + function getChunkColor(chunk, overrides) { if(overrides && chunk.statusName in overrides) @@ -69,13 +76,28 @@ QtObject { ]; } - function interpolate(c1, c2, t) { + function interpolate(c1, c2, u) { let rgb1 = toRgb(c1); let rgb2 = toRgb(c2); return Qt.rgba( - rgb1[0] * (1-t) + rgb2[0] * t, - rgb1[1] * (1-t) + rgb2[1] * t, - rgb1[2] * (1-t) + rgb2[2] * t + rgb1[0] * (1-u) + rgb2[0] * u, + rgb1[1] * (1-u) + rgb2[1] * u, + rgb1[2] * (1-u) + rgb2[2] * u ); } + + function durationColor(t) { + if (t < durationColorScale[0].time) { + return durationColorScale[0].color; + } + if (t > durationColorScale[durationColorScale.length-1].time) { + return durationColorScale[durationColorScale.length-1].color; + } + for (let idx = 1; idx < durationColorScale.length; idx++) { + if (t < durationColorScale[idx].time) { + let u = (t - durationColorScale[idx-1].time) / (durationColorScale[idx].time - durationColorScale[idx-1].time); + return interpolate(durationColorScale[idx-1].color, durationColorScale[idx].color, u); + } + } + } } |