Standardise dial needle radii
This commit is contained in:
parent
20efe78764
commit
6fe91aeccf
2 changed files with 25 additions and 21 deletions
|
@ -51,11 +51,7 @@ int hexagram_dial_draw_mark(hexagram_dial *dial,
|
|||
double max_radius,
|
||||
double value);
|
||||
|
||||
int hexagram_dial_draw_needle(hexagram_dial *dial,
|
||||
cairo_t *cr,
|
||||
double min_radius,
|
||||
double max_radius,
|
||||
double value);
|
||||
int hexagram_dial_draw_needle(hexagram_dial *dial, cairo_t *cr, double value);
|
||||
|
||||
int hexagram_dial_draw_bg(hexagram_dial *dial, cairo_t *cr);
|
||||
|
||||
|
|
40
src/dial.c
40
src/dial.c
|
@ -8,8 +8,17 @@
|
|||
|
||||
#define DIAL_MAIN_BEZEL_WIDTH 16
|
||||
|
||||
#define DIAL_LEGEND_RADIUS_MAIN 0.675
|
||||
#define DIAL_LEGEND_RADIUS_BOTTOM 0.725
|
||||
#define DIAL_RADIUS_LEGEND_MAIN 0.675
|
||||
#define DIAL_RADIUS_LEGEND_BOTTOM 0.725
|
||||
|
||||
#define DIAL_RADIUS_NEEDLE_MAIN_MIN 0.5
|
||||
#define DIAL_RADIUS_NEEDLE_MAIN_MAX 0.89
|
||||
|
||||
#define DIAL_RADIUS_NEEDLE_MAIN_MIN 0.5
|
||||
#define DIAL_RADIUS_NEEDLE_MAIN_MAX 0.89
|
||||
|
||||
#define DIAL_RADIUS_NEEDLE_BOTTOM_MIN 0.8
|
||||
#define DIAL_RADIUS_NEEDLE_BOTTOM_MAX 0.9
|
||||
|
||||
static inline double _min(double a, double b) {
|
||||
return a < b?
|
||||
|
@ -81,7 +90,6 @@ static int main_draw_bg(hexagram_gauge *gauge, cairo_t *cr) {
|
|||
|
||||
static int main_draw_fg(hexagram_gauge *gauge, cairo_t *cr) {
|
||||
hexagram_dial *dial = (hexagram_dial *)gauge;
|
||||
|
||||
double angle = hexagram_dial_angle(dial, dial->value);
|
||||
|
||||
cairo_set_line_width(cr, dial->radius * 0.375);
|
||||
|
@ -96,7 +104,7 @@ static int main_draw_fg(hexagram_gauge *gauge, cairo_t *cr) {
|
|||
|
||||
cairo_stroke(cr);
|
||||
|
||||
hexagram_dial_draw_needle(dial, cr, 0.5, 0.89, dial->value);
|
||||
hexagram_dial_draw_needle(dial, cr, dial->value);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -122,10 +130,7 @@ static int bottom_draw_bg(hexagram_gauge *gauge, cairo_t *cr) {
|
|||
static int bottom_draw_fg(hexagram_gauge *gauge, cairo_t *cr) {
|
||||
hexagram_dial *dial = (hexagram_dial *)gauge;
|
||||
|
||||
double min_radius = 0.8,
|
||||
max_radius = 0.9;
|
||||
|
||||
return hexagram_dial_draw_needle(dial, cr, min_radius, max_radius, dial->value);
|
||||
return hexagram_dial_draw_needle(dial, cr, dial->value);
|
||||
}
|
||||
|
||||
int hexagram_dial_init(hexagram_dial *dial,
|
||||
|
@ -206,8 +211,8 @@ int hexagram_dial_draw_legend(hexagram_dial *dial,
|
|||
cairo_text_extents_t extents;
|
||||
|
||||
double radius = dial->type == HEXAGRAM_DIAL_MAIN?
|
||||
DIAL_LEGEND_RADIUS_MAIN:
|
||||
DIAL_LEGEND_RADIUS_BOTTOM;
|
||||
DIAL_RADIUS_LEGEND_MAIN:
|
||||
DIAL_RADIUS_LEGEND_BOTTOM;
|
||||
|
||||
cairo_text_extents(cr, text, &extents);
|
||||
|
||||
|
@ -241,12 +246,15 @@ int hexagram_dial_draw_mark(hexagram_dial *dial,
|
|||
return 0;
|
||||
}
|
||||
|
||||
int hexagram_dial_draw_needle(hexagram_dial *dial,
|
||||
cairo_t *cr,
|
||||
double min_radius,
|
||||
double max_radius,
|
||||
double value) {
|
||||
double angle = hexagram_dial_angle(dial, value);
|
||||
int hexagram_dial_draw_needle(hexagram_dial *dial, cairo_t *cr, double value) {
|
||||
double angle = hexagram_dial_angle(dial, value),
|
||||
min_radius = DIAL_RADIUS_NEEDLE_MAIN_MIN,
|
||||
max_radius = DIAL_RADIUS_NEEDLE_MAIN_MAX;
|
||||
|
||||
if (dial->type == HEXAGRAM_DIAL_BOTTOM) {
|
||||
min_radius = DIAL_RADIUS_NEEDLE_BOTTOM_MIN;
|
||||
max_radius = DIAL_RADIUS_NEEDLE_BOTTOM_MAX;
|
||||
}
|
||||
|
||||
cairo_set_source_rgba(cr, 1, 0.4, 1, 0.75);
|
||||
cairo_set_line_width(cr, 8);
|
||||
|
|
Loading…
Add table
Reference in a new issue