*to an invisible waiter* Ah, yes, thank you, Inviso-Jeeves.

This commit is contained in:
XANTRONIX Development 2019-06-07 19:59:38 -05:00
parent be52bdc014
commit 67b0a4ea95

View file

@ -235,14 +235,15 @@ static void draw_speedometer_needle(cairo_t *cr,
static void draw_thermometer(cairo_t *cr, static void draw_thermometer(cairo_t *cr,
double x, double x,
double y, double y,
double r) { double r,
double redline) {
int i; int i;
cairo_select_font_face(cr, "Helvetica", cairo_select_font_face(cr, "Helvetica",
CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_SLANT_NORMAL,
CAIRO_FONT_WEIGHT_NORMAL); CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size(cr, r * 0.15); cairo_set_font_size(cr, r * 0.2);
cairo_set_source_rgb(cr, 1, 1, 1); cairo_set_source_rgb(cr, 1, 1, 1);
cairo_arc(cr, x, y, r, 0, 2*M_PI); cairo_arc(cr, x, y, r, 0, 2*M_PI);
@ -251,17 +252,38 @@ static void draw_thermometer(cairo_t *cr,
/* /*
* Draw face numbers * Draw face numbers
*/ */
for (i=120; i<=260; i+=70) { cairo_move_to(cr, x - 0.8 * r, y - 0.1 * r);
char text[5]; cairo_show_text(cr, "120");
snprintf(text, 4, "%02d", i); cairo_move_to(cr, x - 0.15 * r, y - 0.5 * r);
cairo_show_text(cr, "190");
draw_face_number(cr, x, y, cairo_move_to(cr, x + 0.5 * r, y - 0.1 * r);
0.75 * r, cairo_show_text(cr, "260");
/*
* Draw gauge graduations
*/
for (i=0; i<=140; i+=7) {
if (i + 120 >= redline) {
cairo_set_source_rgb(cr, 1, 0, 0);
}
if (i % 35 == 0) {
draw_face_mark(cr, x, y,
0.70 * r,
0.90 * r,
300 * (M_PI/180), 300 * (M_PI/180),
420 * (M_PI/180), 420 * (M_PI/180),
(i - 120.0) / 140.0, i / 140.0);
text); } else {
draw_face_mark(cr, x, y,
0.80 * r,
0.90 * r,
300 * (M_PI/180),
420 * (M_PI/180),
i / 140.0);
}
} }
} }
@ -281,7 +303,7 @@ static void draw_thermometer_needle(cairo_t *cr,
cairo_arc(cr, x, y, 0.08 * r, 0, 2*M_PI); cairo_arc(cr, x, y, 0.08 * r, 0, 2*M_PI);
cairo_stroke(cr); cairo_stroke(cr);
draw_needle(cr, x, y, 0.8 * r, draw_needle(cr, x, y, 0.9 * r,
300 * (M_PI/180), 300 * (M_PI/180),
420 * (M_PI/180), 420 * (M_PI/180),
temp / 260); temp / 260);
@ -291,6 +313,8 @@ static void draw_fuel_gauge(cairo_t *cr,
double x, double x,
double y, double y,
double r) { double r) {
cairo_set_source_rgb(cr, 1, 1, 1);
cairo_arc(cr, x, y, r, 0, 2*M_PI); cairo_arc(cr, x, y, r, 0, 2*M_PI);
cairo_stroke(cr); cairo_stroke(cr);
@ -332,7 +356,7 @@ static void draw_fuel_gauge_needle(cairo_t *cr,
cairo_arc(cr, x, y, 0.08 * r, 0, 2*M_PI); cairo_arc(cr, x, y, 0.08 * r, 0, 2*M_PI);
cairo_stroke(cr); cairo_stroke(cr);
draw_needle(cr, x, y, 0.8 * r, draw_needle(cr, x, y, 0.7 * r,
300 * (M_PI/180), 300 * (M_PI/180),
420 * (M_PI/180), 420 * (M_PI/180),
level / 1.0); level / 1.0);
@ -383,7 +407,8 @@ static void cluster_draw_bg(cairo_t *cr,
draw_thermometer(cr, draw_thermometer(cr,
width * 0.43, width * 0.43,
height * 0.76, height * 0.76,
height * 0.13); height * 0.13,
240.0);
draw_fuel_gauge(cr, draw_fuel_gauge(cr,
width * 0.57, width * 0.57,
@ -446,13 +471,13 @@ static void cluster_draw(cairo_t *cr,
draw_thermometer_needle(cr, draw_thermometer_needle(cr,
width * 0.43, width * 0.43,
height * 0.76, height * 0.76,
height * 0.11, height * 0.13,
state.temp); state.temp);
draw_fuel_gauge_needle(cr, draw_fuel_gauge_needle(cr,
width * 0.57, width * 0.57,
height * 0.76, height * 0.76,
height * 0.11, height * 0.13,
state.fuel); state.fuel);
} }
@ -558,7 +583,7 @@ int main(int argc, char **argv) {
break; break;
default: default:
fprintf(stderr, "Dropping unhandled XEvent.type = %d.\n", e.type); break;
} }
} }