Skip to content

Instantly share code, notes, and snippets.

@eklitzke
Created July 18, 2009 23:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eklitzke/149728 to your computer and use it in GitHub Desktop.
Save eklitzke/149728 to your computer and use it in GitHub Desktop.
this is the code in gnome-system-monitor that draws the curves
cr = gdk_cairo_create (g->disp->window);
cairo_set_line_width (cr, 1);
cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND);
cairo_rectangle (cr, g->rmargin + g->indent + FRAME_WIDTH + 1, FRAME_WIDTH - 1,
g->draw_width - g->rmargin - g->indent - 1, g->real_draw_height + FRAME_WIDTH - 1);
cairo_clip(cr);
for (j = 0; j < g->n; ++j) {
cairo_move_to (cr, x_offset, (1.0f - g->data[0][j]) * g->real_draw_height);
gdk_cairo_set_source_color (cr, &(g->colors [j]));
for (i = 1; i < LoadGraph::NUM_POINTS; ++i) {
if (g->data[i][j] == -1.0f)
continue;
cairo_curve_to (cr,
x_offset - ((i - 0.5f) * g->graph_delx),
(1.0f - g->data[i-1][j]) * g->real_draw_height + 3.5f,
x_offset - ((i - 0.5f) * g->graph_delx),
(1.0f - g->data[i][j]) * g->real_draw_height + 3.5f,
x_offset - (i * g->graph_delx),
(1.0f - g->data[i][j]) * g->real_draw_height + 3.5f);
}
cairo_stroke (cr);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment