wip
This commit is contained in:
@@ -874,27 +874,26 @@ void AnnotatedCameraWidget::drawLaneLines(QPainter &painter, const UIState *s) {
|
|||||||
acceleration.push_back(acceleration_const[i]);
|
acceleration.push_back(acceleration_const[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
for (int i = 0; i < max_len; ++i) {
|
for (int i = 0; i < max_len; ++i) {
|
||||||
if (scene.track_vertices[i].y() < 0 || scene.track_vertices[i].y() > height()) continue;
|
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();
|
||||||
|
|
||||||
double _h, _s, _l; // Use double for compatibility with QColor::getHslF()
|
double _h, _s, _l; // Use double for compatibility with QColor::getHslF()
|
||||||
center_lane_color.getHslF(&_h, &_s, &_l);
|
center_lane_color.getHslF(&_h, &_s, &_l);
|
||||||
|
|
||||||
// Calculate saturation and lightness based on acceleration
|
// Calculate saturation and lightness based on acceleration
|
||||||
float adjusted_saturation = std::min(std::abs(acceleration[i] * 1.5f), 1.f);
|
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
|
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
|
// 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);
|
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);
|
QColor final_color = QColor::fromHslF(static_cast<float>(_h / 360.f), adjusted_saturation, adjusted_lightness, dynamic_alpha);
|
||||||
bg.setColorAt(lin_grad_point, final_color);
|
bg.setColorAt(lin_grad_point, final_color);
|
||||||
|
|
||||||
i += (i + 2) < max_len ? 1 : 0; // Skipping a point to optimize rendering
|
i += (i + 2) < max_len ? 1 : 0; // Skipping a point to optimize rendering
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch () {
|
} catch () {
|
||||||
// Default shading if for some reason the above code fails
|
// Default shading if for some reason the above code fails
|
||||||
|
|||||||
Reference in New Issue
Block a user