mirror of
https://git.wetfence.xyz/RandyTheSilly/Civic-Segments.git
synced 2026-09-05 01:59:26 -04:00
Properly center bar fill in radial mg
This commit is contained in:
+12
-9
@@ -60,17 +60,18 @@ static int8_t s_temp_level;
|
||||
// bar statics
|
||||
#if PBL_RECT
|
||||
static const uint8_t s_bar_width = 17;
|
||||
static const uint8_t s_bar_height = 8; // pixels
|
||||
static const uint8_t s_bar_height = 8;
|
||||
static const uint8_t s_bar_spacing = s_bar_height + 1;
|
||||
#else
|
||||
static const uint8_t s_bar_width = 24;
|
||||
static const uint8_t s_bar_height = 3; // degrees
|
||||
static const uint16_t s_bar_height = DEG_TO_TRIGANGLE(3);
|
||||
static const uint16_t s_bar_spacing = DEG_TO_TRIGANGLE(4); // height (3) + 1
|
||||
static const uint8_t s_bar_deg_range = 40;
|
||||
static const uint16_t s_bar_fuel_deg_top = 90 - s_bar_deg_range;
|
||||
static const uint16_t s_bar_fuel_deg_bottom = 90 + s_bar_deg_range;
|
||||
static const uint16_t s_bar_temp_deg_top = 270 + s_bar_deg_range;
|
||||
static const uint16_t s_bar_temp_deg_bottom = 270 - s_bar_deg_range;
|
||||
#endif
|
||||
static const uint8_t s_bar_spacing = s_bar_height + 1;
|
||||
|
||||
// resource ID arrays for digit bitmaps
|
||||
static const uint32_t s_digit_resource_ids[10] = {RESOURCE_ID_0, RESOURCE_ID_1, RESOURCE_ID_2, RESOURCE_ID_3, RESOURCE_ID_4,
|
||||
@@ -155,10 +156,11 @@ static void temp_update_proc(Layer *layer, GContext *ctx) {
|
||||
graphics_context_set_fill_color(ctx, settings.ColorBarsFill);
|
||||
|
||||
const uint8_t bar_count = s_temp_level;
|
||||
uint16_t bar_bottom_deg = s_bar_temp_deg_bottom;
|
||||
static const uint8_t half_gap = (s_bar_spacing - s_bar_height) / 2;
|
||||
int32_t bar_bottom = DEG_TO_TRIGANGLE(s_bar_temp_deg_bottom) + half_gap;
|
||||
for (uint8_t i = 0; i < bar_count; ++i) {
|
||||
graphics_fill_radial(ctx, grect_inset(bounds, GEdgeInsets(7)), GOvalScaleModeFitCircle, s_bar_width - 2, DEG_TO_TRIGANGLE(bar_bottom_deg), DEG_TO_TRIGANGLE(bar_bottom_deg + s_bar_height));
|
||||
bar_bottom_deg += s_bar_spacing;
|
||||
graphics_fill_radial(ctx, grect_inset(bounds, GEdgeInsets(7)), GOvalScaleModeFitCircle, s_bar_width - 2, bar_bottom, bar_bottom + s_bar_height);
|
||||
bar_bottom += s_bar_spacing;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -178,10 +180,11 @@ static void fuel_update_proc(Layer *layer, GContext *ctx) {
|
||||
GRect bounds = layer_get_bounds(layer);
|
||||
graphics_context_set_fill_color(ctx, settings.ColorBarsFill);
|
||||
|
||||
uint16_t bar_bottom_deg = s_bar_fuel_deg_bottom;
|
||||
static const uint8_t half_gap = (s_bar_spacing - s_bar_height) / 2;
|
||||
int32_t bar_bottom = DEG_TO_TRIGANGLE(s_bar_fuel_deg_bottom) - half_gap;
|
||||
for (uint8_t i = 0; i < s_batt_level; ++i) {
|
||||
graphics_fill_radial(ctx, grect_inset(bounds, GEdgeInsets(7)), GOvalScaleModeFitCircle, s_bar_width - 2, DEG_TO_TRIGANGLE(bar_bottom_deg - s_bar_height), DEG_TO_TRIGANGLE(bar_bottom_deg));
|
||||
bar_bottom_deg -= s_bar_spacing;
|
||||
graphics_fill_radial(ctx, grect_inset(bounds, GEdgeInsets(7)), GOvalScaleModeFitCircle, s_bar_width - 2, bar_bottom - s_bar_height, bar_bottom);
|
||||
bar_bottom -= s_bar_spacing;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user