paint.cc: Simplify drawing line (#1643)

* simplify drawing line

* remove space
old-commit-hash: ff4f432f0f
commatwo_master
Dean Lee 5 years ago committed by GitHub
parent 0a37fc0565
commit 0a9b8f2a32
  1. 36
      selfdrive/ui/paint.cc

@ -128,20 +128,12 @@ static void draw_lead(UIState *s, const cereal::RadarState::LeadData::Reader &le
}
static void ui_draw_lane_line(UIState *s, const model_path_vertices_data *pvd, NVGcolor color) {
if (pvd->cnt == 0) return;
nvgBeginPath(s->vg);
bool started = false;
for (int i=0; i<pvd->cnt; i++) {
float x = pvd->v[i].x;
float y = pvd->v[i].y;
if (x < 0 || y < 0.) {
continue;
}
if (!started) {
nvgMoveTo(s->vg, x, y);
started = true;
} else {
nvgLineTo(s->vg, x, y);
}
nvgMoveTo(s->vg, pvd->v[0].x, pvd->v[0].y);
for (int i=1; i<pvd->cnt; i++) {
nvgLineTo(s->vg, pvd->v[i].x, pvd->v[i].y);
}
nvgClosePath(s->vg);
nvgFillColor(s->vg, color);
@ -214,20 +206,12 @@ static void update_all_track_data(UIState *s) {
static void ui_draw_track(UIState *s, bool is_mpc, track_vertices_data *pvd) {
if (pvd->cnt == 0) return;
nvgBeginPath(s->vg);
bool started = false;
for(int i = 0;i < pvd->cnt;i++) {
float x = pvd->v[i].x;
float y = pvd->v[i].y;
if (x < 0 || y < 0) {
continue;
}
if (!started) {
nvgMoveTo(s->vg, x, y);
started = true;
} else {
nvgLineTo(s->vg, x, y);
}
nvgMoveTo(s->vg, pvd->v[0].x, pvd->v[0].y);
for (int i=1; i<pvd->cnt; i++) {
nvgLineTo(s->vg, pvd->v[i].x, pvd->v[i].y);
}
nvgClosePath(s->vg);

Loading…
Cancel
Save