Skip to content

Adding contrast to flyline delay text so it's readable now #1451

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 8, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion vpr/src/draw/draw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3229,7 +3229,30 @@ static void draw_flyline_timing_edge(ezgl::point2d start, ezgl::point2d end, flo
ss << 1e9 * incr_delay; //In nanoseconds
std::string incr_delay_str = ss.str();

g->draw_text(text_bbox.center(), incr_delay_str.c_str(), text_bbox.width(), text_bbox.height());
// Get the angle of line, to rotate the text
float text_angle = (180 / M_PI) * atan((end.y - start.y) / (end.x - start.x));

// Get the screen coordinates for text drawing
ezgl::rectangle screen_coords = g->world_to_screen(text_bbox);
g->set_text_rotation(text_angle);

// Set the text colour to black to differentiate it from the line
g->set_font_size(16);
g->set_color(ezgl::color(0, 0, 0));

g->set_coordinate_system(ezgl::SCREEN);

// Find an offset so it is sitting on top/below of the line
float x_offset = screen_coords.center().x - 8 * sin(text_angle * (M_PI / 180));
float y_offset = screen_coords.center().y - 8 * cos(text_angle * (M_PI / 180));

ezgl::point2d offset_text_bbox(x_offset, y_offset);
g->draw_text(offset_text_bbox, incr_delay_str.c_str(), text_bbox.width(), text_bbox.height());

g->set_font_size(14);

g->set_text_rotation(0);
g->set_coordinate_system(ezgl::WORLD);
}
}

Expand Down