コード例 #1
0
void hour_layer_update_callback(Layer *me, GContext* ctx) {
    (void)me;
    
    gpath_rotate_to(&hour_hand, (TRIG_MAX_ANGLE / 360) * (curHour * 30 + curMin / 2));

    graphics_context_set_stroke_color(ctx, GColorWhite);
    graphics_context_set_fill_color(ctx, GColorBlack);
    gpath_draw_filled(ctx, &hour_hand);
    gpath_draw_outline(ctx, &hour_hand);
}
コード例 #2
0
static void redraw_direction_arrow(Layer *layer, GContext *ctx) {
  Arrow* arrow = (Arrow*) layer_get_data(layer);
  if (!arrow->direction) {
    return;
  }
  gpath_rotate_to(arrow_path, TRIG_MAX_ANGLE / 360 * arrow->direction);

  graphics_context_set_fill_color(ctx, GColorBlack);
  gpath_draw_filled(ctx, arrow_path);
}
コード例 #3
0
void second_layer_update_callback(Layer *me, GContext* ctx) {
    (void)me;
    
    int r = radius*secLen;
    
    int c1 = cols[ph][curSec>30?1:0];
    int c2 = cols[ph][curSec>30?0:1];
    int c3 = (c1==c2)?cols[ph][2]:c2;
    
    int ox = -1;
    int oy = 1;
    if(curSec>30){
        ox = 1;
    }if(curSec<15 || curSec>45){
        oy = -1;
    }
    
    int angle = TRIG_MAX_ANGLE/-4+TRIG_MAX_ANGLE * curSec/60.;
    double c = cos_lookup(angle) / 65536. * r;
    double s = sin_lookup(angle) / 65536. * r;
    
    graphics_context_set_stroke_color(ctx, c3);
    graphics_draw_line(
        ctx, 
        GPoint(centerx+ox, centery+oy), 
        GPoint(
            centerx + c + ox, 
            centery + s + oy));
    
    graphics_context_set_stroke_color(ctx, c1);
    graphics_draw_line(
        ctx, 
        GPoint(centerx, centery), 
        GPoint(
            centerx + c, 
            centery + s));
    
    graphics_context_set_fill_color(ctx, showDetailedMoonGraphic?GColorWhite:c1);
    graphics_fill_circle(ctx, GPoint(centerx + c,centery + s), secRad);
    
    graphics_context_set_fill_color(ctx, showDetailedMoonGraphic?GColorBlack:c2);
    graphics_fill_circle(ctx, GPoint(centerx + c,centery + s), secRad-1);
}
コード例 #4
0
void minute_layer_update_callback(Layer *me, GContext* ctx) {
    (void)me;
    
    gpath_rotate_to(&minute_hand, (TRIG_MAX_ANGLE / 360) * curMin * 6);

    graphics_context_set_stroke_color(ctx, GColorWhite);
    graphics_context_set_fill_color(ctx, GColorBlack);
    gpath_draw_filled(ctx, &minute_hand);
    gpath_draw_outline(ctx, &minute_hand);
}
コード例 #5
0
ファイル: main.c プロジェクト: braiba/learningpebblefaces
static void bar_layer_update_callback(Layer *layer, GContext *ctx) {
  graphics_context_set_fill_color(ctx, GColorBlack);
  if (layer == s_hour_bar_layer) {
    #ifdef PBL_COLOR
      graphics_context_set_fill_color(ctx, GColorRed);
    #endif
    graphics_fill_rect(ctx, GRect(0, 0, (80 * s_hour_value) / 24, 52), 0, GCornerNone);
  } else if (layer == s_minute_bar_layer) {
    #ifdef PBL_COLOR
      graphics_context_set_fill_color(ctx, GColorGreen);
    #endif
    graphics_fill_rect(ctx, GRect(0, 0, (80 * s_minute_value) / 60, 52), 0, GCornerNone);
  } else if (layer == s_second_bar_layer) {
    #ifdef PBL_COLOR
      graphics_context_set_fill_color(ctx, GColorBlue);
    #endif
    graphics_fill_rect(ctx, GRect(0, 0, (80 * s_second_value) / 60, 52), 0, GCornerNone);
  }
}
コード例 #6
0
void battery_pbl_layer_update_callback(Layer *me, GContext* ctx) {
	
	//draw the remaining pebble battery percentage
	graphics_context_set_stroke_color(ctx, GColorBlack);
	graphics_context_set_fill_color(ctx, GColorWhite);

	//graphics_fill_rect(ctx, GRect(2+16-(int)((batteryPblPercent/100.0)*16.0), 2, (int)((batteryPblPercent/100.0)*16.0), 8), 0, GCornerNone);
	graphics_fill_rect(ctx, GRect(2, 2, (int)((batteryPercent/100.0)*20.0), 10), 0, GCornerNone);
	
}
コード例 #7
0
ファイル: compass.c プロジェクト: paulmitchell/pebble-compass
static void direction_layer_update_proc(Layer *layer, GContext *ctx) {
  GRect bounds = layer_get_bounds(layer);
  GPoint center = grect_center_point(&bounds);
  graphics_context_set_fill_color(ctx, BG_COLOR);
  graphics_context_set_text_color(ctx, FG_COLOR);
  draw_direction(ctx, &center, -heading_angle, "N");
  draw_direction(ctx, &center, -heading_angle + 90, "E");
  draw_direction(ctx, &center, -heading_angle + 180, "S");
  draw_direction(ctx, &center, -heading_angle + 270, "W");
}
コード例 #8
0
void draw_custom_pixel(GContext *ctx, int x, int y, int px_size, GColor color) {
	int pos = x/px_size;
	GRect rect_bounds = GRect(x, y, (pos >= 10 ? px_size+1 : px_size), px_size);
	//GRect rect_bounds = GRect(x, y, px_size, px_size);

	graphics_context_set_fill_color(ctx, color);

	graphics_draw_rect(ctx, rect_bounds);
	graphics_fill_rect(ctx, rect_bounds, 0, GCornerNone);
}
コード例 #9
0
ファイル: modern.c プロジェクト: BUSHA/pebble
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;

  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);

#if INVERTED
  graphics_context_set_fill_color(ctx, GColorBlack);
  graphics_context_set_stroke_color(ctx, GColorWhite);
#else
  graphics_context_set_fill_color(ctx, GColorWhite);
  graphics_context_set_stroke_color(ctx, GColorBlack);
#endif

  gpath_draw_filled(ctx, &hour_hand_path);
  gpath_draw_outline(ctx, &hour_hand_path);
}
コード例 #10
0
ファイル: battery.c プロジェクト: smudugal/PebbleMeachum
static void update_battery(Layer *layer, GContext *context) {
  GRect layer_bounds = layer_get_bounds(layer);
  
  int bar_width = (int)(((float)battery_level / 100.0F) * layer_bounds.size.w);

  graphics_context_set_fill_color(context, GColorVividCerulean);
  graphics_fill_rect(context, GRect(layer_bounds.origin.x, layer_bounds.origin.y,
                                    bar_width, layer_bounds.size.h), 0, GCornerNone);
  
}
コード例 #11
0
ファイル: display.c プロジェクト: cckroets/Chip8Pebble
void display_repaint(Display* display) {
	for (int x = 0; x < DISPLAY_WIDTH; x++) {
		for (int y = 0; y < DISPLAY_HEIGHT; y++) {
      GColor color = display->pixels[x][y] ? GColorBlack : GColorWhite;
      graphics_context_set_fill_color(display->g_context, color);
			GRect pixel = GRect(PIXEL_SIZE * x, PIXEL_SIZE * y, PIXEL_SIZE, PIXEL_SIZE);
			graphics_fill_rect(display->g_context, pixel, 0, GCornersAll );
		}
	}
}
コード例 #12
0
void graphics_sun_layer_update_callback(Layer *me, GContext* ctx) 
{
  (void)me;

  gpath_init(&sun_path, &sun_path_info);
  gpath_move_to(&sun_path, grect_center_point(&graphics_sun_layer.frame));

  graphics_context_set_fill_color(ctx, GColorBlack);
  gpath_draw_filled(ctx, &sun_path);  
}
コード例 #13
0
ファイル: pebble-mario.c プロジェクト: aclymer/pebble-mario
void draw_block(GContext *ctx, GRect rect, uint8_t width)
{
    static const uint8_t radius = 1;

    graphics_context_set_fill_color(ctx, MainColor);
    graphics_fill_rect(ctx, rect, radius, GCornersAll);

    rect.origin.x += width;
    rect.origin.y += width;
    rect.size.w -= width*2;
    rect.size.h -= width*2;
    graphics_context_set_fill_color(ctx, BackgroundColor);
    graphics_fill_rect(ctx, rect, radius, GCornersAll);

    static const uint8_t dot_offset = 3;
    static const uint8_t dot_width = 6;
    static const uint8_t dot_height = 4;

    GRect dot_rect;

    graphics_context_set_fill_color(ctx, MainColor);

    // top left dot
    dot_rect = GRect(rect.origin.x + dot_offset, rect.origin.y + dot_offset,
                     dot_width, dot_height);
    graphics_fill_rect(ctx, dot_rect, 1, GCornersAll);

    // top right dot
    dot_rect = GRect(rect.origin.x + rect.size.w - dot_offset - dot_width, rect.origin.y + dot_offset,
                     dot_width, dot_height);
    graphics_fill_rect(ctx, dot_rect, 1, GCornersAll);

    // bottom left dot
    dot_rect = GRect(rect.origin.x + dot_offset, rect.origin.y + rect.size.h - dot_offset - dot_height,
                     dot_width, dot_height);
    graphics_fill_rect(ctx, dot_rect, 1, GCornersAll);

    // bottom right dot
    dot_rect = GRect(rect.origin.x + rect.size.w - dot_offset - dot_width,
                     rect.origin.y + rect.size.h - dot_offset - dot_height,
                     dot_width, dot_height);
    graphics_fill_rect(ctx, dot_rect, 1, GCornersAll);
}
コード例 #14
0
ファイル: main_window.c プロジェクト: edwinfinch/codec
static void levels_update(Layer *layer, GContext *ctx) {
  #ifdef PBL_COLOR
    graphics_context_set_fill_color(ctx, GColorElectricBlue);
  #else
      graphics_context_set_fill_color(ctx, GColorWhite);
  #endif
  graphics_fill_rect(ctx, GRect(5,130,5,15), 0, GCornersAll);  
  graphics_fill_rect(ctx, GRect(16,130,24,15), 0, GCornersAll);
  //gpath_draw_filled(ctx, level1);
  if(seconds >= 10) {
     graphics_fill_rect(ctx, GRect(5,110,5,15), 0, GCornersAll);    
    gpath_draw_filled(ctx, level2);
  }
 if(seconds >= 20) { 
    graphics_fill_rect(ctx, GRect(5,90,5,15), 0, GCornersAll);  
    gpath_draw_filled(ctx, level3);
  }
  if(seconds >= 30) {
    graphics_fill_rect(ctx, GRect(5,70,5,15), 0, GCornersAll);    
    gpath_draw_filled(ctx, level4);
  }
  if(seconds >= 40) {  
    graphics_fill_rect(ctx, GRect(5,50,5,15), 0, GCornersAll);  
    gpath_draw_filled(ctx, level5);
  }
  if (seconds >= 50) {
    graphics_fill_rect(ctx, GRect(5,29,5,15), 0, GCornersAll);  
    graphics_fill_rect(ctx, GRect(16,29,119,15), 0, GCornersAll);
    #ifdef PBL_COLOR
      graphics_context_set_text_color(ctx, GColorElectricBlue);
    #else
      graphics_context_set_text_color(ctx, GColorWhite);
    #endif
  } else {
    #ifdef PBL_COLOR
      graphics_context_set_text_color(ctx, GColorMidnightGreen);
    #else
      graphics_context_set_text_color(ctx, GColorBlack);
    #endif
  }
   graphics_draw_text(ctx, "MaX",  fonts_load_custom_font(resource_get_handle(RESOURCE_ID_METAL_GEAR_9)), GRect(114,43,30,30), GTextOverflowModeWordWrap, GTextAlignmentLeft, NULL);
}
コード例 #15
0
void graphics_draw_cloud(GContext * ctx, int pos, int isFront, GColor color, weather next) {
  int start = 29*pos;
  
  if (isFront == 0) {
    graphics_context_set_fill_color(ctx, GColorBlack);
    graphics_context_set_stroke_color(ctx, GColorBlack);
    graphics_fill_circle(ctx, GPoint(start + 7, 102+y_off), 6);
    graphics_fill_circle(ctx, GPoint(start + 14, 99+y_off), 7);
    graphics_fill_circle(ctx, GPoint(start + 22, 103+y_off), 5);
    graphics_draw_line(ctx, GPoint(start + 7, 107+y_off), GPoint(start + 18, 107+y_off));
    graphics_draw_line(ctx, GPoint(start + 7, 108+y_off), GPoint(start + 18, 108+y_off));
    if (next == cloudy || next == rainy || next == tstorm) {
      graphics_fill_circle(ctx, GPoint(start + 30, 101+y_off), 7);
      graphics_draw_line(ctx, GPoint(start + 13, 107+y_off), GPoint(start + 32, 107+y_off));
      graphics_draw_line(ctx, GPoint(start + 13, 108+y_off), GPoint(start + 32, 108+y_off));
    }
  } else {
    graphics_context_set_fill_color(ctx, color);
    graphics_fill_circle(ctx, GPoint(start + 7, 102+y_off), 4);
    graphics_fill_circle(ctx, GPoint(start + 14, 99+y_off), 5);
    graphics_fill_circle(ctx, GPoint(start + 22, 103+y_off), 3);
    graphics_fill_rect(ctx, GRect(start + 7, 101+y_off, 16, 6), 0, GCornerNone);
    
    GColor nextColor = GColorClear;
    if (next == cloudy) {
      nextColor = GColorWhite;
    } else if (next == rainy || next == tstorm) {
      nextColor = GColorDarkGray;
    }
    
    if (!gcolor_equal(nextColor, GColorClear)) {
      if (!gcolor_equal(color, nextColor)) {
        graphics_context_set_fill_color(ctx, GColorLightGray);
      }
      graphics_fill_circle(ctx, GPoint(start + 30, 101+y_off), 5);
      graphics_fill_circle(ctx, GPoint(start + 32, 103+y_off), 3);
      graphics_fill_circle(ctx, GPoint(start + 26, 103+y_off), 3);
      graphics_context_set_fill_color(ctx, color);
      graphics_fill_circle(ctx, GPoint(start + 23, 103+y_off), 3);
    }
  }
}
コード例 #16
0
void draw_rounded_text_layer(Layer *layer, GContext *ctx) {
  RoundedTextLayerData* data = (RoundedTextLayerData*)layer_get_data(layer);
  
  GRect bound = layer_get_bounds(layer);
  
  graphics_context_set_fill_color(ctx, data->bg_color);
  graphics_fill_rect(ctx, bound, data->corner_radius, data->corner_mask);
  
  graphics_context_set_text_color(ctx, data->text_color);
  graphics_draw_text(ctx, data->text, data->font, bound, data->overflow, data->text_alignment, NULL);
}
コード例 #17
0
ファイル: pom.c プロジェクト: Belphemur/PblPom
void pomUpdateBatteryLayer(Layer *layer, GContext *ctx) {
  // Emulator battery meter on Aplite
  graphics_context_set_stroke_color(ctx, GColorWhite);
  graphics_draw_rect(ctx, GRect(126, 4, 14, 8));
  graphics_draw_line(ctx, GPoint(140, 6), GPoint(140, 9));

  BatteryChargeState state = battery_state_service_peek();
  int width = (int)(float)(((float)state.charge_percent / 100.0F) * 10.0F);
  graphics_context_set_fill_color(ctx, GColorWhite);
  graphics_fill_rect(ctx, GRect(128, 6, width, 4), 0, GCornerNone);
}
コード例 #18
0
ファイル: main.c プロジェクト: sdneon/Enigma-plus
void time_box_layer_update_proc2(Layer *layer, GContext *ctx) {
    GRect bounds = layer_get_bounds(layer);
    GPoint center = grect_center_point(&bounds);
    GRect r = GRect(bounds.origin.x, center.y + 24, bounds.size.w, 48);

    graphics_context_set_stroke_color(ctx, !m_bDualTime?
        GColorBlack: (m_bisAm2nd? GColorRed: GColorBlue));
    graphics_context_set_fill_color(ctx, !m_bDualTime?
        GColorBlack: (m_bisAm2nd? GColorRed: GColorBlue));
    graphics_fill_rect(ctx, r, 0, GCornerNone);
}
コード例 #19
0
ファイル: main.c プロジェクト: sdneon/Enigma-plus
//
// Enigma display stuff
//
void time_box_layer_update_proc(Layer *layer, GContext *ctx) {
    GRect bounds = layer_get_bounds(layer);
    GPoint center = grect_center_point(&bounds);
    GRect r = GRect(bounds.origin.x, center.y - 24, bounds.size.w, 48);

    graphics_context_set_stroke_color(ctx, m_bIsAm? GColorRed: GColorBlue);
    graphics_context_set_fill_color(ctx, m_bIsAm? GColorRed: GColorBlue);
//    graphics_draw_rect(ctx, r);
    graphics_fill_rect(ctx, r, 0, GCornerNone);
//    graphics_draw_rect(ctx, grect_crop(r, 1));
}
コード例 #20
0
static void render_plus(Layer *layer, GContext *ctx) {
    GRect bounds = layer_get_bounds(layer);

    graphics_context_set_fill_color(ctx, GColorBlack);

    //graphics_fill_rect(ctx, GRect(0,0,FIELD_WIDTH, FIELD_HEIGHT), 0, GCornerNone);
    graphics_draw_line(ctx, GPoint(FIELD_WIDTH/4, FIELD_HEIGHT/2),
                            GPoint(3*FIELD_WIDTH/4, FIELD_HEIGHT/2));
    graphics_draw_line(ctx, GPoint(FIELD_WIDTH/2, FIELD_HEIGHT/4),
                            GPoint(FIELD_WIDTH/2, 3*FIELD_HEIGHT/4));
}
コード例 #21
0
ファイル: common.c プロジェクト: Kfernand2/pebble
void timer_draw_row(Timer* timer, GContext* ctx) {
  char* time_left = malloc(12);
  timer_time_str(timer->current_time, settings()->timers_hours, time_left, 12);

  graphics_context_set_text_color(ctx, GColorBlack);
  graphics_context_set_fill_color(ctx, GColorBlack);

  graphics_draw_text(ctx, time_left,
    fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD),
    GRect(33, -3, PEBBLE_WIDTH - 33, 28), GTextOverflowModeFill,
    GTextAlignmentLeft, NULL);

  GBitmap* bmp_icon = NULL;
  GBitmap* bmp_direction = NULL;

  switch (timer->status) {
    case TIMER_STATUS_STOPPED:
      bmp_icon = bitmaps_get_sub_bitmap(RESOURCE_ID_ICONS_16, ICON_RECT_STOP);
      break;
    case TIMER_STATUS_RUNNING:
      bmp_icon = bitmaps_get_sub_bitmap(RESOURCE_ID_ICONS_16, ICON_RECT_PLAY);
      break;
    case TIMER_STATUS_PAUSED:
      bmp_icon = bitmaps_get_sub_bitmap(RESOURCE_ID_ICONS_16, ICON_RECT_PAUSE);
      break;
    case TIMER_STATUS_DONE:
      bmp_icon = bitmaps_get_sub_bitmap(RESOURCE_ID_ICONS_16, ICON_RECT_DONE);
      break;
  }

  if (bmp_icon) {
    graphics_draw_bitmap_in_rect(ctx, bmp_icon, GRect(8, 8, 16, 16));
  }

  switch (timer->type) {
    case TIMER_TYPE_TIMER:
      bmp_direction = bitmaps_get_sub_bitmap(RESOURCE_ID_ICONS_16, ICON_RECT_TIMER);
      break;
    case TIMER_TYPE_STOPWATCH:
      bmp_direction = bitmaps_get_sub_bitmap(RESOURCE_ID_ICONS_16, ICON_RECT_STOPWATCH);
      break;
  }

  if (bmp_direction) {
    graphics_draw_bitmap_in_rect(ctx, bmp_direction, GRect(PEBBLE_WIDTH - 8 - 8, 9, 8, 16));
  }

  if (timer->type == TIMER_TYPE_TIMER) {
    uint8_t width = (144 * timer->current_time) / timer->length;
    graphics_fill_rect(ctx, GRect(0, 31, width, 2), 0, GCornerNone);
  }

  free(time_left);
}
コード例 #22
0
static void cb_background_draw(Layer *layer, GContext *g_ctx) {
	DashboardLayer* dashboard_layer = *(DashboardLayer**)(layer_get_data(layer));
	GRect layer_bounds = layer_get_bounds(layer);

	graphics_context_set_fill_color(g_ctx,dashboard_layer->bgColor);
	layer_bounds.origin.x += 1;
	layer_bounds.origin.y += 1;
	layer_bounds.size.w -= 2;
	layer_bounds.size.h -= 1;
	graphics_fill_rect(g_ctx,layer_bounds,6,GCornersTop);
}
コード例 #23
0
ファイル: main.c プロジェクト: MathewReiss/Yahoo2015
static void draw_loading_custom_layer(Layer *layer, GContext *ctx){
  graphics_context_set_fill_color(ctx, GColorBlack);
  graphics_fill_rect(ctx, GRect(0,0,144,152), 0, GCornerNone);
	
#ifdef PBL_COLOR
  graphics_context_set_fill_color(ctx, GColorWhite);
#else
  graphics_context_set_fill_color(ctx, GColorBlack);
#endif
	
  graphics_fill_rect(ctx, GRect(32, 72, 80, 6), 2, GCornersAll);
	
#ifdef PBL_COLOR
  graphics_context_set_fill_color(ctx, APP_COLOR);
#else
  graphics_context_set_fill_color(ctx, GColorWhite);
#endif
	
  graphics_fill_rect(ctx, loading_rect, 2, GCornersAll);	
}
コード例 #24
0
ファイル: calendar.c プロジェクト: slugonamission/PebCal
void calendar_graphics_draw(Layer* layer, GContext* context)
{
    // Set the colour
    graphics_context_set_text_color(context, CALENDAR_FOREGROUND);
    graphics_context_set_fill_color(context, CALENDAR_FOREGROUND);
    graphics_context_set_stroke_color(context, CALENDAR_FOREGROUND);
    
    // Get the frame to figure out the offset
    GRect frame = layer_get_frame(layer);
    calendar_single_draw(layer, context, frame.size.h);
}
コード例 #25
0
ファイル: weather.c プロジェクト: caribo/Futura2.0
/*
 * Battery icon callback handler
 */
void battery_layer_update_callback(Layer *layer, GContext *ctx) {
	graphics_context_set_compositing_mode(ctx, GCompOpAssign);
	if (!battery_plugged && ((battery_level<=20) || (battery_level>=90))) {
		graphics_draw_bitmap_in_rect(ctx, icon_battery, GRect(0, 0, 24, 12));
		graphics_context_set_stroke_color(ctx, GColorBlack);
		graphics_context_set_fill_color(ctx, GColorWhite);
		graphics_fill_rect(ctx, GRect(7, 4, (uint8_t)((battery_level / 100.0) * 11.0), 4), 0, GCornerNone);
	} else if (battery_plugged) {
		graphics_draw_bitmap_in_rect(ctx, icon_battery_charge, GRect(0, 0, 24, 12));
	}
}
コード例 #26
0
ファイル: main.c プロジェクト: RichardGG/PebbleWearPebble
static void update_card(GContext* ctx, int card_no)
{
	int title_height = graphics_text_layout_get_content_size(title_strings[card_no],fonts_get_system_font(FONT_KEY_GOTHIC_18),GRect(0,0,142-54,168),GTextOverflowModeWordWrap, GTextAlignmentLeft).h;
	
	//card
	graphics_context_set_fill_color(ctx, GColorWhite);
	if(title_height > 18)
		graphics_fill_rect(ctx, GRect(0, 12, 144, 168), 0, GCornerNone);
	else
		graphics_fill_rect(ctx, GRect(0, 26, 144, 168), 0, GCornerNone);
	
	//icon box
	graphics_context_set_stroke_color(ctx, GColorWhite);
	graphics_draw_round_rect(ctx,GRect(144-54, 0, 54, 54),3);		
	graphics_context_set_fill_color(ctx, GColorBlack);
	graphics_fill_rect(ctx, GRect(144-53, 1, 52, 52), 3, GCornersAll);
	
	//icon
	graphics_draw_bitmap_in_rect(ctx, &icon_bitmaps[card_no],GRect(144-51,3,48,48));
	
	//text
	graphics_context_set_text_color(ctx, GColorBlack);	
	if(title_height > 18)
		graphics_draw_text(ctx, 
						   title_strings[card_no],  
						   fonts_get_system_font(FONT_KEY_GOTHIC_18),
						   GRect( 2, 12, 142-54, 20),
						   GTextOverflowModeWordWrap, GTextAlignmentLeft, NULL);
	else
		graphics_draw_text(ctx, 
					   title_strings[card_no],  
					   fonts_get_system_font(FONT_KEY_GOTHIC_18),
					   GRect( 2, 26, 142-54, 20),
					   GTextOverflowModeWordWrap, GTextAlignmentLeft, NULL);
	
	graphics_draw_text(ctx, 
					   text_strings[card_no],  
					   fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD),
					   GRect( 2, MIN_CARD_HEIGHT - 7, 142, 60),
					   (expanded_visible)?GTextOverflowModeWordWrap:GTextOverflowModeTrailingEllipsis, GTextAlignmentLeft, NULL);
}
コード例 #27
0
ファイル: hello_world.c プロジェクト: sbmyers/PebbleFace
static void hands_update_proc(Layer *layer, GContext *ctx) {
    GRect bounds = layer_get_bounds(layer);
    GPoint center = grect_center_point(&bounds);
    int16_t second_hand_length = bounds.size.w / 2;

    time_t now = time(NULL);
    struct tm *t = localtime(&now);
    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,
    };

    // second hand
    graphics_context_set_stroke_color(ctx, GColorWhite);
    graphics_draw_line(ctx, second_hand, center);

    // minute/hour hand
    graphics_context_set_fill_color(ctx, GColorWhite);
    graphics_context_set_stroke_color(ctx, GColorBlack);

    gpath_rotate_to(s_minute_arrow, TRIG_MAX_ANGLE * t->tm_min / 60);
    gpath_draw_filled(ctx, s_minute_arrow);
    gpath_draw_outline(ctx, s_minute_arrow);

    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);
    gpath_draw_outline(ctx, s_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);
}

static void date_update_proc(Layer *layer, GContext *ctx) {
    time_t now = time(NULL);
    struct tm *t = localtime(&now);

    strftime(s_num_buffer, sizeof(s_num_buffer), "%d", t);
    text_layer_set_text(s_num_label, s_num_buffer);
}
コード例 #28
0
ファイル: battery_icon.c プロジェクト: schornT/atWATCH
static void paint_battery_icon(BatteryIcon *aIcon, GContext *aCtx, GRect r, GPoint aCenter, int32_t aRadius, bool aZoomedIn) {
    graphics_context_set_stroke_color(aCtx, GColorWhite);
    uint8_t percent = battery_icon_get_percent(aIcon);
#ifdef PBL_COLOR
    graphics_context_set_fill_color(aCtx, GColorMalachite);
    graphics_fill_circle(aCtx, aCenter, aRadius);
#endif
    for (int32_t x = 0; x < r.size.w; ++x) {
        for (int32_t y = 0; y < r.size.h; ++y) {
            if (point_in_circle(x-aCenter.x, y-aCenter.y, aCenter.y)) {
                graphics_context_set_stroke_color(aCtx, GColorWhite);
                if (!point_in_arc(percent, x-aCenter.x, y-aCenter.y, aCenter.y)) {
#ifdef PBL_COLOR
                    graphics_context_set_stroke_color(aCtx, GColorDarkGray);
                    graphics_draw_pixel(aCtx, GPoint(x, y));
#else
                    if (pattern25(x,y)) {
                        graphics_context_set_stroke_color(aCtx, GColorBlack);
                    }
#endif
                }
#ifndef PBL_COLOR
                graphics_draw_pixel(aCtx, GPoint(x, y));
#endif
            }
        }
    }
    graphics_context_set_fill_color(aCtx, GColorBlack);
    graphics_fill_circle(aCtx, aCenter, aRadius * (1.f-RING_WIDTH));

    // text
    static char buffer[] = "100";
    snprintf(buffer, sizeof(buffer)/sizeof(buffer[0]), "%d", percent);
    graphics_draw_text(aCtx, buffer,
        fonts_get_system_font(BATTERY_FONT),
        GRect(0, (r.size.h - BATTERY_TEXT_ADJUSTMENT) / 2,
            r.size.w, BATTERY_FONT_SIZE),
        GTextOverflowModeWordWrap,
        GTextAlignmentCenter,
        NULL);
}
コード例 #29
0
ファイル: pebble_one.c プロジェクト: agreen/PebbleONE
void hands_layer_update_callback(Layer *layer, GContext* ctx) {
#if SCREENSHOT
  now->tm_hour = 10;
  now->tm_min = 9;
  now->tm_sec = 36;
#endif

  GPoint center = GPoint(CENTER_X, CENTER_Y);

  // hours and minutes
  int32_t hour_angle = THREESIXTY * (now->tm_hour * 5 + now->tm_min / 12) / 60;
  int32_t min_angle = THREESIXTY * now->tm_min / 60;
  gpath_rotate_to(hour_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_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);

  // seconds
  if (!hide_seconds) {
    int32_t sec_angle = THREESIXTY * now->tm_sec / 60;
    GPoint sec_pos = GPoint(
      CENTER_X + SEC_RADIUS * sin_lookup(sec_angle) / ONE,
      CENTER_Y - SEC_RADIUS * cos_lookup(sec_angle) / ONE);
    graphics_context_set_fill_color(ctx, GColorBlack);
    gpath_rotate_to(sec_path, sec_angle);
    gpath_draw_filled(ctx, sec_path);
    graphics_context_set_stroke_color(ctx, GColorWhite);
    graphics_context_set_compositing_mode(ctx, GCompOpAssignInverted);
    graphics_draw_line(ctx, center, sec_pos);
  }

  // center dot
  graphics_context_set_fill_color(ctx, GColorBlack);
  graphics_fill_circle(ctx, center, DOTS_SIZE);
}
コード例 #30
0
void minute_display_layer_update_callback(Layer *me, GContext* ctx) {
	(void)me;
    
	PblTm t;
	get_time(&t);
    
	unsigned int angle = (t.tm_min * 6) + (t.tm_sec / 10);
	gpath_rotate_to(&minute_hand_path, (TRIG_MAX_ANGLE / 360) * angle);
	
	graphics_context_set_fill_color(ctx, GColorWhite);
	gpath_draw_filled(ctx, &minute_hand_path);
}