Skip to content

Commit

Permalink
Simplify lane line color calculation (commaai#199)
Browse files Browse the repository at this point in the history
* temp

* simplify lane line color calculation with 1d poly from numpy

* simplify lane line color calculation with 1d poly from numpy

* fix

* not needed

* remove comments

* remove file
  • Loading branch information
sshane authored and jamcar23 committed Sep 8, 2020
1 parent aaadf7c commit 480c178
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion selfdrive/ui/paint.cc
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,12 @@ static void update_all_lane_lines_data(UIState *s, const PathData &path, model_p
update_lane_line_data(s, path.points, var, pstart + 2, path.validLen);
}

static void ui_draw_lane(UIState *s, const PathData *path, model_path_vertices_data *pstart, NVGcolor color) {
static void ui_draw_lane(UIState *s, const PathData *path, model_path_vertices_data *pstart, float prob) {
float lane_pos = std::abs(path->poly[3]); // get redder when line is closer to car
float hue = 332.5 * lane_pos - 332.5; // equivalent to {1.4, 1.0}: {133, 0} (green to red)
hue = fmin(133, fmax(0, hue)) / 360.; // clip and normalize
NVGcolor color = nvgHSLA(hue, 0.73, 0.64, prob * 255);

ui_draw_lane_line(s, pstart, color);
color.a /= 25;
ui_draw_lane_line(s, pstart + 1, color);
Expand Down

0 comments on commit 480c178

Please sign in to comment.