mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-07-07 22:52:06 +08:00
Rainbow Road™
This commit is contained in:
@@ -725,6 +725,27 @@ void FrogPilotAnnotatedCameraWidget::paintPedalIcons(QPainter &p) {
|
||||
p.restore();
|
||||
}
|
||||
|
||||
void FrogPilotAnnotatedCameraWidget::paintRainbowPath(QPainter &p, QLinearGradient &bg, float lin_grad_point) {
|
||||
p.save();
|
||||
|
||||
static float hueOffset = 0.0f;
|
||||
if (speed > 0) {
|
||||
hueOffset += speed / speedConversion * 0.02f;
|
||||
|
||||
if (hueOffset >= 360.0f) {
|
||||
hueOffset = fmodf(hueOffset, 360.0f);
|
||||
}
|
||||
}
|
||||
|
||||
float alpha = util::map_val(lin_grad_point, 0.0f, 1.0f, 0.5f, 0.1f);
|
||||
float pathHue = fmodf(lin_grad_point * 120.0f + hueOffset, 360.0f);
|
||||
|
||||
bg.setColorAt(lin_grad_point, QColor::fromHslF(pathHue / 360.0f, 1.0f, 0.5f, alpha));
|
||||
bg.setSpread(QGradient::RepeatSpread);
|
||||
|
||||
p.restore();
|
||||
}
|
||||
|
||||
void FrogPilotAnnotatedCameraWidget::paintRadarTracks(QPainter &p) {
|
||||
if (radar_tracks.empty()) {
|
||||
return;
|
||||
|
||||
@@ -17,6 +17,7 @@ public:
|
||||
void paintFrogPilotWidgets(QPainter &p, UIState &s);
|
||||
void paintLeadMetrics(QPainter &p, bool adjacent, QPointF *chevron, const cereal::RadarState::LeadData::Reader &lead_data);
|
||||
void paintPathEdges(QPainter &p, int height);
|
||||
void paintRainbowPath(QPainter &p, QLinearGradient &bg, float lin_grad_point);
|
||||
void updateState(const UIState &s, const FrogPilotUIState &fs);
|
||||
|
||||
bool hideBottomIcons;
|
||||
|
||||
@@ -165,7 +165,7 @@ void ModelRenderer::drawLaneLines(QPainter &painter) {
|
||||
|
||||
void ModelRenderer::drawPath(QPainter &painter, const cereal::ModelDataV2::Reader &model, int height) {
|
||||
QLinearGradient bg(0, height, 0, 0);
|
||||
if (experimental_mode || frogpilot_toggles.value("acceleration_path").toBool()) {
|
||||
if (experimental_mode || frogpilot_toggles.value("acceleration_path").toBool() || frogpilot_toggles.value("rainbow_path").toBool()) {
|
||||
// The first half of track_vertices are the points for the right side of the path
|
||||
const auto &acceleration = model.getAcceleration().getX();
|
||||
const int max_len = std::min<int>(track_vertices.length() / 2, acceleration.size());
|
||||
@@ -178,7 +178,9 @@ void ModelRenderer::drawPath(QPainter &painter, const cereal::ModelDataV2::Reade
|
||||
// Flip so 0 is bottom of frame
|
||||
float lin_grad_point = (height - track_vertices[track_idx].y()) / height;
|
||||
|
||||
if (fabs(acceleration[i]) < 0.25 && frogpilot_toggles.value("color_scheme").toString() != "stock") {
|
||||
if ((fabs(acceleration[i]) < 0.25 || !frogpilot_toggles.value("acceleration_path").toBool()) && frogpilot_toggles.value("rainbow_path").toBool()) {
|
||||
frogpilot_nvg->paintRainbowPath(painter, bg, lin_grad_point);
|
||||
} else if (fabs(acceleration[i]) < 0.25 && frogpilot_toggles.value("color_scheme").toString() != "stock") {
|
||||
QColor color = QColor(frogpilot_toggles.value("path_color").toString());
|
||||
color.setAlphaF(util::map_val(lin_grad_point, 0.0f, 1.0f, 1.0f, 0.1f));
|
||||
bg.setColorAt(lin_grad_point, color);
|
||||
|
||||
Reference in New Issue
Block a user