|
|
|
|
@@ -823,6 +823,14 @@ void AnnotatedCameraWidget::updateFrameMat() {
|
|
|
|
|
void AnnotatedCameraWidget::drawLaneLines(QPainter &painter, const UIState *s) {
|
|
|
|
|
painter.save();
|
|
|
|
|
|
|
|
|
|
// CLEARPILOT: color channel code rewriten to allow custom colors
|
|
|
|
|
// Define base RGB color and alpha
|
|
|
|
|
int base_red = 255; // Example red color
|
|
|
|
|
int base_green = 200; // Example green color
|
|
|
|
|
int base_blue = 150; // Example blue color
|
|
|
|
|
float base_alpha = 0.75; // Example base alpha
|
|
|
|
|
QColor baseColor(base_red, base_green, base_blue);
|
|
|
|
|
|
|
|
|
|
SubMaster &sm = *(s->sm);
|
|
|
|
|
|
|
|
|
|
// lanelines
|
|
|
|
|
@@ -864,59 +872,32 @@ void AnnotatedCameraWidget::drawLaneLines(QPainter &painter, const UIState *s) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < max_len; ++i) {
|
|
|
|
|
// Some points are out of frame
|
|
|
|
|
if (scene.track_vertices[i].y() < 0 || scene.track_vertices[i].y() > height()) continue;
|
|
|
|
|
|
|
|
|
|
// Flip so 0 is bottom of frame
|
|
|
|
|
float lin_grad_point = (height() - scene.track_vertices[i].y()) / height();
|
|
|
|
|
|
|
|
|
|
// CLEARPILOT disabling custom theme colors
|
|
|
|
|
// // If acceleration is between -0.25 and 0.25, resort to the theme color
|
|
|
|
|
// if (std::abs(acceleration[i]) < 0.25 && (currentHolidayTheme != 0)) {
|
|
|
|
|
// const auto &colorMap = std::get<2>(holidayThemeConfiguration[currentHolidayTheme]);
|
|
|
|
|
// for (const auto &[position, brush] : colorMap) {
|
|
|
|
|
// bg.setColorAt(position, brush.color());
|
|
|
|
|
// }
|
|
|
|
|
float path_hue = std::max(std::min(60 + acceleration[i] * 35, 120.f), 0.f);
|
|
|
|
|
path_hue = static_cast<int>(path_hue * 100 + 0.5) / 100; // Ensuring hue is rounded to reduce processing
|
|
|
|
|
|
|
|
|
|
// } else if (std::abs(acceleration[i]) < 0.25 && (customColors != 0)) {
|
|
|
|
|
// const auto &colorMap = std::get<2>(themeConfiguration[customColors]);
|
|
|
|
|
// for (const auto &[position, brush] : colorMap) {
|
|
|
|
|
// bg.setColorAt(position, brush.color());
|
|
|
|
|
// }
|
|
|
|
|
float saturation = std::min(std::abs(acceleration[i] * 1.5f), 1.f);
|
|
|
|
|
float lightness = util::map_val(saturation, 0.5f, 0.0f, 0.95f, 0.62f); // lighter when grey
|
|
|
|
|
|
|
|
|
|
// } else {
|
|
|
|
|
// speed up: 120, slow down: 0
|
|
|
|
|
float path_hue = fmax(fmin(60 + acceleration[i] * 35, 120), 0);
|
|
|
|
|
// FIXME: painter.drawPolygon can be slow if hue is not rounded
|
|
|
|
|
path_hue = int(path_hue * 100 + 0.5) / 100;
|
|
|
|
|
float dynamic_alpha = util::map_val(lin_grad_point, 0.75f / 2.f, 0.75f, base_alpha, 0.0f);
|
|
|
|
|
|
|
|
|
|
float saturation = fmin(fabs(acceleration[i] * 1.5), 1);
|
|
|
|
|
float lightness = util::map_val(saturation, 0.0f, 1.0f, 0.95f, 0.62f); // lighter when grey
|
|
|
|
|
float alpha = util::map_val(lin_grad_point, 0.75f / 2.f, 0.75f, 0.4f, 0.0f); // matches previous alpha fade
|
|
|
|
|
bg.setColorAt(lin_grad_point, QColor::fromHslF(path_hue / 360., saturation, lightness, alpha));
|
|
|
|
|
QColor base_color = QColor::fromRgb(base_red, base_green, base_blue);
|
|
|
|
|
float h, s, l;
|
|
|
|
|
base_color.getHslF(&h, &s, &l);
|
|
|
|
|
QColor final_color = QColor::fromHslF(path_hue / 360., saturation, lightness, dynamic_alpha);
|
|
|
|
|
|
|
|
|
|
// Skip a point, unless next is last
|
|
|
|
|
i += (i + 2) < max_len ? 1 : 0;
|
|
|
|
|
// }
|
|
|
|
|
bg.setColorAt(lin_grad_point, final_color);
|
|
|
|
|
|
|
|
|
|
i += (i + 2) < max_len ? 1 : 0; // skipping a point to optimize rendering
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// CLEARPILOT disabling custom theme colors
|
|
|
|
|
// } else if (currentHolidayTheme != 0) {
|
|
|
|
|
// const auto &colorMap = std::get<2>(holidayThemeConfiguration[currentHolidayTheme]);
|
|
|
|
|
// for (const auto &[position, brush] : colorMap) {
|
|
|
|
|
// bg.setColorAt(position, brush.color());
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// } else if (customColors != 0) {
|
|
|
|
|
// const auto &colorMap = std::get<2>(themeConfiguration[customColors]);
|
|
|
|
|
// for (const auto &[position, brush] : colorMap) {
|
|
|
|
|
// bg.setColorAt(position, brush.color());
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
bg.setColorAt(0.0, QColor::fromHslF(148 / 360., 0.94, 0.51, 0.4));
|
|
|
|
|
bg.setColorAt(0.5, QColor::fromHslF(112 / 360., 1.0, 0.68, 0.35));
|
|
|
|
|
bg.setColorAt(1.0, QColor::fromHslF(112 / 360., 1.0, 0.68, 0.0));
|
|
|
|
|
bg.setColorAt(0.0, QColor(baseColor.red(), baseColor.green(), baseColor.blue(), static_cast<int>(base_alpha * 255 * 0.4)));
|
|
|
|
|
bg.setColorAt(0.5, QColor(baseColor.red(), baseColor.green(), baseColor.blue(), static_cast<int>(base_alpha * 255 * 0.35)));
|
|
|
|
|
bg.setColorAt(1.0, QColor(baseColor.red(), baseColor.green(), baseColor.blue(), static_cast<int>(base_alpha * 255 * 0.0)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
painter.setBrush(bg);
|
|
|
|
|
@@ -944,22 +925,10 @@ void AnnotatedCameraWidget::drawLaneLines(QPainter &painter, const UIState *s) {
|
|
|
|
|
pe.setColorAt(0.0, QColor::fromHslF(205 / 360., 0.85, 0.56, 1.0));
|
|
|
|
|
pe.setColorAt(0.5, QColor::fromHslF(205 / 360., 0.85, 0.56, 0.5));
|
|
|
|
|
pe.setColorAt(1.0, QColor::fromHslF(205 / 360., 0.85, 0.56, 0.1));
|
|
|
|
|
// } else if (currentHolidayTheme != 0) {
|
|
|
|
|
// const auto &colorMap = std::get<2>(holidayThemeConfiguration[currentHolidayTheme]);
|
|
|
|
|
// for (const auto &[position, brush] : colorMap) {
|
|
|
|
|
// QColor darkerColor = brush.color().darker(120);
|
|
|
|
|
// pe.setColorAt(position, darkerColor);
|
|
|
|
|
// }
|
|
|
|
|
// } else if (customColors != 0) {
|
|
|
|
|
// const auto &colorMap = std::get<2>(themeConfiguration[customColors]);
|
|
|
|
|
// for (const auto &[position, brush] : colorMap) {
|
|
|
|
|
// QColor darkerColor = brush.color().darker(120);
|
|
|
|
|
// pe.setColorAt(position, darkerColor);
|
|
|
|
|
// }
|
|
|
|
|
} else {
|
|
|
|
|
pe.setColorAt(0.0, QColor::fromHslF(148 / 360., 0.94, 0.51, 1.0));
|
|
|
|
|
pe.setColorAt(0.5, QColor::fromHslF(112 / 360., 1.00, 0.68, 0.5));
|
|
|
|
|
pe.setColorAt(1.0, QColor::fromHslF(112 / 360., 1.00, 0.68, 0.1));
|
|
|
|
|
pe.setColorAt(0.0, QColor(baseColor.red(), baseColor.green(), baseColor.blue(), static_cast<int>(base_alpha * 255)));
|
|
|
|
|
pe.setColorAt(0.5, QColor(baseColor.red(), baseColor.green(), baseColor.blue(), static_cast<int>(base_alpha * 255 * 0.5)));
|
|
|
|
|
pe.setColorAt(1.0, QColor(baseColor.red(), baseColor.green(), baseColor.blue(), static_cast<int>(base_alpha * 255 * 0.1)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QPainterPath path;
|
|
|
|
|
|