static void ring_layer_update(Layer *layer, GContext *ctx) { if (data_loaded) { const GRect entire_screen = GRect(0, 0, 180, 180); draw_circle(ctx, entire_screen, GColorWhite, 20, 360); graphics_context_set_stroke_color(ctx, GColorOxfordBlue); graphics_context_set_stroke_width(ctx, 10); const GRect time_orbit = GRect(10, 10, 160, 160); int degree_icon = degreeify(hour, minute); int degree_rise = degreeify(hour_rise, minute_rise); int degree_set = degreeify(hour_set, minute_set); GBitmap *icon = degree_icon >= degree_set && degree_icon <= degree_rise ? moon : sun; const GRect icon_space = grect_centered_from_polar( time_orbit, GOvalScaleModeFitCircle, DEG_TO_TRIGANGLE(degree_icon), GSize(18, 18) ); graphics_context_set_compositing_mode(ctx, GCompOpSet); graphics_draw_bitmap_in_rect(ctx, icon, icon_space); } }
static GRect prv_get_donut_rect(const GRect *layer_bounds, int32_t donut_angle) { const GRect donut_orbit_rect = prv_get_donut_orbit_rect(layer_bounds); GRect donut_rect = grect_centered_from_polar(donut_orbit_rect, GOvalScaleModeFitCircle, donut_angle, gbitmap_get_bounds(s_app_data->donut_bitmap).size); donut_rect.origin.y = (int16_t)prv_interpolate_int64_linear(0, donut_rect.origin.y, s_app_data->intro_animation_progress); return donut_rect; }
static void layer_update_proc(Layer *layer, GContext *ctx) { if (!should_update) { APP_LOG(APP_LOG_LEVEL_INFO, "Skipped update"); return; } GRect bounds = layer_get_bounds(layer); // Draw battery line graphics_context_set_stroke_color(ctx, s_charge_percent <= 30 ? GColorYellow : GColorRed); graphics_context_set_stroke_width(ctx, 3); int lineSegment = (bounds.size.w - 56) * 10/100; for (int i = 0; i < s_charge_percent / 10; i+=1) { graphics_draw_line(ctx, GPoint(28 + i * lineSegment, 120), GPoint(26 + (lineSegment * (i + 1)), 120)); } // Draw arcs for each STEP_DIVS GRect inset_bounds = grect_inset(bounds,GEdgeInsets(1,3,2,2)); graphics_context_set_fill_color(ctx, color_from_active_status(check_active_status())); // Get the sum steps so far today HealthValue steps = health_service_sum_today(HealthMetricStepCount); int lapSteps = steps%STEPS_LAP; int lapSectionAngle = 360 / (STEPS_LAP / STEP_DIVS); int subLapSectionAngle = lapSectionAngle / 10; for (int i = 0; lapSteps > (STEP_DIVS / 10); i++) { if ( lapSteps > STEP_DIVS ) { int32_t add_Degrees = lapSectionAngle - 2; graphics_fill_radial(ctx, inset_bounds, GOvalScaleModeFitCircle, 9, DEG_TO_TRIGANGLE(lapSectionAngle * i), DEG_TO_TRIGANGLE(lapSectionAngle * i + add_Degrees )); lapSteps -= STEP_DIVS; } else { for (int j = 0; lapSteps > (STEP_DIVS / 10); j++) { int32_t add_Degrees = subLapSectionAngle - 1; graphics_fill_radial(ctx, inset_bounds, GOvalScaleModeFitCircle, ((j == 4) ? 13 : 9 ), DEG_TO_TRIGANGLE(lapSectionAngle * i + subLapSectionAngle * j), DEG_TO_TRIGANGLE(lapSectionAngle * i + subLapSectionAngle * j + add_Degrees )); lapSteps -= STEP_DIVS / 10; } } } GRect double_inset = grect_inset(inset_bounds, GEdgeInsets(15)); graphics_context_set_fill_color(ctx, GColorWhite); if (steps < STEPS_LAP) { steps += 150; return; } // draw step lap dots for (int i = 0; i < steps/STEPS_LAP; i++) { GRect xywh = grect_centered_from_polar(double_inset, GOvalScaleModeFitCircle, DEG_TO_TRIGANGLE(6 * i), GSize(5,5)); graphics_fill_radial(ctx, xywh, GOvalScaleModeFitCircle, 5, 0, TRIG_MAX_ANGLE); } steps += 33; }
void prv_draw_pupil(GContext *ctx, const GRect *eye_rect, const GPoint *perimeter_point) { const int16_t pupil_radius = 3; const GSize pupil_size = GSize(pupil_radius * 2, pupil_radius * 2); const GRect pupil_container_rect = grect_inset((*eye_rect), GEdgeInsets(2 * pupil_radius)); const GPoint pupil_center = grect_center_point(&pupil_container_rect); const int32_t pupil_angle = atan2_lookup(perimeter_point->y - pupil_center.y, perimeter_point->x - pupil_center.x) + DEG_TO_TRIGANGLE(90); const GRect pupil_rect = grect_centered_from_polar(pupil_container_rect, GOvalScaleModeFitCircle, pupil_angle, pupil_size); graphics_fill_radial(ctx, pupil_rect, GOvalScaleModeFitCircle, pupil_radius, 0, TRIG_MAX_ANGLE); }