Пример #1
0
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);	
*/
}
Пример #2
0
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); 	
}
Пример #3
0
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);
}
Пример #4
0
// Layer representing the pet pebble
void draw_pet_pebble(Layer *layer, GContext *ctx) {
  PetPebbleState pet_state = current_pet_state();
  
  GPoint BODY_CENTER = GPoint(90, 120);
  int EYES_HEIGHT = 115;
  int EYE_LEFT_CENTER = 80;
  int EYE_RIGHT_CENTER = 100;
  uint16_t radius = 30;
  
  // Draw the pet pebble body
  graphics_context_set_stroke_color(ctx, GColorCobaltBlue);
  graphics_context_set_fill_color(ctx, GColorCyan);
  graphics_context_set_stroke_width(ctx, 5);
  graphics_draw_circle(ctx, BODY_CENTER, radius);
  graphics_fill_circle(ctx, BODY_CENTER, radius);
  
  // Draw the pet pebble eyes
  graphics_context_set_stroke_color(ctx, GColorBlack);
  graphics_context_set_fill_color(ctx, GColorBlack);
  graphics_context_set_stroke_width(ctx, 2);
  radius = 2;
  
  if (pet_state == SLEEPING) {
    graphics_draw_line(ctx,
      GPoint(EYE_LEFT_CENTER-5, EYES_HEIGHT),
      GPoint(EYE_LEFT_CENTER+5, EYES_HEIGHT));
    graphics_draw_line(ctx, 
      GPoint(EYE_RIGHT_CENTER-5, EYES_HEIGHT), 
      GPoint(EYE_RIGHT_CENTER+5, EYES_HEIGHT));
  } else {
    graphics_draw_circle(
      ctx, GPoint(EYE_LEFT_CENTER, EYES_HEIGHT),radius);
    graphics_draw_circle(
      ctx, GPoint(EYE_RIGHT_CENTER, EYES_HEIGHT), radius);    
  }
  
  // Draw the pet pebble mouth
  if (pet_state == SLEEPING) {
    graphics_draw_circle(ctx, 
      GPoint((EYE_LEFT_CENTER+EYE_RIGHT_CENTER)/2, EYES_HEIGHT+13), 5);
    // Draw "Zzzz" to show that the pet pebble is asleep
    graphics_draw_text(ctx, "Zzzz", 
      fonts_get_system_font(FONT_KEY_ROBOTO_CONDENSED_21),
      GRect(EYE_RIGHT_CENTER+20, EYES_HEIGHT-40, EYE_RIGHT_CENTER+60, EYES_HEIGHT-20),
      GTextOverflowModeTrailingEllipsis, GTextAlignmentLeft, NULL);
  } else {
    GRect rect_bounds = GRect(EYE_LEFT_CENTER, 
      EYES_HEIGHT+10, EYE_RIGHT_CENTER-EYE_LEFT_CENTER, 5);    
    int32_t angle_start = DEG_TO_TRIGANGLE(85);
    int32_t angle_end = DEG_TO_TRIGANGLE(275);
    graphics_draw_arc(ctx, rect_bounds,
      GOvalScaleModeFillCircle, angle_start, angle_end);
  }
}
Пример #5
0
void draw_round_bar(GContext *ctx, GPoint l_p, GPoint r_p, int height) {
	
	graphics_fill_circle(ctx, l_p, height/2);
	graphics_draw_circle(ctx, l_p, height/2);
	
	graphics_fill_circle(ctx, r_p, height/2);
	graphics_draw_circle(ctx, r_p, height/2);
	
	GRect bar = {
		.origin = {l_p.x, 0},
		.size = {r_p.x - l_p.x, height}
	};
Пример #6
0
static void canvas_update_proc(Layer *layer, GContext *ctx) {
  // Custom drawing happens here!
  
  Layer *window_layer = window_get_root_layer(s_main_window);
  GRect bounds = layer_get_bounds(window_layer);
  
  int x,y;
  int left=bounds.size.w/10+2;
  int right=bounds.size.w-left;
  int adjusted_steps=steps/(target_steps/5);
  uint16_t radius = bounds.size.w/8;
  
  if(adjusted_steps>4) adjusted_steps=4;
  
  printf("adj steps %d", adjusted_steps);
  
  y=bounds.size.h/2;
  x=left;
  GPoint center = GPoint(x, y);
  
  graphics_context_set_stroke_width(ctx, 2);
  graphics_context_set_stroke_color(ctx, GColorInchworm);  
  graphics_draw_circle(ctx, center, radius);
  // Draw the outline of a circle
  for(int i=0;i<adjusted_steps;i++)
  {
    x=x+((right-left)/6);
    center = GPoint(x, y);
    graphics_draw_circle(ctx, center, radius);
  }
  
  // Fill a circle
  GPoint p1 = GPoint(center.x-radius, center.y-radius+4);  
  GPoint p2 = GPoint(center.x+radius, center.y-radius+4);  
  graphics_context_set_fill_color(ctx, GColorInchworm);
  graphics_fill_circle(ctx, center, radius);
  
  graphics_context_set_stroke_color(ctx, GColorBlack);  
  graphics_context_set_stroke_width(ctx, 1);
  graphics_context_set_fill_color(ctx, GColorBlack);
  
  for(int i=0;i<2*radius;i+=4)
  {
    p1.y=center.y-radius+i;
    p2.y=center.y-radius+i;
    graphics_draw_line(ctx, p1, p2);
  }
  radius=radius/4;
  
  graphics_fill_circle(ctx, center, radius);

  
}
// 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);
}
Пример #8
0
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);
}
Пример #9
0
static void canvas_update_proc(Layer *layer, GContext *ctx) {
  // Custom drawing happens here!
  
  Layer *window_layer = window_get_root_layer(s_main_window);
  GRect bounds = layer_get_bounds(window_layer);
  
  int x,y;
  int midpoint_x=bounds.size.w/2;
  int midpoint_y=bounds.size.h/2;
  int adjusted_minutes=90-minutes*6;
  x=midpoint_x+cos(3.14*adjusted_minutes/180)*(3*midpoint_x/5);
  y=midpoint_y-sin(3.14*adjusted_minutes/180)*(3*midpoint_y/5);
  GPoint center = GPoint(x, y);
  uint16_t radius = midpoint_x/4;

  // Draw the outline of a circle
  graphics_context_set_stroke_color(ctx, GColorCadetBlue);
  graphics_draw_circle(ctx, center, radius);

  // Fill a circle
  graphics_context_set_fill_color(ctx, GColorCadetBlue);
  graphics_fill_circle(ctx, center, radius);
  
  radius=radius/4;
  center = GPoint(x-6, y-6);
  graphics_context_set_fill_color(ctx, GColorCeleste);
  graphics_fill_circle(ctx, center, radius);
  

}
Пример #10
0
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);
}
Пример #11
0
// Draw the vertically stacked spots that indicate how many devices there are and which one is selected
static void spots_draw(Layer *layer, GContext *ctx) {
  GRect rect = layer_get_frame(layer);
  graphics_context_set_stroke_color(ctx, GColorWhite);
  graphics_context_set_fill_color(ctx, GColorWhite);
  
  for (int y = 0; y < g_device_count; y++) {
#ifdef PBL_ROUND
    GPoint spot = gpoint_from_polar(GRect(rect.origin.x+((rect.size.w-DEV_LAYER_WIDTH)/4),
                                          rect.origin.y+((rect.size.h-DEV_LAYER_HEIGHT)/4),
                                          rect.size.w-((rect.size.w-DEV_LAYER_WIDTH)/2),
                                          rect.size.h-((rect.size.h-DEV_LAYER_HEIGHT)/2)), GOvalScaleModeFitCircle, 
                                   DEG_TO_TRIGANGLE(270+
                                      ((((SPOT_RADIUS*2)*g_device_count)+(SPOT_SPACING*(g_device_count-1)))/2) -
                                       (y*((SPOT_RADIUS*2)+SPOT_SPACING)+3)));
#else
    GPoint spot = GPoint((rect.size.w/2),
                                     (rect.size.h/2)-((((SPOT_RADIUS*2)*g_device_count)+(SPOT_SPACING*(g_device_count-1)))/2) +
                                     (y*((SPOT_RADIUS*2)+SPOT_SPACING)+3));
#endif
    if (g_device_selected == y)
      graphics_fill_circle(ctx, spot, SPOT_RADIUS);
    else
      graphics_draw_circle(ctx, spot, SPOT_RADIUS);
  }
}
Пример #12
0
// ------------------------------------------------------------------------ //
//  Drawing Functions
// ------------------------------------------------------------------------ //
static void graphics_layer_update(Layer *me, GContext *ctx) {
    static char text[100];  //Buffer to hold text

    // Draw text box
    GRect textframe = GRect(25-2, 28+2, 90+4, 27+2);  // Text Box Position and Size: x, y, w, h
    graphics_context_set_fill_color(ctx, GColorBlack);
    graphics_fill_rect(ctx, textframe, 0, GCornerNone);  //Black Filled Rectangle
    graphics_context_set_stroke_color(ctx, GColorWhite);
    graphics_draw_rect(ctx, textframe);                //White Rectangle Border

    // Fill it with text
    textframe = GRect(25, 28, 90, 27);  // Text Box Position and Size: x, y, w, h
    graphics_draw_text(ctx, "Strength:\nTime:", fonts_get_system_font(FONT_KEY_GOTHIC_14), textframe, GTextOverflowModeWordWrap, GTextAlignmentLeft, NULL);  //Write Text
    snprintf(text, sizeof(text), "%d\n%ld", tap.strength, (long)(tap.timestamp&0x7FFFFFFF));  // What text to draw
    graphics_draw_text(ctx, text, fonts_get_system_font(FONT_KEY_GOTHIC_14), textframe, GTextOverflowModeWordWrap, GTextAlignmentRight, NULL);  //Write Text

    // Draw Plus and Tap Circle
    graphics_context_set_stroke_color(ctx, GColorWhite); // Line Color
    graphics_draw_line(ctx, GPoint(cursor.x-10, cursor.y), GPoint(cursor.x+10, cursor.y));
    graphics_draw_line(ctx, GPoint(cursor.x, cursor.y-10), GPoint(cursor.x, cursor.y+10));
    //graphics_draw_circle(ctx, GPoint(tap.x, tap.y), tap.length);  // Draw the tap (commented out since now we draw the 8 previous taps below)
    for(uint8_t i=0; i<NUMBER_OF_CIRCLES; i++)
        if(circles[i].r<100) // Make sure we didn't somehow make a giant circle
            graphics_draw_circle(ctx, GPoint(circles[i].x, circles[i].y), circles[i].r);
}
Пример #13
0
static void canvas_update_proc(Layer *layer, GContext *ctx) {
  int rect_width = text_layer_get_content_size(s_date_layer).w + 10;
  GRect rect_bounds = GRect(((180 - rect_width) / 2), 110, rect_width, 25);
  graphics_context_set_fill_color(ctx, settings.SecondaryColor);
  int corner_radius = 5;
  graphics_fill_rect(ctx, rect_bounds, corner_radius, GCornersAll);

  GPoint circle_center = GPoint(90, 90);
  uint16_t circle_radius = 75;
  graphics_context_set_stroke_color(ctx, settings.SecondaryColor);
  graphics_context_set_stroke_width(ctx, 1);
  graphics_draw_circle(ctx, circle_center, circle_radius);

  graphics_context_set_stroke_width(ctx, 3);
  uint16_t outer_circle_radius = 80;
  graphics_draw_circle(ctx, circle_center, outer_circle_radius);
}
Пример #14
0
static void draw_mark(int x, int y, int width, int height, void *vp)
{
     graphics_draw_circle(canvas, x, y, 10, 0xff00ff);
     graphics_draw_line(canvas, x - 15, y, x + 15, y, 0x00ffff);
     graphics_draw_line(canvas, x, y - 15, x, y + 15, 0x00ffff);
     graphics_draw_string(canvas, 50, 110, cal1, NULL, 0xffffff, 0);
     graphics_set_visible_canvas(display, canvas);
}
Пример #15
0
void centre_layer_update_proc(Layer *centre_layer, GContext* ctx){
	//fill circle
	graphics_context_set_fill_color(ctx, GColorWhite);
	graphics_fill_circle(ctx, (GPoint){72, 84}, 7);
	//stroke circle
	graphics_context_set_stroke_color(ctx, GColorBlack);
	graphics_draw_circle(ctx, (GPoint){72, 84}, 7);
}
Пример #16
0
static void mainForegroundUpdateProc(Layer* this_layer, GContext *ctx) {
  GRect b = layer_get_bounds(this_layer);

  #ifdef PBL_ROUND
  b.size.h -= 16; // Because of the time at the top, default position is too low on a round screen
  #endif

  // Draw the three lives
  GPoint lives = GPoint( b.size.w/2 - PIECE_PIXELS, b.size.h - 6);
  for (int L=0; L<3; ++L) {
    GColor in;
    GColor out;
    if (s_score.lives >= (3 - L)) {
      if (L == 0) { in = COLOR_FALLBACK(GColorMintGreen, GColorWhite); out = COLOR_FALLBACK(GColorDarkGreen, GColorBlack); }
      else if (L == 1) { in = COLOR_FALLBACK(GColorRajah, GColorWhite); out = COLOR_FALLBACK(GColorWindsorTan, GColorBlack); }
      else { in = COLOR_FALLBACK(GColorMelon, GColorWhite); out = COLOR_FALLBACK(GColorDarkCandyAppleRed, GColorBlack); }
    } else {
      in = COLOR_FALLBACK(GColorLightGray, GColorBlack);
      out = COLOR_FALLBACK(GColorDarkGray, GColorBlack);
    }
    GPoint p = lives;
    p.x += PIECE_PIXELS * L;
    graphics_context_set_stroke_color(ctx, out);
    graphics_context_set_fill_color(ctx, in);
    graphics_context_set_stroke_width(ctx, 3);
    graphics_fill_circle(ctx, p, 3);
    graphics_draw_circle(ctx, p, 3);
    // Animation?
    if (s_spentLifeAnimRadius > 0 && s_score.lives == (3 - L)) {
      graphics_context_set_stroke_width(ctx, 5);
      graphics_context_set_stroke_color(ctx, COLOR_FALLBACK(in,out));
      graphics_draw_circle(ctx, p, s_spentLifeAnimRadius / SUB_PIXEL );
    }
  }

  // Draw the game over message
  if (s_gameOverMessage == true) {
    static const char txtGame[] = "GAME";
    static const char txtOver[] = "OVER";
    b.origin.y += 30;
    draw3DText(ctx, b, fonts_get_system_font(FONT_KEY_BITHAM_42_BOLD), txtGame, 1, GTextAlignmentCenter, true, GColorWhite, GColorBlack);
    b.origin.y += 40;
    draw3DText(ctx, b, fonts_get_system_font(FONT_KEY_BITHAM_42_BOLD), txtOver, 1, GTextAlignmentCenter, true, GColorWhite, GColorBlack);
  }
}
Пример #17
0
static void paint_clock(ClockIcon *aIcon, GContext *aCtx, GRect r, GPoint aCenter, int32_t aRadius, bool aAnimating, bool aZoomedIn) {
    // background
    if (aAnimating) {
        graphics_context_set_stroke_color(aCtx, GColorWhite);
        for (int32_t i = 0; i < 60; ++i) {
            int32_t len1 = aRadius;
            int32_t len2 = (i % 5 == 0)
                ? CLOCK_HOUR_MARK_START_LENGTH(aRadius)
                : CLOCK_MIN_MARK_START_LENGTH(aRadius);
            int32_t angle = TRIG_MAX_ANGLE * i / 60.f;
            draw_angle_line(aCtx, aCenter, angle, len1, len2,
                (i % 5 == 0) ? LineWidth2 : LineWidth1);
        }
        graphics_context_set_fill_color(aCtx, GColorWhite);
        graphics_context_set_stroke_color(aCtx, GColorWhite);
    } else {
        graphics_context_set_fill_color(aCtx, GColorWhite);
        graphics_fill_circle(aCtx, aCenter, aRadius);
        graphics_context_set_fill_color(aCtx, GColorBlack);
        graphics_context_set_stroke_color(aCtx, GColorBlack);
    }
    
    clock_icon_data *data = layer_get_data(aIcon);
    int32_t h = data->h;
    int32_t m = data->m;
    int32_t s = data->s;
    
    // hour hand
    draw_clock_hand(aCtx, aCenter, aRadius, aZoomedIn,
        CLOCK_HOUR_HAND_LENGTH(aRadius),
        TRIG_MAX_ANGLE * (h + m / 60.f) / 12.f);
    
    // minutes hand
    draw_clock_hand(aCtx, aCenter, aRadius, aZoomedIn,
        CLOCK_MIN_HAND_LENGTH(aRadius),
        TRIG_MAX_ANGLE * (m + s / 60.f) / 60.f);
    
    if (aZoomedIn) {
        graphics_draw_circle(aCtx, aCenter, CLOCK_CENTER_RADIUS - 1);
    }
    
    if (!aAnimating && !aZoomedIn && !clock_icon_shows_second_hand()) {
        // don't draw second hand if preffed off.
        return;
    }
    // seconds hand
    int32_t secLength = CLOCK_SEC_HAND_LENGTH(aRadius);
    int32_t secAngle = TRIG_MAX_ANGLE * s / 60.f;
#ifdef PBL_COLOR
    graphics_context_set_stroke_color(aCtx, GColorChromeYellow);
#endif
    if (aZoomedIn) {
        draw_angle_line(aCtx, aCenter, secAngle, CLOCK_CENTER_RADIUS, secLength, LineWidth1);
    } else {
        draw_angle_line(aCtx, aCenter, secAngle, 0, secLength, LineWidth1);
    }
}
Пример #18
0
static void draw_shape(GContext* ctx, int shape, int32_t angle, bool hour) {
  if (shape < 3) {
    graphics_draw_circle(ctx, center_point, hour ? HOUR_RADIUS : MINUTE_RADIUS);
  } else {
    GPathInfo* path_info = (hour ? HOUR_SHAPES : MINUTE_SHAPES) + shape - 3;
    GPath* path = gpath_create(path_info);
    gpath_rotate_to(path, angle);
    gpath_move_to(path, center_point);
    gpath_draw_outline(ctx, path);
  }
}
static void graph_layer_update_callback(Layer *me, GContext *ctx) {
	const GRect frame = layer_get_frame(me);
	graphics_context_set_fill_color(ctx, GColorWhite);
	if (!is_measuring() && calibrations_count < 3) {
		text_calibrate_initial[74] = '0' + (3 - calibrations_count);
		graphics_draw_text(ctx, text_calibrate_initial, font_tiny, GRect(3, 0, frame.size.w - 3, frame.size.h), GTextOverflowModeWordWrap, GTextAlignmentLeft, NULL);
		return;
	}
	
	// graph area boundaries
	graphics_fill_rect(ctx, GRect(0, 0, frame.size.w, 1), 0, GCornerNone);
	graphics_fill_rect(ctx, GRect(frame.size.w - 1, 0, 1, frame.size.h), 0, GCornerNone);

	int count = calibrations_count;
	if (is_measuring())
		count++;

	Measurement *m;
	float maxWeight = 1, minFreq = calibrations[0].freq, maxFreq = 0.01, minAmp = calibrations[0].amp, maxAmp = 0.01;
	for (int i = 0; i < count; i++) {
		m = &calibrations[i];
		if (m->weight > maxWeight)
			maxWeight = m->weight;
		if (m->freq < minFreq) minFreq = m->freq;
		if (m->freq > maxFreq) maxFreq = m->freq;
		if (m->amp < minAmp) minAmp = m->amp;
		if (m->amp > maxAmp) maxAmp = m->amp;
	}
	// draw current measure circle
	graphics_context_set_stroke_color(ctx, GColorWhite);
	for (int i = 0; i < count; i++) {
		m = &calibrations[i];
		uint16_t r = 5 * m->weight / maxWeight;
		if (r < 1) r = 1;
		int16_t x = (5 + (m->freq - minFreq) * (frame.size.w - 10) / (maxFreq - minFreq));
		int16_t y = (frame.size.h - 5 - (m->amp - minAmp) * (frame.size.h - 10) / (maxAmp - minAmp));
		if (i == calibrations_count || m->weight == weight)
			graphics_fill_circle(ctx, GPoint(x, y), r);
		else
			graphics_draw_circle(ctx, GPoint(x, y), r);
	}

	// draw lines of constant weight for steps of 50g
	if (calibrations_count >= 3) {
		draw_calibration_line(ctx, frame, weight, false, minFreq, maxFreq, minAmp, maxAmp);
		float w = 0;
		do {
			if (!draw_calibration_line(ctx, frame, w, true, minFreq, maxFreq, minAmp, maxAmp))
				break;
			w += 50;
		} while (w <= 1000);
	}
}
Пример #20
0
void minutes_proc(Layer *layer, GContext *ctx){
	for(int j = c_enabled; j > 0; j--){
		if(pulse_enabled_c){
			graphics_context_set_stroke_color(ctx, GColorWhite);
			graphics_fill_circle(ctx, GPoint(circle_coords[0][j], circle_coords[1][j]), ci_value);
			graphics_draw_circle(ctx, GPoint(circle_coords[0][j], circle_coords[1][j]), ci_value+1);
		}
		else{
			graphics_fill_circle(ctx, GPoint(circle_coords[0][j], circle_coords[1][j]), 3);
		}
	}
}
Пример #21
0
void display_layer_update_callback(Layer *me, GContext* ctx) {
 	(void)me;
	PblTm t;

	graphics_context_set_fill_color(ctx, GColorWhite);
	graphics_context_set_stroke_color(ctx, GColorWhite);

	GPoint center;
	center.x = DISPLAY_W/2;
	center.y = DISPLAY_H/2;
	graphics_draw_circle(ctx,center,DISPLAY_W/2);
}
Пример #22
0
static void score_layer_update(Layer *layer,GContext *ctx){
  const uint8_t RADIUS = 60; 
  const uint8_t THICKNESS = 10;
  
  graphics_context_set_stroke_color(ctx, GColorDarkGray);
  graphics_context_set_stroke_width(ctx,THICKNESS);
  GRect r = layer_get_bounds(layer);
  
  GPoint center = grect_center_point(&r);
  graphics_draw_circle(ctx,center,RADIUS);
  
  graphics_draw_arc(ctx,center,RADIUS+ (THICKNESS/2),THICKNESS,angle_270,angle_90,GColorDukeBlue);
}
Пример #23
0
void path_layer_update_callback(Layer *me, GContext *ctx) {
    (void)me;

    graphics_context_set_stroke_color(ctx, GColorBlack);

    GPoint p0, p1;

    if (nb_points < 2) {
        return;
    }

    for (int i = 0; i < ((nb_points > NUM_POINTS ? NUM_POINTS : nb_points) - 1); i++) {
        p0 = pts[(NUM_POINTS+cur_point-i) % NUM_POINTS];
        p1 = pts[(NUM_POINTS+cur_point-i-1) % NUM_POINTS];

        p0.x = (XINI + (p0.x * SCREEN_W / (map_scale/10))) % MAP_VSIZE_X;
        p0.y = (YINI - (p0.y * SCREEN_W / (map_scale/10))) % MAP_VSIZE_Y;
        p1.x = (XINI + (p1.x * SCREEN_W / (map_scale/10))) % MAP_VSIZE_X;
        p1.y = (YINI - (p1.y * SCREEN_W / (map_scale/10))) % MAP_VSIZE_Y;

        graphics_draw_line(
            ctx,
            p0,
            p1
        );
    }

    for (int i = 0; i < s_live.nb; i++) {
        p0.x = (XINI + (s_live.friends[i].xpos * SCREEN_W / (map_scale/10))) % MAP_VSIZE_X;
        p0.y = (YINI - (s_live.friends[i].ypos * SCREEN_W / (map_scale/10))) % MAP_VSIZE_Y;

        graphics_draw_pixel(ctx, p0);
        graphics_draw_circle(ctx, p0, 3);

        if (i == 0) {
#if DEBUG
            snprintf(s_data.debug2, sizeof(s_data.debug2),
                     "%d|%d\n"
                     "%d|%d\n"
                     "%d|%d\n"
                     "%d|%d\n",
                     s_live.friends[i].xpos,s_live.friends[i].ypos,
                     p0.x,p0.y,
                     pathFrame.origin.x,pathFrame.origin.y,
                     s_live.friends[i].name_frame.origin.x,s_live.friends[i].name_frame.origin.y
                    );
#endif
        }
    }

}
Пример #24
0
static void game_layer_update_proc(Layer *layer, GContext *ctx)
{
    // Draw the apple
    graphics_context_set_stroke_color(ctx, GColorBlack);
    graphics_draw_circle(ctx, GPoint(apple->x,apple->y), APPLE_SIZE);

    // Draw the snake
    snake_section_t *current_section = snake->head;
    while (current_section) {
        graphics_context_set_fill_color(ctx, GColorBlack);
        graphics_fill_circle(ctx, GPoint(current_section->x,current_section->y), SNAKE_BODY_WIDTH);
        current_section = current_section->next;
    }
}
void circle_proc(Layer *layer, GContext *ctx){
    graphics_context_set_stroke_color(ctx, GColorBlack);
    graphics_context_set_fill_color(ctx, GColorBlack);
    int i;
    for(i = 0; i < 4; i++){
        int fix = 17+(30*i);
        graphics_draw_circle(ctx, GPoint(fix, CIRCLE_HEIGHT), CIRCLE_RADIUS);
    }
    int k;
    for(k = 0; k < circles_filled; k++){
        int fix = 17+(30*k);
        graphics_fill_circle(ctx, GPoint(fix, CIRCLE_HEIGHT), CIRCLE_RADIUS);
    }
}
Пример #26
0
static void maze_layer_update_callback(Layer *layer, GContext *ctx) {
  for(int i = 0; i < mazeWidth; i++){
    for(int j = 0; j < mazeHeight; j++){
      int currentPos = getPOS(j, i, mazeWidth);
      if(maze[currentPos].r == 1) {
        graphics_draw_line(ctx, GPoint(corridorSize*(i + 1), corridorSize*j), GPoint(corridorSize*(i + 1), corridorSize*(j + 1)));
      }
      if(maze[currentPos].b == 1) {
        graphics_draw_line(ctx, GPoint(corridorSize*i, corridorSize*(j + 1)), GPoint(corridorSize*(i + 1), corridorSize*(j + 1)));
      }
    }
  }
  graphics_draw_circle(ctx, GPoint((mazeWidth-1)*corridorSize+corridorSize/2,
                                   (mazeHeight-1)*corridorSize+corridorSize/2), corridorSize/2-1);
}
Пример #27
0
void battery_layer_update(Layer *me, GContext *ctx) 
{
  int8_t spacer  = 7; // pixels
  int8_t start_x = spacer * MAX_DOTS;
  
  graphics_context_set_fill_color(ctx, GColorWhite);
  graphics_context_set_stroke_color(ctx, GColorWhite);
  for (int i=0; i<MAX_DOTS; i++) {
    if (i<dots) {
      graphics_fill_circle(ctx, GPoint(start_x-(i*spacer), 4), 2);
    } else {
      graphics_draw_circle(ctx, GPoint(start_x-(i*spacer), 4), 2);
    }
  } 
}
Пример #28
0
void draw_face_layer(Layer* l, GContext* ctx)
{
	GColor foreground_color = gcolor_legible_over(s_background_color);
	GRect bounds = layer_get_frame(l);
	GPoint center = GPoint(bounds.size.w / 2, bounds.size.h / 2);
	int height = bounds.size.h - 2;
	int width = bounds.size.w - 2;

	graphics_context_set_stroke_color(ctx, foreground_color);
	graphics_context_set_fill_color(ctx, s_complementary_color);
	graphics_context_set_text_color(ctx, foreground_color);

	graphics_draw_circle(ctx, center, 6);
	graphics_fill_circle(ctx, center, 5);

	// draw 4 ticks
	GRect zero_box;
	zero_box.size.w = 30;
	zero_box.size.h = 12;
	zero_box.origin.x = width / 2 - 12;
	zero_box.origin.y = height - 20;
	graphics_draw_text(ctx, "0", s_time_font, zero_box, GTextOverflowModeFill, GTextAlignmentCenter, NULL);
	zero_box.origin.y = height / 2 - 12;
	zero_box.origin.x = 2;
	graphics_draw_text(ctx, "6", s_time_font, zero_box, GTextOverflowModeFill, GTextAlignmentLeft, NULL);
	zero_box.origin.x = width / 2 - 10;
	zero_box.origin.y = 0;
	graphics_draw_text(ctx, "12", s_time_font, zero_box, GTextOverflowModeFill, GTextAlignmentCenter, NULL);
	zero_box.origin.y = height / 2 - 10;
	zero_box.origin.x = width - 30;
	graphics_draw_text(ctx, "18", s_time_font, zero_box, GTextOverflowModeFill, GTextAlignmentRight, NULL);

	graphics_context_set_fill_color(ctx, s_complementary_color);
	int circle_inset = PBL_IF_ROUND_ELSE(6, 2);
	int circle_radius = MIN(width / 2 - circle_inset, height / 2 - circle_inset);
	for (int i = 0; i < 24; ++i) {
		if (i % 6 == 0) {
			continue;
		}
		int angle = i * TRIG_MAX_ANGLE / 24;

		int y = (-cos_lookup(angle) * circle_radius / TRIG_MAX_RATIO);
		int x = (sin_lookup(angle) * circle_radius / TRIG_MAX_RATIO);

		GPoint pt = GPoint(x + center.x, y + center.y);
		graphics_fill_circle(ctx, pt, 2);
	}
}
Пример #29
0
static void draw_digit(Layer *layer, GContext *ctx,
                       int col, int bits, int val)
{
	const GRect bounds = layer_get_bounds(layer);
	const int16_t x_coord = col_offset + RADIUS + (2 * RADIUS + col_spacing) * col;
	GPoint point;
	int i;

	for (i = 0; i < bits; i++) {
		point = GPoint(x_coord, bounds.size.h - RADIUS * (3 * i + 2));
		if (val & 1)
			graphics_fill_circle(ctx, point, RADIUS);
		else
			graphics_draw_circle(ctx, point, RADIUS);

		val >>= 1;
	}
}
Пример #30
0
void update_graph(struct Layer* layer, GContext* ctx) {
  graphics_context_set_fill_color(ctx, BG_COLOR);
  graphics_fill_rect(ctx, FULL_SCREEN, 0, GCornerNone);
  
  float hourpos = 12 - (hours + minutes / 60.0f);
  float minpos = (minutes) / 5.0f;
  graphics_context_set_stroke_color(ctx, TIME_COLOR);
  graphics_draw_line(ctx, GPoint((int)(18 + 9 * minpos), 22), GPoint((int)(18 + 9 * minpos), 146));
  graphics_draw_line(ctx, GPoint(10, (int)(30 + 9 * hourpos)), GPoint(134, (int)(30 + 9 * hourpos)));
  graphics_draw_circle(ctx, GPoint((int)(18 + 9 * minpos), (int)(30 + 9 * hourpos)), 2);
  
  graphics_context_set_stroke_color(ctx, TEXT_COLOR);
  
  for (int i = 0; i < 13; i++)
    for (int j = 0; j < 13; j++)
    graphics_draw_pixel(ctx, GPoint(18 + 9 * i, 30 + 9 * j));
  
  graphics_draw_rect(ctx, GRect(9, 21, 126, 126));
}