mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-07-06 22:22:11 +08:00
paint.cc: Simplify drawing line (#1643)
* simplify drawing line * remove space old-commit-hash: ff4f432f0fd2ca5cf592082914e3a3a7b091a3db
This commit is contained in:
+10
-26
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user