This commit is contained in:
Your Name
2024-05-02 22:47:28 -05:00
parent e2cde8e886
commit 7ca074cd79
3 changed files with 40 additions and 34 deletions

View File

@@ -770,10 +770,10 @@ void AnnotatedCameraWidget::drawHud(QPainter &p) {
if (!(scene.hide_speed || bigMapOpen)) {
// CLEARPILOT changes to 120 from ~176
// Maybe we want to hide this?
p.setFont(InterFont(120, QFont::Bold));
p.setFont(InterFont(140, QFont::Bold));
drawText(p, rect().center().x(), 210, speedStr);
// CLEARPILOT changes to 40 from 66
p.setFont(InterFont(40));
p.setFont(InterFont(50));
drawText(p, rect().center().x(), 290, speedUnit, 200);
}
@@ -824,14 +824,15 @@ 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 = 150; // Dark red component
int base_green = 150; // Minimal green component
int base_blue = 150; // Minimal blue component
float path_alpha = 0.75; // 60% opacity
// Center lane color
// This should be moved to ui.h
int base_red = 150;
int base_green = 150;
int base_blue = 150;
float path_alpha = 0.30; // 60% opacity
float other_alpha = 0.75; // 60% opacity
QColor baseColor(base_red, base_green, base_blue);
QColor center_lane_color(base_red, base_green, base_blue);
SubMaster &sm = *(s->sm);
@@ -873,32 +874,38 @@ void AnnotatedCameraWidget::drawLaneLines(QPainter &painter, const UIState *s) {
acceleration.push_back(acceleration_const[i]);
}
for (int i = 0; i < max_len; ++i) {
if (scene.track_vertices[i].y() < 0 || scene.track_vertices[i].y() > height()) continue;
try {
for (int i = 0; i < max_len; ++i) {
if (scene.track_vertices[i].y() < 0 || scene.track_vertices[i].y() > height()) continue;
float lin_grad_point = (height() - scene.track_vertices[i].y()) / height();
float lin_grad_point = (height() - scene.track_vertices[i].y()) / height();
QColor base_color = QColor::fromRgb(base_red, base_green, base_blue);
double _h, _s, _l; // Use double for compatibility with QColor::getHslF()
base_color.getHslF(&_h, &_s, &_l); // Extracting HSL values from the base color
double _h, _s, _l; // Use double for compatibility with QColor::getHslF()
center_lane_color.getHslF(&_h, &_s, &_l);
// Calculate saturation and lightness based on acceleration
float adjusted_saturation = std::min(std::abs(acceleration[i] * 1.5f), 1.f);
float adjusted_lightness = util::map_val(adjusted_saturation, 0.f, 1.f, static_cast<float>(_l), 0.95f); // Using base lightness as a starting point
// Calculate saturation and lightness based on acceleration
float adjusted_saturation = std::min(std::abs(acceleration[i] * 1.5f), 1.f);
float adjusted_lightness = util::map_val(adjusted_saturation, 0.f, 1.f, static_cast<float>(_l), 0.95f); // Using base lightness as a starting point
// Calculate dynamic alpha based on lin_grad_point
float dynamic_alpha = util::map_val(lin_grad_point, 0.75f / 2.f, 0.75f, path_alpha, 0.f);
// Calculate dynamic alpha based on lin_grad_point
float dynamic_alpha = util::map_val(lin_grad_point, 0.75f / 2.f, 0.75f, path_alpha, 0.f);
QColor final_color = QColor::fromHslF(static_cast<float>(_h / 360.f), adjusted_saturation, adjusted_lightness, dynamic_alpha);
bg.setColorAt(lin_grad_point, final_color);
i += (i + 2) < max_len ? 1 : 0; // Skipping a point to optimize rendering
QColor final_color = QColor::fromHslF(static_cast<float>(_h / 360.f), adjusted_saturation, adjusted_lightness, dynamic_alpha);
bg.setColorAt(lin_grad_point, final_color);
}
i += (i + 2) < max_len ? 1 : 0; // Skipping a point to optimize rendering
}
} catch () {
// Default shading if for some reason the above code fails
bg = QLinearGradient(0, height(), 0, 0);
bg.setColorAt(0.0, QColor(center_lane_color.red(), center_lane_color.green(), center_lane_color.blue(), static_cast<int>(other_alpha * 255 * 0.4)));
bg.setColorAt(0.5, QColor(center_lane_color.red(), center_lane_color.green(), center_lane_color.blue(), static_cast<int>(other_alpha * 255 * 0.35)));
bg.setColorAt(1.0, QColor(center_lane_color.red(), center_lane_color.green(), center_lane_color.blue(), static_cast<int>(other_alpha * 255 * 0.0)));
}
} else {
bg.setColorAt(0.0, QColor(baseColor.red(), baseColor.green(), baseColor.blue(), static_cast<int>(other_alpha * 255 * 0.4)));
bg.setColorAt(0.5, QColor(baseColor.red(), baseColor.green(), baseColor.blue(), static_cast<int>(other_alpha * 255 * 0.35)));
bg.setColorAt(1.0, QColor(baseColor.red(), baseColor.green(), baseColor.blue(), static_cast<int>(other_alpha * 255 * 0.0)));
bg.setColorAt(0.0, QColor(center_lane_color.red(), center_lane_color.green(), center_lane_color.blue(), static_cast<int>(other_alpha * 255 * 0.4)));
bg.setColorAt(0.5, QColor(center_lane_color.red(), center_lane_color.green(), center_lane_color.blue(), static_cast<int>(other_alpha * 255 * 0.35)));
bg.setColorAt(1.0, QColor(center_lane_color.red(), center_lane_color.green(), center_lane_color.blue(), static_cast<int>(other_alpha * 255 * 0.0)));
}
painter.setBrush(bg);