#include #include #include #include void hexagram_tacho_init(hexagram_tacho *tacho, double x, double y, double radius, double redline) { hexagram_gauge_init(&tacho->gauge, x, y, radius, 232.0 * (M_PI / 180.0), 488.0 * (M_PI / 180.0)); tacho->redline = redline; } void hexagram_tacho_draw_face(hexagram_tacho *tacho, cairo_t *cr) { int i; cairo_select_font_face(cr, "Helvetica", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL); cairo_set_font_size(cr, tacho->gauge.radius * 0.125); cairo_set_source_rgb(cr, 1, 1, 1); cairo_arc(cr, tacho->gauge.x, tacho->gauge.y, tacho->gauge.radius, 0, 2.0 * M_PI); cairo_stroke(cr); /* * Draw face numbers */ for (i=0; i<=80; i+=10) { char text[4]; snprintf(text, 3, "%02d", i); hexagram_gauge_draw_number(&tacho->gauge, cr, 0.85, i / 80.0, text); } for (i=0; i<=80; i++) { if (i * 100 >= tacho->redline) { cairo_set_source_rgb(cr, 1, 0, 0); } hexagram_gauge_draw_mark(&tacho->gauge, cr, i % 5? 0.75: 0.7, 0.8, i / 80.0); } } void hexagram_tacho_draw_needle(hexagram_tacho *tacho, cairo_t *cr, double rpm) { if (rpm > 8000) { rpm = 8000; } hexagram_gauge_draw_needle(&tacho->gauge, cr, 0.8, rpm / 8000); }