static void hands_update_proc(Layer *layer, GContext *hands_ctx) { time_t now = time(NULL); struct tm *t = localtime(&now); graphics_context_set_fill_color(hands_ctx, GColorDukeBlue); gpath_rotate_to(minute_arrow_path, TRIG_MAX_ANGLE * t->tm_min / 60); gpath_draw_filled(hands_ctx, minute_arrow_path); gpath_draw_outline(hands_ctx, minute_arrow_path); gpath_rotate_to(hour_arrow_path, (TRIG_MAX_ANGLE * (((t->tm_hour % 12) * 6) + (t->tm_min / 10))) / (12 * 6)); gpath_draw_filled(hands_ctx, hour_arrow_path); gpath_draw_outline(hands_ctx, hour_arrow_path); // dot in the middle GRect hands_bounds = layer_get_bounds(s_hands_layer); if (BTConnected == 1) { graphics_context_set_text_color(hands_ctx, GColorDukeBlue); graphics_context_set_fill_color(hands_ctx, GColorYellow); } else { graphics_context_set_text_color(hands_ctx, GColorWhite); graphics_context_set_fill_color(hands_ctx, GColorRed); } graphics_fill_circle(hands_ctx, GPoint(hands_bounds.size.w / 2, hands_bounds.size.h / 2), 13); #ifdef PBL_PLATFORM_BASALT graphics_draw_text(hands_ctx, day_text, fontRobotoCondensed19, GRect(61, 72, 24, 24), GTextOverflowModeWordWrap, GTextAlignmentCenter, NULL); #else // PEBBLE_PLATFORM_CHALK graphics_draw_text(hands_ctx, day_text, fontRobotoCondensed19, GRect(78, 78, 24, 24), GTextOverflowModeWordWrap, GTextAlignmentCenter, NULL); #endif }
static void update_triangle_proc(Layer *layer, GContext *ctx) { if(!s_spinning) { return; } // Move int32_t move_x = (int32_t)(sin_lookup(angle) * (RADIUS - 4) / TRIG_MAX_RATIO); int32_t move_y = (int32_t)(-cos_lookup(angle) * (RADIUS - 4) / TRIG_MAX_RATIO); gpath_move_to(s_spin_arrow_path, GPoint(s_spin_circle_center.x - move_x, s_spin_circle_center.y + move_y)); if(TESTING){ APP_LOG(APP_LOG_LEVEL_DEBUG, "move_x: %d", (int)move_x); APP_LOG(APP_LOG_LEVEL_DEBUG, "move_y: %d", (int)move_y); APP_LOG(APP_LOG_LEVEL_DEBUG, "angle: %d", (int)TRIGANGLE_TO_DEG(angle)); } // Rotate gpath_rotate_to(s_spin_triangle_path, -angle); gpath_rotate_to(s_spin_arrow_path, -angle); // Fill the path: graphics_context_set_fill_color(ctx, GColorBlack); gpath_draw_filled(ctx, s_spin_triangle_path); graphics_context_set_fill_color(ctx, GColorWhite); gpath_draw_filled(ctx, s_spin_arrow_path); }
static void hands_update_proc(Layer *layer, GContext *ctx) { GRect bounds = layer_get_bounds(layer); const GPoint center = grect_center_point(&bounds); const int16_t secondHandLength = bounds.size.w / 2; GPoint secondHand; time_t now = time(NULL); struct tm *t = localtime(&now); int32_t second_angle = TRIG_MAX_ANGLE * t->tm_sec / 60; secondHand.y = (int16_t)(-cos_lookup(second_angle) * (int32_t)secondHandLength / TRIG_MAX_RATIO) + center.y; secondHand.x = (int16_t)(sin_lookup(second_angle) * (int32_t)secondHandLength / TRIG_MAX_RATIO) + center.x; // second hand graphics_context_set_stroke_color(ctx, GColorWhite); graphics_draw_line(ctx, secondHand, center); // minute/hour hand graphics_context_set_fill_color(ctx, GColorWhite); graphics_context_set_stroke_color(ctx, GColorBlack); gpath_rotate_to(minute_arrow, TRIG_MAX_ANGLE * t->tm_min / 60); gpath_draw_filled(ctx, minute_arrow); gpath_draw_outline(ctx, minute_arrow); gpath_rotate_to(hour_arrow, (TRIG_MAX_ANGLE * (((t->tm_hour % 12) * 6) + (t->tm_min / 10))) / (12 * 6)); gpath_draw_filled(ctx, hour_arrow); gpath_draw_outline(ctx, hour_arrow); // dot in the middle graphics_context_set_fill_color(ctx, GColorBlack); graphics_fill_rect(ctx, GRect(bounds.size.w / 2 - 1, bounds.size.h / 2 - 1, 3, 3), 0, GCornerNone); }
void minute_display_layer_update_callback(Layer *me, GContext* ctx) { PblTm t; get_time(&t); unsigned int angle = t.tm_min * 6; unsigned int hr_angle = (t.tm_min / 5) *30; GPoint center = grect_center_point(&me->frame); // minute background white graphics_context_set_fill_color(ctx, GColorWhite); graphics_fill_circle(ctx, center, 72); // five minute sector black graphics_context_set_fill_color(ctx, GColorBlack); gpath_rotate_to(&minute5_segment_path, (TRIG_MAX_ANGLE / 360) * hr_angle); gpath_draw_filled(ctx, &minute5_segment_path); // minute sector white graphics_context_set_fill_color(ctx, GColorWhite); gpath_rotate_to(&minute_segment_path, (TRIG_MAX_ANGLE / 360) * angle); gpath_draw_filled(ctx, &minute_segment_path); // minute markers black graphics_context_set_stroke_color(ctx, GColorBlack); for (unsigned int i = 0; i < 360; i+=30) { gpath_rotate_to(&minute_marker_path, (TRIG_MAX_ANGLE / 360) * i); gpath_draw_outline(ctx, &minute_marker_path); } // black out outer ring graphics_context_set_stroke_color(ctx, GColorBlack); graphics_draw_circle(ctx, center, 73); graphics_draw_circle(ctx, center, 74); }
static void hands_update_proc(Layer* me, GContext* ctx) { const GPoint center = grect_center_point(&me->bounds); const int16_t secondHandLength = me->bounds.size.w / 2; GPoint secondHand; PblTm t; get_time(&t); int32_t second_angle = TRIG_MAX_ANGLE * t.tm_sec / 60; secondHand.y = (int16_t)(-cos_lookup(second_angle) * (int32_t)secondHandLength / TRIG_MAX_RATIO) + center.y; secondHand.x = (int16_t)(sin_lookup(second_angle) * (int32_t)secondHandLength / TRIG_MAX_RATIO) + center.x; // second hand graphics_context_set_stroke_color(ctx, GColorWhite); graphics_draw_line(ctx, secondHand, center); // minute/hour hand graphics_context_set_fill_color(ctx, GColorWhite); graphics_context_set_stroke_color(ctx, GColorBlack); gpath_rotate_to(&s_data.minute_arrow, TRIG_MAX_ANGLE * t.tm_min / 60); gpath_draw_filled(ctx, &s_data.minute_arrow); gpath_draw_outline(ctx, &s_data.minute_arrow); gpath_rotate_to(&s_data.hour_arrow, (TRIG_MAX_ANGLE * (((t.tm_hour % 12) * 6) + (t.tm_min / 10))) / (12 * 6)); gpath_draw_filled(ctx, &s_data.hour_arrow); gpath_draw_outline(ctx, &s_data.hour_arrow); // dot in the middle graphics_context_set_fill_color(ctx, GColorBlack); graphics_fill_rect(ctx, GRect(me->bounds.size.w / 2-1, me->bounds.size.h / 2-1, 3, 3), 0, GCornerNone); }
static void hands_layer_update_callback(Layer *layer, GContext* ctx) { GPoint center = GPoint(CENTER_X, CENTER_Y); // hours and minutes // int32_t hour_angle = TRIG_MAX_ANGLE * (now->tm_hour * 5 + now->tm_min / 12) / 60; int32_t hour_angle = (TRIG_MAX_ANGLE * (((hour % 12) * 6) + (min / 10))) / (12 * 6); int32_t min_angle = TRIG_MAX_ANGLE * min / 60; gpath_rotate_to(hour_path, hour_angle); gpath_rotate_to(hour_in_path, hour_angle); gpath_rotate_to(min_path, min_angle); graphics_context_set_fill_color(ctx, GColorWhite); graphics_context_set_stroke_color(ctx, GColorBlack); gpath_draw_filled(ctx, hour_path); gpath_draw_outline(ctx, hour_path); graphics_context_set_fill_color(ctx, GColorBlack); gpath_draw_filled(ctx, hour_in_path); graphics_context_set_fill_color(ctx, GColorWhite); graphics_draw_circle(ctx, center, DOTS_SIZE+4); gpath_draw_filled(ctx, min_path); gpath_draw_outline(ctx, min_path); graphics_fill_circle(ctx, center, DOTS_SIZE+3); // center dot graphics_context_set_fill_color(ctx, GColorBlack); graphics_fill_circle(ctx, center, DOTS_SIZE); }
// Draw the lizard by calling from the layer redraw proc void draw_lizard(GContext* ctx) { GPath *lizard_path = gpath_create(&lizard_points); GPath *bug_path = gpath_create(&bug_points); //gpath_rotate_to(lizard_path, TRIG_MAX_ANGLE / 360 * 20); gpath_move_to(lizard_path, GPoint(10, 0)); graphics_context_set_fill_color(ctx, GColorGreen); gpath_draw_filled(ctx, lizard_path); graphics_context_set_stroke_color(ctx, GColorBlack); gpath_draw_outline(ctx, lizard_path); graphics_context_set_fill_color(ctx, GColorBlack); gpath_draw_filled(ctx, bug_path); GPoint center = { .x = 41, .y = 59 }; graphics_fill_circle(ctx, center, 3); graphics_draw_circle(ctx, center, 8); graphics_draw_line(ctx, GPoint(6, 73), GPoint(16, 72)); graphics_context_set_text_color(ctx, GColorRed); graphics_draw_text(ctx, "Lizzy", fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD), GRect(0,120,144,140), GTextOverflowModeTrailingEllipsis, GTextAlignmentCenter, NULL); } // Only need to draw the lizard static void drawing_layer_update_callback(Layer *me, GContext *ctx) { draw_lizard(ctx); }
static void update_welcome_proc(Layer *layer, GContext *ctx){ // Fill the path: graphics_context_set_fill_color(ctx, GColorBlack); gpath_draw_filled(ctx, s_welcome_arrow_path); graphics_context_set_fill_color(ctx, GColorWhite); gpath_draw_filled(ctx, s_welcome_arrow_path); graphics_fill_rect(ctx, s_welcome_rect, 0, GCornerNone ); }
static void hand_layer_update( Layer * const me, GContext * ctx ) { ( void ) me; // Draw the hour hand outline in black and filled with white int hour_angle = ( ( now.tm_hour * 60 + now.tm_min ) * TRIG_MAX_ANGLE ) / ( 60 * 24 ); gpath_rotate_to(&hour_path, hour_angle); graphics_context_set_fill_color(ctx, GColorWhite); gpath_draw_filled(ctx, &hour_path); graphics_context_set_stroke_color(ctx, GColorBlack); gpath_draw_outline(ctx, &hour_path); // Draw the minute hand outline in black and filled with white int minute_angle = ( now.tm_min * TRIG_MAX_ANGLE ) / 60; gpath_rotate_to(&minute_path, minute_angle); graphics_context_set_fill_color(ctx, GColorWhite); gpath_draw_filled(ctx, &minute_path); graphics_context_set_stroke_color(ctx, GColorBlack); gpath_draw_outline(ctx, &minute_path); // Draw the second hand outline in black and filled with white int second_angle = ( now.tm_sec * TRIG_MAX_ANGLE ) / 60; gpath_rotate_to( &second_path, second_angle ); graphics_context_set_fill_color( ctx, GColorWhite ); gpath_draw_filled( ctx, &second_path ); graphics_context_set_stroke_color( ctx, GColorBlack ); gpath_draw_outline(ctx, &second_path); // Black circle over the hands. Looks nice. graphics_context_set_fill_color( ctx, GColorBlack ); graphics_fill_circle( ctx, GPoint( W / 2, H / 2 ), 30); // Put some date info in the center space. graphics_context_set_text_color( ctx, GColorWhite ); string_format_time( buffer, sizeof( buffer ), "%a", &now ); graphics_text_draw( ctx, buffer, font_date, GRect( W / 2 - 30, H / 2 - 30, 60, 24 ), GTextOverflowModeTrailingEllipsis, GTextAlignmentCenter, NULL ); string_format_time( buffer, sizeof( buffer ), "%m/%d", &now ); graphics_text_draw( ctx, buffer, font_date, GRect( W / 2 - 30 , H / 2 - 8, 60, 24 ), GTextOverflowModeTrailingEllipsis, GTextAlignmentCenter, NULL ); }
static void path_layer_update_callback(Layer *path, GContext *ctx) { gpath_draw_filled(ctx, s_needle_north);gpath_draw_filled(ctx, s_needle_north); // creating centerpoint GRect bounds = layer_get_frame(path); GPoint path_center = GPoint(bounds.size.w / 2, bounds.size.h / 2); graphics_fill_circle(ctx, path_center, 3); // then put a white circle on top graphics_context_set_fill_color(ctx, GColorWhite); graphics_fill_circle(ctx, path_center, 2); layer_mark_dirty(s_path_layer); }
static void analog_update_proc(Layer *layer, GContext *ctx) { time_t now = time(NULL); struct tm *t = localtime(&now); // Draw ticks behind draw_ticks(layer, ctx); // minute/hour hand graphics_context_set_compositing_mode(ctx, GCompOpSet); graphics_context_set_antialiased(ctx, true); gpath_rotate_to(minute_arrow, TRIG_MAX_ANGLE * t->tm_min / 60); gpath_rotate_to(minute_fill, TRIG_MAX_ANGLE * t->tm_min / 60); gpath_rotate_to(hour_arrow, (TRIG_MAX_ANGLE * (((t->tm_hour % 12) * 6) + (t->tm_min / 10)))/(12 * 6)); gpath_rotate_to(hour_fill, (TRIG_MAX_ANGLE * (((t->tm_hour % 12) * 6) + (t->tm_min / 10)))/(12 * 6)); // Draw minute hand background graphics_context_set_stroke_color(ctx, GColorBlack); graphics_context_set_stroke_width(ctx, 6); gpath_draw_outline(ctx, minute_arrow); // Draw minute hand foreground graphics_context_set_stroke_color(ctx, GColorWhite); graphics_context_set_fill_color(ctx, GColorWhite); graphics_context_set_stroke_width(ctx, 3); gpath_draw_outline(ctx, minute_arrow); gpath_draw_filled(ctx, minute_fill); // Draw hour hand background graphics_context_set_stroke_color(ctx, GColorBlack); graphics_context_set_stroke_width(ctx, 6); gpath_draw_outline(ctx, hour_arrow); // Draw hour hand foreground graphics_context_set_stroke_color(ctx, GColorWhite); graphics_context_set_fill_color(ctx, GColorWhite); graphics_context_set_stroke_width(ctx, 3); gpath_draw_outline(ctx, hour_arrow); gpath_draw_filled(ctx, hour_fill); // Draw a black peg in the center graphics_context_set_antialiased(ctx, false); graphics_context_set_fill_color(ctx, GColorBlack); graphics_context_set_stroke_color(ctx, GColorBlack); graphics_context_set_stroke_width(ctx, 1); gpath_draw_filled(ctx, peg_fill); }
void hour_display_layer_update_callback(Layer *me, GContext* ctx) { (void)me; PblTm t; get_time(&t); unsigned int angle = t.tm_hour * 30 + t.tm_min / 2; gpath_rotate_to(&hour_hand_path, (TRIG_MAX_ANGLE / 360) * angle); gpath_rotate_to(&hour_hand_outline_path, (TRIG_MAX_ANGLE / 360) * angle); graphics_context_set_fill_color(ctx, GColorWhite); gpath_draw_filled(ctx, &hour_hand_outline_path); gpath_draw_filled(ctx, &hour_hand_path); }
static void minute_display_layer_update_callback(Layer *layer, GContext* ctx) { time_t now = time(NULL); struct tm *t = localtime(&now); unsigned int angle = t->tm_min * 6; gpath_rotate_to(minute_segment_path, (TRIG_MAX_ANGLE / 360) * angle); GRect bounds = layer_get_bounds(layer); GPoint center = grect_center_point(&bounds); graphics_context_set_fill_color(ctx, GColorWhite); graphics_fill_circle(ctx, center, 77); graphics_context_set_fill_color(ctx, GColorBlack); // Note: I had intended to use the `GCompOpAssignInverted` mode here // but it appears it's ignored for path/shape drawing. gpath_draw_filled(ctx, minute_segment_path); graphics_fill_circle(ctx, center, 52); }
static void draw_graphics(Layer *layer, GContext *ctx) { GRect bounds = layer_get_bounds(layer); graphics_context_set_fill_color(ctx, GColorBlack); graphics_fill_rect(ctx, bounds, 0, GCornerNone); debugLayer = layer; debugCtx = ctx; graphics_context_set_stroke_color(ctx, GColorWhite); graphics_context_set_fill_color(ctx, GColorWhite); graphics_context_set_stroke_color(ctx, GColorWhite); int count =0; for (int screenFace = 0; screenFace < NR_FACES_CALCULATED; screenFace++) { for (int digits = 0; digits < NR_DIGITS_DEFINED ; digits++) { if (selectedDigits[count]) { gpath_draw_outline(ctx, calculatedFaceDigitPaths[screenFace][digits]); gpath_draw_filled(ctx, calculatedFaceDigitPaths[screenFace][digits]); } else { gpath_draw_outline(ctx, calculatedFaceDigitPaths[screenFace][digits]); } count++; } } }
static void hands_update_proc(Layer *layer, GContext *ctx) { GRect bounds = layer_get_bounds(layer); GPoint center = grect_center_point(&bounds); const int16_t second_hand_length = PBL_IF_ROUND_ELSE((bounds.size.w / 2) - 19, bounds.size.w / 2); time_t now = time(NULL); struct tm *t = localtime(&now); // minute/hour hand // 時 graphics_context_set_stroke_color(ctx, s_backColor); graphics_context_set_fill_color(ctx, s_hourHandColor); gpath_rotate_to(s_hour_arrow, (TRIG_MAX_ANGLE * (((t->tm_hour % 12) * 6) + (t->tm_min / 10))) / (12 * 6)); gpath_draw_filled(ctx, s_hour_arrow); // 分 graphics_context_set_fill_color(ctx, s_backColor); gpath_rotate_to(s_minute_arrow, (TRIG_MAX_ANGLE * (t->tm_min * 10 + (t->tm_sec/6)) / (60 * 10))); graphics_context_set_stroke_width(ctx, 2); graphics_context_set_stroke_color(ctx, s_minuteHandColor); gpath_draw_outline(ctx, s_minute_arrow); // 秒 int32_t second_angle = TRIG_MAX_ANGLE * t->tm_sec / 60; GPoint second_hand = { .x = (int16_t)(sin_lookup(second_angle) * (int32_t)second_hand_length / TRIG_MAX_RATIO) + center.x, .y = (int16_t)(-cos_lookup(second_angle) * (int32_t)second_hand_length / TRIG_MAX_RATIO) + center.y, }; if (s_show_seconds_hand){ // second hand graphics_context_set_stroke_width(ctx, 3); graphics_context_set_stroke_color(ctx, s_secondHandColor); graphics_draw_line(ctx, second_hand, center); graphics_context_set_stroke_width(ctx, 1); graphics_context_set_stroke_color(ctx, s_backColor); graphics_draw_line(ctx, second_hand, center); } // dot in the middle // 黒に設定 graphics_context_set_fill_color(ctx, s_backColor); // 円を塗り潰し graphics_fill_circle(ctx, center, 7); // 線の色を白に設定 graphics_context_set_stroke_color(ctx, s_secondHandColor); graphics_context_set_stroke_width(ctx, 1); graphics_draw_circle(ctx, center, 7); graphics_draw_circle(ctx, center, 1); } static void date_update_proc(Layer *layer, GContext *ctx) { time_t now = time(NULL); struct tm *t = localtime(&now); strftime(s_day_buffer, sizeof(s_day_buffer), "%a", t); text_layer_set_text(s_day_label, s_day_buffer); strftime(s_num_buffer, sizeof(s_num_buffer), "%d", t); text_layer_set_text(s_num_label, s_num_buffer); }
static void shape(GContext *ctx,uint16_t ang,int16_t ox,int16_t oy,int16_t mx,int16_t my,GPathInfo *gp,int func) { // draw 'shape' rotated to 'ang' and translated by 'ox' and 'oy' // use this instead of the library functions as they have shit precision GPoint *oldpoints=gp->points; gp->points=malloc(sizeof(GPoint)*gp->num_points); for(uint16_t i=0;i<gp->num_points;i++) { gp->points[i].x=((oldpoints[i].x*mx)>>FRACBITS)+ox; gp->points[i].y=((oldpoints[i].y*my)>>FRACBITS)+oy; rotate(ang,&gp->points[i]); gp->points[i].x=(gp->points[i].x>>FRACBITS)+CENTREX; gp->points[i].y=(gp->points[i].y>>FRACBITS)+CENTREY; } GPath *pptr=gpath_create(gp); switch(func) { case 0: // std filled in gpath_draw_outline(ctx,pptr); gpath_draw_filled(ctx,pptr); break; case 1: // open line draw #ifdef PBL_COLOR gpath_draw_outline_open(ctx,pptr); #else gpath_draw_outline(ctx,pptr); #endif break; } gpath_destroy(pptr); free(gp->points); gp->points=oldpoints; }
void layer_ring_update_callback(Layer *layer, GContext* ctx) { time_t tt = time(NULL); struct tm *t = localtime(&tt); unsigned int angle = 0; if (t->tm_min != 0) { angle = ( t->tm_min + 1 ) * 6; } GRect bounds = layer_get_bounds(layer); GPoint center = grect_center_point(&bounds); graphics_context_set_fill_color(ctx, s_color_ring_1); graphics_fill_circle(ctx, center, 73); graphics_context_set_fill_color(ctx, s_color_ring_2); for(; angle < 355; angle += 6) { gpath_rotate_to(s_path_ring_segment, (TRIG_MAX_ANGLE / 360) * angle); gpath_draw_filled(ctx, s_path_ring_segment); } graphics_context_set_stroke_color(ctx, s_color_bg_out); graphics_context_set_stroke_width(ctx, 4); graphics_draw_circle(ctx, center, 73); }
//added by gac and is probably wrong void month_display_layer_update_callback(Layer *me, GContext* ctx) { PblTm t; get_time(&t); unsigned int angle; //angle = (( t.tm_mon % 12 ) * 30) + (t.tm_mday / 2); angle = (( ( t.tm_mon + 1 ) % 12 ) * 30); angle = angle - (angle % 2); //use modulo 2 for smaller black overlaps GPoint center = grect_center_point(&me->frame); graphics_context_set_fill_color(ctx, GColorWhite); graphics_fill_circle(ctx, center, 25); graphics_context_set_fill_color(ctx, GColorBlack); for(; angle < 355; angle += 2) { //has to be same increment as the modulo in line 231 gpath_rotate_to(&month_segment_path, (TRIG_MAX_ANGLE / 360) * angle); gpath_draw_filled(ctx, &month_segment_path); } graphics_fill_circle(ctx, center, 20); }
static void hour_display_update_proc(Layer *layer, GContext* ctx) { time_t now = time(NULL); struct tm *t = localtime(&now); unsigned int angle = (t->tm_hour % 12) * 30; GRect bounds = layer_get_bounds(layer); GPoint center = grect_center_point(&bounds); graphics_context_set_fill_color(ctx, GColorWhite); graphics_fill_circle(ctx, center, 48); for (unsigned int i = 0; i < 360; i += 15) { if ((i != angle) && (i != (angle + 15)) && (i != ((angle - 15 + 360) % 360)) ) { gpath_rotate_to(s_hour_segment_path, (TRIG_MAX_ANGLE / 360) * i); graphics_context_set_fill_color(ctx, GColorBlack); gpath_draw_filled(ctx, s_hour_segment_path); } } // Stray pixels graphics_context_set_fill_color(ctx, GColorBlack); graphics_fill_circle(ctx, center, 5); graphics_context_set_stroke_color(ctx, GColorBlack); if ((angle != 0) && (angle != 330)) { graphics_draw_pixel(ctx, GPoint(71, 77)); graphics_draw_pixel(ctx, GPoint(71, 78)); } }
void second_display_layer_update_callback(Layer *me, GContext* ctx) { PblTm t; get_time(&t); unsigned int angle = t.tm_sec * 6; GPoint center = grect_center_point(&me->frame); graphics_context_set_fill_color(ctx, GColorWhite); graphics_fill_circle(ctx, center, 65); graphics_context_set_fill_color(ctx, GColorBlack); for(; angle < 355; angle += 6) { gpath_rotate_to(&second_segment_path, (TRIG_MAX_ANGLE / 360) * angle); gpath_draw_filled(ctx, &second_segment_path); } graphics_fill_circle(ctx, center, 60); }
static void fill_wedge(GContext *ctx, GPath *wedge, GColor color) { graphics_context_set_fill_color(ctx, color); graphics_context_set_stroke_color(ctx, color); graphics_context_set_stroke_width(ctx, 2); gpath_draw_filled(ctx, wedge); gpath_draw_outline(ctx, wedge); }
static void layer1_update_proc(Layer *layer, GContext *ctx) { // Set the color using RGB values graphics_context_set_fill_color(ctx, GColorWhite); // Draw the filled shape in above color gpath_draw_filled(ctx, s_path1); }
static void windshield_proc(Layer *layer, GContext *ctx) { // fill it first graphics_context_set_fill_color(ctx, jeep_color); gpath_draw_filled(ctx,s_windshield_path); // now stroke it graphics_context_set_stroke_width(ctx, 1); graphics_context_set_stroke_color(ctx, GColorBlack); gpath_draw_outline(ctx, s_windshield_path); // glass graphics_context_set_fill_color(ctx, GColorBlack); graphics_fill_rect(ctx, GRect(4, 4, 136, 50), 3, GCornersAll); graphics_context_set_fill_color(ctx, background_color); graphics_fill_rect(ctx, GRect(5, 5, 134, 48), 3, GCornersAll); // forest // graphics_context_set_compositing_mode(ctx, GCompOpSet); // graphics_draw_bitmap_in_rect(ctx, s_forest_image, GRect( 6, 6, 132, 46)); // logo graphics_context_set_compositing_mode(ctx, GCompOpSet); graphics_draw_bitmap_in_rect(ctx, s_logo_image, GRect( 14, 6, 117, 46)); }
void minute_display_layer_update_callback(Layer *me, GContext* ctx) { (void) me; time_t now = time(NULL); struct tm *t = localtime(&now); unsigned int angle = t->tm_min * 6 + t->tm_sec / 10; if (init_anim < ANIM_MINUTES) { angle = 0; } else if (init_anim == ANIM_MINUTES) { minute_angle_anim += 6; if (minute_angle_anim >= angle) { init_anim = ANIM_SECONDS; } else { angle = minute_angle_anim; } } gpath_rotate_to(minute_hand_path, (TRIG_MAX_ANGLE / 360) * angle); graphics_context_set_fill_color(ctx, GColorWhite); graphics_context_set_stroke_color(ctx, GColorBlack); gpath_draw_filled(ctx, minute_hand_path); gpath_draw_outline(ctx, minute_hand_path); }
void hour_display_layer_update_callback(Layer *me, GContext* ctx) { (void) me; time_t now = time(NULL); struct tm *t = localtime(&now); unsigned int angle = t->tm_hour * 30 + t->tm_min / 2; if (init_anim < ANIM_HOURS) { angle = 0; } else if (init_anim == ANIM_HOURS) { if (hour_angle_anim == 0 && t->tm_hour >= 12) { hour_angle_anim = 360; } hour_angle_anim += 6; if (hour_angle_anim >= angle) { init_anim = ANIM_MINUTES; } else { angle = hour_angle_anim; } } gpath_rotate_to(hour_hand_path, (TRIG_MAX_ANGLE / 360) * angle); graphics_context_set_fill_color(ctx, GColorWhite); graphics_context_set_stroke_color(ctx, GColorBlack); gpath_draw_filled(ctx, hour_hand_path); gpath_draw_outline(ctx, hour_hand_path); }
void hour_display_layer_update_callback(Layer *me, GContext* ctx) { PblTm t; get_time(&t); unsigned int angle = (t.tm_hour % 12) * 30; GPoint center = grect_center_point(&me->frame); // hour background black graphics_context_set_fill_color(ctx, GColorBlack); graphics_fill_circle(ctx, center, 52); // hour sector white graphics_context_set_fill_color(ctx, GColorWhite); gpath_rotate_to(&hour_segment_path, (TRIG_MAX_ANGLE / 360) * angle); gpath_draw_filled(ctx, &hour_segment_path); // rounding hour "sector" graphics_context_set_stroke_color(ctx, GColorBlack); graphics_draw_circle(ctx, center, 50); graphics_draw_circle(ctx, center, 49); graphics_draw_circle(ctx, center, 48); graphics_draw_circle(ctx, center, 47); /* graphics_context_set_fill_color(ctx, GColorBlack); graphics_fill_circle(ctx, center, 25); */ }
void hour_display_layer_update_callback(Layer *me, GContext* ctx) { PblTm t; get_time(&t); unsigned int angle; #if TWENTY_FOUR_HOUR_DIAL angle = (t.tm_hour * 15) + (t.tm_min / 4); #else angle = (( t.tm_hour % 12 ) * 30) + (t.tm_min / 2); #endif angle = angle - (angle % 6); GPoint center = grect_center_point(&me->frame); graphics_context_set_fill_color(ctx, GColorWhite); graphics_fill_circle(ctx, center, 45); graphics_context_set_fill_color(ctx, GColorBlack); for(; angle < 355; angle += 6) { gpath_rotate_to(&hour_segment_path, (TRIG_MAX_ANGLE / 360) * angle); gpath_draw_filled(ctx, &hour_segment_path); } graphics_fill_circle(ctx, center, 40); }
// Draws a given hand on the face, using the vector structures. void draw_vector_hand(struct VectorHandTable *hand, int hand_index, int num_steps, int place_x, int place_y, GContext *ctx) { GPoint center = { place_x, place_y }; int32_t angle = TRIG_MAX_ANGLE * hand_index / num_steps; int gi; for (gi = 0; gi < hand->num_groups; ++gi) { struct VectorHandGroup *group = &hand->group[gi]; GPath path; gpath_init(&path, &group->path_info); gpath_rotate_to(&path, angle); gpath_move_to(&path, center); if (group->fill != GColorClear) { graphics_context_set_fill_color(ctx, group->fill); gpath_draw_filled(ctx, &path); } if (group->outline != GColorClear) { graphics_context_set_stroke_color(ctx, group->outline); gpath_draw_outline(ctx, &path); } } }
// Draw the gray cover over part of the progress ring static void prv_draw_progress_ring(GContext *ctx, GSize window_size, uint32_t angle) { graphics_context_set_fill_color(ctx, COLOR_BACKGROUND); // get step angle and exit if too small int32_t step = angle / 4; if (step < 1) { return; } // get properties GPoint center = GPoint(window_size.w / 2, window_size.h / 2); uint16_t radius = window_size.h + window_size.w / 2; // calculate points around outside of window to draw cover GPoint points[8]; int8_t idx = 0; for (uint32_t t_angle = 0; t_angle < angle; t_angle += step){ points[idx++] = prv_polar_to_rectangular(center, t_angle, radius); } // add point at hand position, and in center (to form pie wedge) points[idx++] = prv_polar_to_rectangular(center, angle, radius); points[idx++] = center; // fill the covering GPathInfo info = (GPathInfo) { .num_points = idx, .points = points }; GPath *path = gpath_create(&info); gpath_draw_filled(ctx, path); gpath_destroy(path); }
/** * Redraw handler for the minute layer * Draws the minute dial */ static void minute_layer_draw(Layer *layer, GContext *ctx) { // rotate the black quadrant that we use to mask the white circle gpath_rotate_to(minute_path, (TRIG_MAX_ANGLE * minutes / 60)); gpath_move_to(minute_path, GPoint(144/2,168/2)); graphics_context_set_fill_color(ctx, GColorBlack); gpath_draw_filled(ctx, minute_path); // draw the other overlays if(minutes < 45){ // hide the last quadrant (45-60) graphics_context_set_fill_color(ctx, GColorBlack); graphics_fill_rect(ctx, GRect(0,0,144/2,168/2), 0, 0); } if(minutes < 30) { // hide third quadrant (30-45) graphics_context_set_fill_color(ctx, GColorBlack); graphics_fill_rect(ctx, GRect(0,168/2,144/2,168/2), 0, 0); } if(minutes <= 15) { // hide second quadrant (15-30) graphics_context_set_fill_color(ctx, GColorBlack); graphics_fill_rect(ctx, GRect(144/2,168/2,144/2,168/2), 0, 0); } }