1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-19 16:45:08 +00:00

ProcessManager: Draw the graphs as lines.

This looks pretty neat. Also it exercises the diagonal line drawing code
so we get 2-for-1. :^)
This commit is contained in:
Andreas Kling 2019-05-07 17:11:48 +02:00
parent 5b2e122624
commit 1598a0a5cb
2 changed files with 9 additions and 4 deletions

View file

@ -30,12 +30,16 @@ void GraphWidget::paint_event(GPaintEvent& event)
auto inner_rect = frame_inner_rect();
float scale = (float)inner_rect.height() / (float)m_max;
Point prev_point;
for (int i = 0; i < m_values.size(); ++i) {
int x = inner_rect.right() - i + 1;
int x = inner_rect.right() - (i * 2) + 1;
if (x < 0)
break;
float scaled_value = (float)m_values.at(m_values.size() - i) * scale;
painter.draw_line({ x, inner_rect.bottom() }, { x, inner_rect.bottom() - (int)scaled_value }, m_graph_color);
float scaled_value = (float)m_values.at(m_values.size() - i - 1) * scale;
Point point = { x, inner_rect.bottom() - (int)scaled_value };
if (i != 0)
painter.draw_line(prev_point, point, m_graph_color);
prev_point = point;
}
if (!m_values.is_empty() && text_formatter) {