Standardise dial mark radii
This commit is contained in:
parent
6fe91aeccf
commit
cc978ca13e
6 changed files with 37 additions and 18 deletions
|
@ -47,9 +47,8 @@ int hexagram_dial_draw_legend(hexagram_dial *dial,
|
||||||
|
|
||||||
int hexagram_dial_draw_mark(hexagram_dial *dial,
|
int hexagram_dial_draw_mark(hexagram_dial *dial,
|
||||||
cairo_t *cr,
|
cairo_t *cr,
|
||||||
double min_radius,
|
double value,
|
||||||
double max_radius,
|
int large);
|
||||||
double value);
|
|
||||||
|
|
||||||
int hexagram_dial_draw_needle(hexagram_dial *dial, cairo_t *cr, double value);
|
int hexagram_dial_draw_needle(hexagram_dial *dial, cairo_t *cr, double value);
|
||||||
|
|
||||||
|
|
27
src/dial.c
27
src/dial.c
|
@ -20,6 +20,14 @@
|
||||||
#define DIAL_RADIUS_NEEDLE_BOTTOM_MIN 0.8
|
#define DIAL_RADIUS_NEEDLE_BOTTOM_MIN 0.8
|
||||||
#define DIAL_RADIUS_NEEDLE_BOTTOM_MAX 0.9
|
#define DIAL_RADIUS_NEEDLE_BOTTOM_MAX 0.9
|
||||||
|
|
||||||
|
#define DIAL_RADIUS_MARK_MAIN_MIN 0.82
|
||||||
|
#define DIAL_RADIUS_MARK_MAIN_MIN_LARGE 0.80
|
||||||
|
#define DIAL_RADIUS_MARK_MAIN_MAX 0.87
|
||||||
|
|
||||||
|
#define DIAL_RADIUS_MARK_BOTTOM_MIN 0.84
|
||||||
|
#define DIAL_RADIUS_MARK_BOTTOM_MIN_LARGE 0.82
|
||||||
|
#define DIAL_RADIUS_MARK_BOTTOM_MAX 0.87
|
||||||
|
|
||||||
static inline double _min(double a, double b) {
|
static inline double _min(double a, double b) {
|
||||||
return a < b?
|
return a < b?
|
||||||
a: b;
|
a: b;
|
||||||
|
@ -228,10 +236,23 @@ int hexagram_dial_draw_legend(hexagram_dial *dial,
|
||||||
|
|
||||||
int hexagram_dial_draw_mark(hexagram_dial *dial,
|
int hexagram_dial_draw_mark(hexagram_dial *dial,
|
||||||
cairo_t *cr,
|
cairo_t *cr,
|
||||||
double min_radius,
|
double value,
|
||||||
double max_radius,
|
int large) {
|
||||||
double value) {
|
|
||||||
double angle = hexagram_dial_angle(dial, value);
|
double angle = hexagram_dial_angle(dial, value);
|
||||||
|
double min_radius,
|
||||||
|
max_radius;
|
||||||
|
|
||||||
|
if (dial->type == HEXAGRAM_DIAL_MAIN) {
|
||||||
|
min_radius = large? DIAL_RADIUS_MARK_MAIN_MIN_LARGE:
|
||||||
|
DIAL_RADIUS_MARK_MAIN_MIN;
|
||||||
|
|
||||||
|
max_radius = DIAL_RADIUS_MARK_MAIN_MAX;
|
||||||
|
} else {
|
||||||
|
min_radius = large? DIAL_RADIUS_MARK_BOTTOM_MIN_LARGE:
|
||||||
|
DIAL_RADIUS_MARK_BOTTOM_MIN;
|
||||||
|
|
||||||
|
max_radius = DIAL_RADIUS_MARK_BOTTOM_MAX;
|
||||||
|
}
|
||||||
|
|
||||||
cairo_move_to(cr,
|
cairo_move_to(cr,
|
||||||
dial->gauge.x + min_radius * dial->radius * cos(angle),
|
dial->gauge.x + min_radius * dial->radius * cos(angle),
|
||||||
|
|
|
@ -39,20 +39,19 @@ static int draw_bg(hexagram_gauge *gauge, cairo_t *cr) {
|
||||||
cairo_set_line_width(cr, 6.0);
|
cairo_set_line_width(cr, 6.0);
|
||||||
|
|
||||||
for (level=0; level<=LEVEL_MAX; level++) {
|
for (level=0; level<=LEVEL_MAX; level++) {
|
||||||
double min_radius;
|
int large = 0;
|
||||||
|
|
||||||
if (level < 2) {
|
if (level < 2) {
|
||||||
min_radius = 0.84;
|
|
||||||
cairo_set_source_rgb(cr, 1, 0, 0);
|
cairo_set_source_rgb(cr, 1, 0, 0);
|
||||||
} else if (level < 4) {
|
} else if (level < 4) {
|
||||||
min_radius = 0.82;
|
large = 1;
|
||||||
cairo_set_source_rgb(cr, 1, 0, 0);
|
cairo_set_source_rgb(cr, 1, 0, 0);
|
||||||
} else {
|
} else {
|
||||||
min_radius = 0.82;
|
large = 1;
|
||||||
cairo_set_source_rgb(cr, 1, 1, 1);
|
cairo_set_source_rgb(cr, 1, 1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
hexagram_dial_draw_mark(&fuel->dial, cr, min_radius, 0.87, level);
|
hexagram_dial_draw_mark(&fuel->dial, cr, level, large);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -54,10 +54,10 @@ static int draw_bg(hexagram_gauge *gauge, cairo_t *cr) {
|
||||||
cairo_set_source_rgb(cr, 1, 1, 1);
|
cairo_set_source_rgb(cr, 1, 1, 1);
|
||||||
|
|
||||||
for (speed=0; speed<=(int)speedo->dial.max_value; speed += 5) {
|
for (speed=0; speed<=(int)speedo->dial.max_value; speed += 5) {
|
||||||
double min_radius = speed % 10 == 0? 0.81: 0.82;
|
int large = speed % 10 == 0? 1: 0;
|
||||||
|
|
||||||
cairo_set_line_width(cr, speed % 10 == 0? 6.0: 2.0);
|
cairo_set_line_width(cr, large? 6.0: 2.0);
|
||||||
hexagram_dial_draw_mark(&speedo->dial, cr, min_radius, 0.87, (double)speed);
|
hexagram_dial_draw_mark(&speedo->dial, cr, (double)speed, large);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (speed=0; speed<=(int)speedo->dial.max_value; speed += 20) {
|
for (speed=0; speed<=(int)speedo->dial.max_value; speed += 20) {
|
||||||
|
|
|
@ -30,15 +30,15 @@ static int draw_bg(hexagram_gauge *gauge, cairo_t *cr) {
|
||||||
cairo_set_source_rgb(cr, 1, 1, 1);
|
cairo_set_source_rgb(cr, 1, 1, 1);
|
||||||
|
|
||||||
for (rpm=0; rpm<=(int)tacho->dial.max_value; rpm+=TACHO_INTERVAL_MARK) {
|
for (rpm=0; rpm<=(int)tacho->dial.max_value; rpm+=TACHO_INTERVAL_MARK) {
|
||||||
double min_radius = (rpm % TACHO_INTERVAL_LEGEND) == 0? 0.81: 0.82;
|
int large = (rpm % TACHO_INTERVAL_LEGEND) == 0? 1: 0;
|
||||||
|
|
||||||
if (rpm >= tacho->redline) {
|
if (rpm >= tacho->redline) {
|
||||||
cairo_set_source_rgb(cr, 0.6, 0.1, 0.1);
|
cairo_set_source_rgb(cr, 0.6, 0.1, 0.1);
|
||||||
}
|
}
|
||||||
|
|
||||||
cairo_set_line_width(cr, (rpm % TACHO_INTERVAL_LEGEND) == 0? 6.0: 2.0);
|
cairo_set_line_width(cr, large? 6.0: 2.0);
|
||||||
|
|
||||||
hexagram_dial_draw_mark(&tacho->dial, cr, min_radius, 0.87, rpm);
|
hexagram_dial_draw_mark(&tacho->dial, cr, rpm, large);
|
||||||
}
|
}
|
||||||
|
|
||||||
cairo_set_source_rgb(cr, 1, 1, 1);
|
cairo_set_source_rgb(cr, 1, 1, 1);
|
||||||
|
|
|
@ -49,7 +49,7 @@ static int draw_bg(hexagram_gauge *gauge, cairo_t *cr) {
|
||||||
cairo_set_source_rgb(cr, 1, 1, 1);
|
cairo_set_source_rgb(cr, 1, 1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
hexagram_dial_draw_mark(&thermo->dial, cr, 0.83, 0.87, level);
|
hexagram_dial_draw_mark(&thermo->dial, cr, level, 1);
|
||||||
|
|
||||||
level += incr;
|
level += incr;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue