コード例 #1
0
static void init() {
  window = window_create();
  
  window_set_background_color(window, GColorWhite);
  #ifdef PBL_SDK_2 
    window_set_fullscreen(window, true);
  #endif
  
  window_set_click_config_provider(window, click_config_provider);
  
  window_set_window_handlers(window, (WindowHandlers) {
    .load = main_window_load,
    .unload = main_window_unload,
  });
  
  window_stack_push(window, true);
  
  platform_path = gpath_create(&platform_path_points);
  gpath_move_to(platform_path, GPoint(53, 156));
}

static void deinit() {
  window_destroy(window);
}

int main(void) {
  init();
  app_event_loop();
  deinit();
  return 0;
}
コード例 #2
0
static void line_layer_draw_callback(Layer *layer, GContext *ctx) {
    GRect bounds = layer_get_bounds(layer);
    graphics_draw_line(ctx, GPoint(0,0), GPoint(bounds.size.w,0));
}
コード例 #3
0
void handle_init(AppContextRef ctx) {
  (void)ctx;
	
  window_init(&window, "KP Sun-Moon-Clock");
  window_stack_push(&window, true /* Animated */);
  window_set_background_color(&window, GColorWhite);

  resource_init_current_app(&APP_RESOURCES);
  font_moon = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_MOON_PHASES_SUBSET_30));
  layer_init(&graphics_sun_layer, window.layer.frame);
  graphics_sun_layer.update_proc = &graphics_sun_layer_update_callback;
  layer_add_child(&window.layer, &graphics_sun_layer);

  rotbmp_pair_init_container(RESOURCE_ID_IMAGE_WATCHFACE_WHITE, RESOURCE_ID_IMAGE_WATCHFACE_BLACK, &watchface_container);
  layer_add_child(&graphics_sun_layer, &watchface_container.layer.layer);
  watchface_container.layer.layer.frame.origin.x = (144/2) - (watchface_container.layer.layer.frame.size.w/2);
  watchface_container.layer.layer.frame.origin.y = (168/2) - (watchface_container.layer.layer.frame.size.h/2);

  text_layer_init(&text_time_layer, window.layer.frame);
  text_layer_set_text_color(&text_time_layer, GColorBlack);
  text_layer_set_background_color(&text_time_layer, GColorClear);
  layer_set_frame(&text_time_layer.layer, GRect(0, 35, 144, 30));
  text_layer_set_font(&text_time_layer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_ROBOTO_CONDENSED_30)));
  layer_add_child(&window.layer, &text_time_layer.layer);

  rotbmp_pair_init_container(RESOURCE_ID_IMAGE_HOUR_WHITE, RESOURCE_ID_IMAGE_HOUR_BLACK, &bitmap_container);
  rotbmp_pair_layer_set_src_ic(&bitmap_container.layer, GPoint(9,56));
  layer_add_child(&window.layer, &bitmap_container.layer.layer);

  text_layer_init(&moonLayer, GRect(0, 100, 144 /* width */, 168-115 /* height */));
  text_layer_set_text_color(&moonLayer, GColorWhite);
  text_layer_set_background_color(&moonLayer, GColorClear);
  text_layer_set_font(&moonLayer, font_moon);
  text_layer_set_text_alignment(&moonLayer, GTextAlignmentCenter);

  handle_day(ctx, NULL);
	
  layer_add_child(&window.layer, &moonLayer.layer);
	
PblTm t;
  get_time(&t);
  rotbmp_pair_layer_set_angle(&bitmap_container.layer, TRIG_MAX_ANGLE * get24HourAngle(t.tm_hour, t.tm_min));
  bitmap_container.layer.layer.frame.origin.x = (144/2) - (bitmap_container.layer.layer.frame.size.w/2);
  bitmap_container.layer.layer.frame.origin.y = (168/2) - (bitmap_container.layer.layer.frame.size.h/2);

  //Day of Week text
  text_layer_init(&dow_layer, GRect(0, 0, 144, 127+26));
  text_layer_set_text_color(&dow_layer, GColorWhite);
  text_layer_set_background_color(&dow_layer, GColorClear);
  text_layer_set_font(&dow_layer, fonts_get_system_font(FONT_KEY_GOTHIC_14_BOLD));
  text_layer_set_text_alignment(&dow_layer, GTextAlignmentLeft);
  text_layer_set_text(&dow_layer, "xxx");
  layer_add_child(&window.layer, &dow_layer.layer);

  //Day of the Month text
  text_layer_init(&dom_layer, GRect(0, 10, 144, 137+26));
  text_layer_set_text_color(&dom_layer, GColorWhite);
  text_layer_set_background_color(&dom_layer, GColorClear);
  text_layer_set_font(&dom_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24));
  text_layer_set_text_alignment(&dom_layer, GTextAlignmentLeft);
  text_layer_set_text(&dom_layer, "00");
  layer_add_child(&window.layer, &dom_layer.layer);
	
  //Month Text
  text_layer_init(&mon_layer, GRect(0, 0, 144, 127+26));
  text_layer_set_text_color(&mon_layer, GColorWhite);
  text_layer_set_background_color(&mon_layer, GColorClear);
  text_layer_set_font(&mon_layer, fonts_get_system_font(FONT_KEY_GOTHIC_14_BOLD));
  text_layer_set_text_alignment(&mon_layer, GTextAlignmentRight);
  text_layer_set_text(&mon_layer, "xxx");
  layer_add_child(&window.layer, &mon_layer.layer);

  //Year Number text
  text_layer_init(&yon_layer, GRect(0, 10, 144, 137+26));
  text_layer_set_text_color(&yon_layer, GColorWhite);
  text_layer_set_background_color(&yon_layer, GColorClear);
  text_layer_set_font(&yon_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24));
  text_layer_set_text_alignment(&yon_layer, GTextAlignmentRight);
  text_layer_set_text(&yon_layer, "00");
  layer_add_child(&window.layer, &yon_layer.layer); 	

  //Sunrise Text 
  text_layer_init(&text_sunrise_layer, window.layer.frame);
  text_layer_set_text_color(&text_sunrise_layer, GColorWhite);
  text_layer_set_background_color(&text_sunrise_layer, GColorClear);
  layer_set_frame(&text_sunrise_layer.layer, GRect(0, 145, 144, 30));
  text_layer_set_font(&text_sunrise_layer, fonts_get_system_font(FONT_KEY_GOTHIC_18));
  layer_add_child(&window.layer, &text_sunrise_layer.layer);

 //Sunset Text
  text_layer_init(&text_sunset_layer, window.layer.frame);
  text_layer_set_text_color(&text_sunset_layer, GColorWhite);
  text_layer_set_background_color(&text_sunset_layer, GColorClear);
  layer_set_frame(&text_sunset_layer.layer, GRect(0, 145, 144, 30));
  text_layer_set_font(&text_sunset_layer, fonts_get_system_font(FONT_KEY_GOTHIC_18));
  layer_add_child(&window.layer, &text_sunset_layer.layer); 

  updateDayAndNightInfo();
}
コード例 #4
0
ファイル: chunk.c プロジェクト: vekexasia/Chunk-Weather-v2.0
// HORIZONTAL LINE //
void update_background_callback(Layer *me, GContext* ctx) { 
	graphics_context_set_stroke_color(ctx, GColorBlack);
	graphics_draw_line(ctx, GPoint(0, 83), GPoint(144, 83));		
}
コード例 #5
0
ファイル: GraphDisplay.cpp プロジェクト: skothr/SoundSandbox
GPoint GraphDisplay::absoluteToGraphPoint(APoint a_point) const
{
	//Scale, then translate
	return GPoint(absoluteToGraphXP(a_point.x), absoluteToGraphYP(a_point.y));
}
コード例 #6
0
GPoint random_point_roughly_in_screen(int margin, int padding) {
  GRect window_bounds = layer_get_bounds(window_get_root_layer(window));
  return GPoint(random_in_range(0-margin+padding, window_bounds.size.w+1+margin-padding),
		random_in_range(0-margin+padding, window_bounds.size.h+1+margin-padding));
}
コード例 #7
0
ファイル: ServiceDB.cpp プロジェクト: Almamu/evemu_apocrypha
bool ServiceDB::GetStationInfo(uint32 stationID, uint32 *systemID, uint32 *constellationID, uint32 *regionID, GPoint *position, GPoint *dockPosition, GVector *dockOrientation) {
    if(       systemID == NULL
        && constellationID == NULL
        && regionID == NULL
        && position == NULL
        && dockPosition == NULL
        && dockOrientation == NULL
    )
        return true;

    DBQueryResult res;
    if(!sDatabase.RunQuery(res,
        "SELECT"
        " solarSystemID,"
        " constellationID,"
        " regionID,"
        " x, y, z,"
        " dockEntryX, dockEntryY, dockEntryZ,"
        " dockOrientationX, dockOrientationY, dockOrientationZ"
        " FROM staStations"
        " LEFT JOIN staStationTypes USING (stationTypeID)"
        " WHERE stationID = %u",
        stationID))
    {
        _log(DATABASE__ERROR, "Failed to query info for station %u: %s.", stationID, res.error.c_str());
        return false;
    }

    DBResultRow row;
    if(!res.GetRow(row)) {
        _log(DATABASE__ERROR, "Failed to query info for station %u: Station not found.", stationID);
        return false;
    }

    if(systemID != NULL)
        *systemID = row.GetUInt(0);
    if(constellationID != NULL)
        *constellationID = row.GetUInt(1);
    if(regionID != NULL)
        *regionID = row.GetUInt(2);
    if(position != NULL)
        *position = GPoint(
            row.GetDouble(3),
            row.GetDouble(4),
            row.GetDouble(5)
        );
    if(dockPosition != NULL)
        *dockPosition = GPoint(
            row.GetDouble(3) + row.GetDouble(6),
            row.GetDouble(4) + row.GetDouble(7),
            row.GetDouble(5) + row.GetDouble(8)
        );
    if(dockOrientation != NULL) {
        *dockOrientation = GVector(
            row.GetDouble(9),
            row.GetDouble(10),
            row.GetDouble(11)
        );
        // as it's direction, it should be normalized
        dockOrientation->normalize();
    }

    return true;
}
コード例 #8
0
void handle_init(AppContextRef ctx) {
  (void)ctx;

  window_init(&window, "Circling Hours");
  window_stack_push(&window, true);
	window_set_background_color(&window, GColorBlack);

  resource_init_current_app(&APP_RESOURCES);

	first_run = "true";
	hours_word.old_text = hours_word.text;

  bmp_init_container(RESOURCE_ID_IMAGE_HOUR_BG, &background_image_container);
  layer_add_child(&window.layer, &background_image_container.layer.layer);


//	font_minutes = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_ARIAL_BLACK_50));
//	text_layer(&font_minutes_word, GRect(0, 40, 143, 100), font_minutes);
/*  add to resource_map.json:
  {
				"type":"font",
				"defName":"FONT_ARIAL_BLACK_50",
				"file":"fonts/Arial-Black.ttf"
  }
*/

// much less space needed because font is built in
//	font_minutes = fonts_get_system_font(FONT_KEY_GOTHAM_42_MEDIUM_NUMBERS);
	font_minutes = fonts_get_system_font(FONT_KEY_GOTHAM_42_BOLD);
	text_layer(&font_minutes_word, GRect(0, 58, 143, 50), font_minutes);

	text_layer_set_text_alignment(&font_minutes_word.layer, GTextAlignmentCenter);
	
	rotbmp_init_container(RESOURCE_ID_IMAGE_HOUR_1, &hour_image_container_1);
	rotbmp_init_container(RESOURCE_ID_IMAGE_HOUR_2, &hour_image_container_2);
	rotbmp_init_container(RESOURCE_ID_IMAGE_HOUR_3, &hour_image_container_3);
	rotbmp_init_container(RESOURCE_ID_IMAGE_HOUR_4, &hour_image_container_4);
	rotbmp_init_container(RESOURCE_ID_IMAGE_HOUR_5, &hour_image_container_5);
	rotbmp_init_container(RESOURCE_ID_IMAGE_HOUR_6, &hour_image_container_6);
	rotbmp_init_container(RESOURCE_ID_IMAGE_HOUR_7, &hour_image_container_7);
	rotbmp_init_container(RESOURCE_ID_IMAGE_HOUR_8, &hour_image_container_8);
	rotbmp_init_container(RESOURCE_ID_IMAGE_HOUR_9, &hour_image_container_9);
	rotbmp_init_container(RESOURCE_ID_IMAGE_HOUR_10, &hour_image_container_10);
	rotbmp_init_container(RESOURCE_ID_IMAGE_HOUR_11, &hour_image_container_11);
	rotbmp_init_container(RESOURCE_ID_IMAGE_HOUR_12, &hour_image_container_12);

	//GCompOpAssign, GCompOpAssignInverted, GCompOpOr, GCompOpAnd, GCompOpClear
	GCompOp mode = GCompOpAssign;
  hour_image_container_1.layer.compositing_mode = mode;
  hour_image_container_2.layer.compositing_mode = mode;
  hour_image_container_3.layer.compositing_mode = mode;
  hour_image_container_4.layer.compositing_mode = mode;
  hour_image_container_5.layer.compositing_mode = mode;
  hour_image_container_6.layer.compositing_mode = mode;
  hour_image_container_7.layer.compositing_mode = mode;
  hour_image_container_8.layer.compositing_mode = mode;
  hour_image_container_9.layer.compositing_mode = mode;
  hour_image_container_10.layer.compositing_mode = mode;
  hour_image_container_11.layer.compositing_mode = mode;
  hour_image_container_12.layer.compositing_mode = mode;

	//GPoint pointxy = GPoint(-73, -75);
	GPoint pointxy = GPoint(14, 70);
  rot_bitmap_set_src_ic(&hour_image_container_1.layer, pointxy);
  rot_bitmap_set_src_ic(&hour_image_container_2.layer, pointxy);
  rot_bitmap_set_src_ic(&hour_image_container_3.layer, pointxy);
  rot_bitmap_set_src_ic(&hour_image_container_4.layer, pointxy);
  rot_bitmap_set_src_ic(&hour_image_container_5.layer, pointxy);
  rot_bitmap_set_src_ic(&hour_image_container_6.layer, pointxy);
  rot_bitmap_set_src_ic(&hour_image_container_7.layer, pointxy);
  rot_bitmap_set_src_ic(&hour_image_container_8.layer, pointxy);
  rot_bitmap_set_src_ic(&hour_image_container_9.layer, pointxy);
  rot_bitmap_set_src_ic(&hour_image_container_10.layer, pointxy);
  rot_bitmap_set_src_ic(&hour_image_container_11.layer, pointxy);
  rot_bitmap_set_src_ic(&hour_image_container_12.layer, pointxy);

  layer_add_child(&window.layer, &hour_image_container_1.layer.layer);
  layer_add_child(&window.layer, &hour_image_container_2.layer.layer);
  layer_add_child(&window.layer, &hour_image_container_3.layer.layer);
  layer_add_child(&window.layer, &hour_image_container_4.layer.layer);
  layer_add_child(&window.layer, &hour_image_container_5.layer.layer);
  layer_add_child(&window.layer, &hour_image_container_6.layer.layer);
  layer_add_child(&window.layer, &hour_image_container_7.layer.layer);
  layer_add_child(&window.layer, &hour_image_container_8.layer.layer);
  layer_add_child(&window.layer, &hour_image_container_9.layer.layer);
  layer_add_child(&window.layer, &hour_image_container_10.layer.layer);
  layer_add_child(&window.layer, &hour_image_container_11.layer.layer);
  layer_add_child(&window.layer, &hour_image_container_12.layer.layer);


  update_hand_positions();


}
コード例 #9
0
ファイル: gatekeeper.c プロジェクト: CupricWolf/Gatekeeper
void handle_init(AppContextRef ctx) {
  (void)ctx;

  window_init(&window, "Brains Watch");
  window_stack_push(&window, true);

  resource_init_current_app(&APP_RESOURCES);

//    rotbmp_pair_init_container(RESOURCE_ID_IMAGE_PANDA_WHITE, RESOURCE_ID_IMAGE_PANDA_BLACK, &bitmap_container);


  // Set up a layer for the static watch face background
  bmp_init_container(RESOURCE_ID_IMAGE_BACKGROUND, &background_image_container);
  layer_add_child(&window.layer, &background_image_container.layer.layer);


dice = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_VISITOR_16));

  text_layer_init(&date_layer, GRect(53, 105, 40, 40));
  text_layer_set_text_alignment(&date_layer, GTextAlignmentCenter);
  text_layer_set_text_color(&date_layer, GColorBlack);
  text_layer_set_background_color(&date_layer, GColorClear);
  text_layer_set_font(&date_layer, dice);
  layer_add_child(&window.layer, &date_layer.layer);

 PblTm ti;
 get_time(&ti);
  
 string_format_time(date_text, sizeof(date_text), "%d", &ti);
 text_layer_set_text(&date_layer, date_text);




  // Set up a layer for the hour hand
  rotbmp_init_container(RESOURCE_ID_IMAGE_HOUR_HAND, &hour_hand_image_container);

    //  hour_hand_image_container.layer.compositing_mode = GCompOpClear;

  rot_bitmap_set_src_ic(&hour_hand_image_container.layer, GPoint(3, 42));

  layer_add_child(&window.layer, &hour_hand_image_container.layer.layer);


  // Set up a layer for the minute hand
  rotbmp_init_container(RESOURCE_ID_IMAGE_MINUTE_HAND, &minute_hand_image_container);

 // minute_hand_image_container.layer.compositing_mode = GCompOpClear;

  rot_bitmap_set_src_ic(&minute_hand_image_container.layer, GPoint(3, 58));

  layer_add_child(&window.layer, &minute_hand_image_container.layer.layer);






  update_hand_positions();


  // Setup the black and white circle in the centre of the watch face
  // (We use a bitmap rather than just drawing it because it means not having
  // to stuff around with working out the circle center etc.)
  rotbmp_pair_init_container(RESOURCE_ID_IMAGE_CENTER_CIRCLE_WHITE, RESOURCE_ID_IMAGE_CENTER_CIRCLE_BLACK,
			     &center_circle_image_container);

  // TODO: Do this properly with a GRect().
  // (144 = screen width, 168 = screen height)
  center_circle_image_container.layer.layer.frame.origin.x = (144/2) - (center_circle_image_container.layer.layer.frame.size.w/2);
  center_circle_image_container.layer.layer.frame.origin.y = (168/2) - (center_circle_image_container.layer.layer.frame.size.h/2);


  layer_add_child(&window.layer, &center_circle_image_container.layer.layer);

  layer_init(&second_display_layer, window.layer.frame);
  second_display_layer.update_proc = &second_display_layer_update_callback;
  layer_add_child(&window.layer, &second_display_layer);

}
コード例 #10
0
ファイル: text.c プロジェクト: mereed/pebbleface-mixup
static void set_container_image(GBitmap **bmp_image, BitmapLayer *bmp_layer, const int resource_id, GPoint origin) {
  GBitmap *old_image = *bmp_image;
  *bmp_image = gbitmap_create_with_resource(resource_id);
  GRect frame = (GRect) {
    .origin = origin,
    .size = (*bmp_image)->bounds.size
  };
  bitmap_layer_set_bitmap(bmp_layer, *bmp_image);
  layer_set_frame(bitmap_layer_get_layer(bmp_layer), frame);
  gbitmap_destroy(old_image);
}

static void update_hours(struct tm *tick_time) {

  if(appStarted && hourlyvibe) {
    //vibe!
    vibes_short_pulse();
  }
}

static void update_minutes(struct tm *tick_time) {
	
  set_container_image(&time_digits_images[2], time_digits_layers[2], BIG_DIGIT_IMAGE_RESOURCE_IDS[tick_time->tm_min/10], GPoint(6, 6));
  set_container_image(&time_digits_images[3], time_digits_layers[3], BIG_DIGIT_IMAGE_RESOURCE_IDS[tick_time->tm_min%10], GPoint(75, 6));
}
コード例 #11
0
ファイル: moonphase.c プロジェクト: bldewolf/pebble-moonphase
void moon_LayerUpdateProc(struct Layer *layer, GContext *ctx) {
/*
	GPath shadow;
	GPathInfo shadow_points = {
		5,
		(GPoint []) {
			{0, 0},
			{0, 0},
			{0, 0},
			{0, 0},
			{0, 0},
		}
	};
*/
	int radius;
	int x, y, error;
	int mx, my;
	GPoint center;
	int edge;

	if(phase == 1) {
		graphics_context_set_fill_color(ctx, GColorBlack);
		graphics_fill_rect(ctx, GRect(0, 0, layer->frame.size.w, layer->frame.size.h), 0, GCornerNone);
		return;
	}
	if(phase == 15)
		return;
	graphics_context_set_fill_color(ctx, GColorWhite);
	center.x = layer->frame.size.w / 2;
	center.y = layer->frame.size.h / 2;
	radius = (layer->frame.size.w > layer->frame.size.h ?
		layer->frame.size.h / 2 :
		layer->frame.size.w / 2) - 4;
//	graphics_fill_circle(ctx, center, radius);

	graphics_context_set_stroke_color(ctx, GColorBlack);
	// circle algo from: http://en.wikipedia.org/wiki/Midpoint_circle_algorithm
	// Even though I studied it in school, it still feels like magic
	error = -radius;
	x = radius;
	y = 0;
	while ( x >= y) {
		if(phase < 15) {
			mx = x * (cos_lookup(TRIG_MAX_ANGLE * (phase / 28.0)) / (0xffff * 1.0));
			my = y * (cos_lookup(TRIG_MAX_ANGLE * (phase / 28.0)) / (0xffff * 1.0));
			edge = 0;
		}
		if(phase > 15) {
			mx = x * (cos_lookup(TRIG_MAX_ANGLE * ((phase - 15) / 32.0)) / (0xffff * 1.0));
			my = y * (cos_lookup(TRIG_MAX_ANGLE * ((phase - 15) / 32.0)) / (0xffff * 1.0));
			edge = layer->frame.size.w;
		}
		graphics_draw_line(ctx, GPoint(center.x + mx, center.y + y), GPoint(edge, center.y + y));
		graphics_draw_line(ctx, GPoint(center.x + mx, center.y - y), GPoint(edge, center.y - y));
		graphics_draw_line(ctx, GPoint(center.x + my, center.y + x), GPoint(edge, center.y + x));
		graphics_draw_line(ctx, GPoint(center.x + my, center.y - x), GPoint(edge, center.y - x));

		error += y;
		++y;
		error += y;
		if( error >= 0) {
			error -= x;
			--x;
			error -= x;
		}
	}
}
コード例 #12
0
ファイル: Minimalist.c プロジェクト: Jnmattern/Minimalist
void handle_tick(AppContextRef ctx, PebbleTickEvent *e) {
	static GRect clipRect = { {0, 0}, {SCREENW, DIGIT_SIZE} };
	int i, a, digit[4], x;
	
	get_time(&now);
	
#if DRAW_SECONDS
	if (now.tm_min != last.tm_min) {
#endif
#if MINUTES_AT_HOUR_HAND
		now.tm_hour = now.tm_hour%12;
		
		digit[0] = now.tm_min/10;
		digit[1] = now.tm_min%10;

#if WHITE_BACKGROUND
		bmpFill(&bitmap, GColorWhite);
#else
		bmpFill(&bitmap, GColorBlack);
#endif
		
		if (now.tm_hour < 6) {
			a = 30*(now.tm_hour-3) + now.tm_min/2;
			for (i=0;i<2;i++) {
				x = CX + 69 + (i-2)*(DIGIT_SIZE+DIGIT_SPACE);
				bmpSub(&digitBmp[digit[i]].bmp, &bitmap, digitBmp[digit[i]].bmp.bounds, GPoint(x, 0));
			}
			clipRect.origin.x = CX + 69 - 2*(DIGIT_SIZE+DIGIT_SPACE);
		} else {
			a = 30*(now.tm_hour-9) + now.tm_min/2;
			for (i=0;i<2;i++) {
				x = CX - 69 + DIGIT_SPACE + i*(DIGIT_SIZE+DIGIT_SPACE);
				bmpSub(&digitBmp[digit[i]].bmp, &bitmap, digitBmp[digit[i]].bmp.bounds, GPoint(x, 0));
			}
			clipRect.origin.x = CX - 69 + DIGIT_SPACE;
		}
		clipRect.size.w = 2*DIGIT_SIZE + DIGIT_SPACE;
		
#else // MINUTES_AT_HOUR_HAND
		if (clock12) {
			now.tm_hour = now.tm_hour%12;
			if (now.tm_hour == 0) now.tm_hour = 12;
		}
#if HOUR_AT_MINUTE_HAND
		digit[0] = now.tm_hour/10;
		digit[1] = now.tm_hour%10;
#else // HOUR_AT_MINUTE_HAND
		digit[0] = now.tm_hour/10;
		digit[1] = now.tm_hour%10;
		digit[2] = now.tm_min/10;
		digit[3] = now.tm_min%10;
#endif // HOUR_AT_MINUTE_HAND
		
#if WHITE_BACKGROUND
		bmpFill(&bitmap, GColorWhite);
#else
		bmpFill(&bitmap, GColorBlack);
#endif
		
		if (now.tm_min < 30) {
			a = 6*(now.tm_min-15);
#if HOUR_AT_MINUTE_HAND
			for (i=0; i<2; i++) {
				if (i != 0 || digit[i] != 0) {
					x = CX + 69 + (i-2)*(DIGIT_SIZE+DIGIT_SPACE);
					bmpSub(&digitBmp[digit[i]].bmp, &bitmap, digitBmp[digit[i]].bmp.bounds, GPoint(x, 0));
				}
			}
			clipRect.origin.x = CX + 69 - 2*(DIGIT_SIZE+DIGIT_SPACE);
#else // HOUR_AT_MINUTE_HAND
			for (i=0; i<4; i++) {
				if (i != 0 || digit[i] != 0) {
					x = CX-DIGIT_SIZE+(DIGIT_SIZE+DIGIT_SPACE)*i+(DIGIT_SPACE*(i>1));
					bmpSub(&digitBmp[digit[i]].bmp, &bitmap, digitBmp[digit[i]].bmp.bounds, GPoint(x, 0));
				}
			}
			clipRect.origin.x = CX - DIGIT_SIZE;
#endif // HOUR_AT_MINUTE_HAND
		} else {
			a = 6*(now.tm_min-45);
#if HOUR_AT_MINUTE_HAND
			for (i=0; i<2; i++) {
				if (i != 0 || digit[i] != 0) {
					if (digit[0] == 0) {
						x = CX+DIGIT_SPACE+1+DIGIT_SIZE-(DIGIT_SIZE+DIGIT_SPACE)*(5-i)-(DIGIT_SPACE*(i<2));
					} else {
						x = CX+DIGIT_SPACE+1+DIGIT_SIZE-(DIGIT_SIZE+DIGIT_SPACE)*(4-i)-(DIGIT_SPACE*(i<2));
					}
					bmpSub(&digitBmp[digit[i]].bmp, &bitmap, digitBmp[digit[i]].bmp.bounds, GPoint(x, 0));
				}
			}
			clipRect.origin.x = CX - 4*DIGIT_SPACE - 3*DIGIT_SIZE + 1;
#else // HOUR_AT_MINUTE_HAND
			for (i=0; i<4; i++) {
				if (i != 0 || digit[i] != 0) {
					if (digit[0] == 0) {
						x = CX+DIGIT_SPACE+1+DIGIT_SIZE-(DIGIT_SIZE+DIGIT_SPACE)*(5-i)-(DIGIT_SPACE*(i<2));
					} else {
						x = CX+DIGIT_SPACE+1+DIGIT_SIZE-(DIGIT_SIZE+DIGIT_SPACE)*(4-i)-(DIGIT_SPACE*(i<2));
					}
					bmpSub(&digitBmp[digit[i]].bmp, &bitmap, digitBmp[digit[i]].bmp.bounds, GPoint(x, 0));
				}
			}
			clipRect.origin.x = CX - 4*DIGIT_SPACE - 3*DIGIT_SIZE + 1;
#endif // HOUR_AT_MINUTE_HAND
		}
		clipRect.size.w = 4*(DIGIT_SIZE + DIGIT_SPACE);
		
#endif // HOUR_AT_MINUTE_HAND
		bmpFill(&bitmap2, GColorBlack);
#if WHITE_BACKGROUND
		bmpFillCircle(&bitmap2, center, radius-1, GColorWhite);
#endif

		bmpRotate(&bitmap, &bitmap2, a, &clipRect, grect_center_point(&bitmap.bounds), GPoint(0,CX-bitmap.bounds.size.h/2));
		
		bmpDrawArc(&bitmap2, center, radius, 2, 0, 360, GColorWhite);
#if DRAW_SECONDS
		if (last.tm_hour != -1) {
			drawSec(&bitmap2, center, 267, 273, GColorBlack);
		}
	} else {
		la1 = (267+6*last.tm_sec)%360;
		la2 = la1+6;
		a1 = (267+6*now.tm_sec)%360;
		a2 = a1+6;
		drawSec(&bitmap2, center, la1, la2, GColorWhite);
		drawSec(&bitmap2, center, a1, a2, GColorBlack);
	}
#endif
	
	layer_mark_dirty(&layer);
	
	last = now;
}
コード例 #13
0
ファイル: main.c プロジェクト: gerryk/ActiveHour
static void draw_proc(Layer *layer, GContext *ctx) {
  srand(time(NULL));  // For screenshots
  GRect bounds = layer_get_bounds(layer);
  GPoint center = grect_center_point(&bounds);
  
  int lastMin = 0;
  if (SCREENSHOT_RUN) {
    lastMin = s_last_time.seconds;  // For screenshots
  } else {
    lastMin = s_last_time.minutes;  // For real
  }

  for (int m = 0; m <= 59; m++) {
    if (m <= lastMin) {
      graphics_context_set_fill_color(ctx, getDotMainColor());
    } else {
      graphics_context_set_fill_color(ctx, getDotDarkColor());
    }
    
    int v = DOT_DISTANCE;
    
    int numDots = s_dotArray[m];
    
    if (m == lastMin || SCREENSHOT_RUN) {
      numDots = getNumDots();
      s_dotArray[m] = numDots;
    } else if (numDots == 0 && m <= lastMin) {
      numDots = 1;
    }

    // For each dot
    for (int i = 0; i < numDots; i++) {

      // Draw dot
      for(int y = 0; y < 1; y++) {
        for(int x = 0; x < 1; x++) {
          GPoint point = (GPoint) {
            .x = (int16_t)(sin_lookup(TRIG_MAX_ANGLE * m / 60) * (int32_t)(v) / TRIG_MAX_RATIO) + center.x,
            .y = (int16_t)(-cos_lookup(TRIG_MAX_ANGLE * m / 60) * (int32_t)(v) / TRIG_MAX_RATIO) + center.y,
          };
          graphics_fill_circle(ctx, GPoint(point.x + x, point.y + y), s_dotSize);
        }
      }
      
      // Draw next dot farther away
      v += DOT_SPACING;
    }
  }
  
  if (config_get(PERSIST_KEY_WEATHER) && hasWeather) {
    // Get weather "minute"
    int m = weatherTemp % 60;
    
    // Get weather dot color
    if (weatherTemp < 0) {
      graphics_context_set_fill_color(ctx, GColorCeleste);
    } else if (weatherTemp < 60) {
      graphics_context_set_fill_color(ctx, GColorMediumAquamarine);
    } else {
      graphics_context_set_fill_color(ctx, GColorOrange);
    }
    
    // Draw dot
    int v = DOT_DISTANCE - DOT_SPACING - 1;
    for(int y = 0; y < 1; y++) {
      for(int x = 0; x < 1; x++) {
        GPoint point = (GPoint) {
          .x = (int16_t)(sin_lookup(TRIG_MAX_ANGLE * m / 60) * (int32_t)(v) / TRIG_MAX_RATIO) + center.x,
          .y = (int16_t)(-cos_lookup(TRIG_MAX_ANGLE * m / 60) * (int32_t)(v) / TRIG_MAX_RATIO) + center.y,
        };
        graphics_fill_circle(ctx, GPoint(point.x + x, point.y + y), s_dotSize);
      }
    }
  }
}

static void health_handler(HealthEventType event, void *context) {
  // Which type of event occured?
  switch(event) {
    case HealthEventSignificantUpdate:
//       APP_LOG(APP_LOG_LEVEL_INFO, "New HealthService HealthEventSignificantUpdate event");
      break;
    case HealthEventMovementUpdate:
      APP_LOG(APP_LOG_LEVEL_INFO, "New HealthService HealthEventMovementUpdate event");
    
      // Mark layer dirty so it updates
      layer_mark_dirty(s_canvas_layer);
      break;
    case HealthEventSleepUpdate:
//       APP_LOG(APP_LOG_LEVEL_INFO, "New HealthService HealthEventSleepUpdate event");
      break;
  }
}

void comm_init() {
  app_message_register_inbox_received(in_recv_handler);
  
  // Register callbacks
  app_message_register_inbox_dropped(inbox_dropped_callback);
  app_message_register_outbox_failed(outbox_failed_callback);
  app_message_register_outbox_sent(outbox_sent_callback);
  
  app_message_open(app_message_inbox_size_maximum(), app_message_outbox_size_maximum());
}
コード例 #14
0
static void update_plat() {
  layer_mark_dirty(window_get_root_layer(window));
  gpath_move_to(platform_path, GPoint(platform_x_pos, 156));
}
コード例 #15
0
void draw_particle(GContext* ctx, int i) {
  graphics_fill_circle(ctx, GPoint((int)particles[i].position.x,
                                   (int)particles[i].position.y),
                       particles[i].size);
}
コード例 #16
0
static void disc_draw(GContext *ctx, Disc *disc) {
  graphics_context_set_fill_color(ctx, GColorWhite);
  graphics_fill_circle(ctx, GPoint(disc->pos.x, disc->pos.y), disc->radius);
}
コード例 #17
0
GPoint random_point_in_screen() {
  GRect window_bounds = layer_get_bounds(window_get_root_layer(window));
  return GPoint(random_in_range(0, window_bounds.size.w+1),
		random_in_range(0, window_bounds.size.h+1));
}
コード例 #18
0
ファイル: mainWindow.c プロジェクト: Developer626/RockCrush
/**
 * Iterate the game board and markup for found combinations
 **/
bool findMatches() {
  // One look for explosions

  bool matchesFound = false;

  // Double or singe black? Must be a switch
  if (s_switch.first.x != -1) {
    if (s_pieces[XYp(s_switch.first)].colour == kBlack && s_pieces[XYp(s_switch.second)].colour == kBlack) { // double black
      explode(kBOOM, s_switch.second.x, s_switch.second.y, 0);
      matchesFound = true;
    } else if (s_pieces[XYp(s_switch.first)].colour == kWhite && s_pieces[XYp(s_switch.second)].colour == kBlack) { //White black
      explode(kCross, s_switch.second.x, s_switch.second.y, 0);
      matchesFound = true;
    } else if (s_pieces[XYp(s_switch.first)].colour == kBlack && s_pieces[XYp(s_switch.second)].colour == kWhite) { //Black white
      explode(kCross, s_switch.second.x, s_switch.second.y, 0);
      matchesFound = true;
    } else if (s_pieces[XYp(s_switch.first)].colour == kBlack) { // Single black A
      explode(kMiniBoom, s_switch.second.x, s_switch.second.y, s_pieces[XYp(s_switch.second)].colour);
      s_pieces[XYp(s_switch.first)].exploded = true;
      matchesFound = true;
    } else if (s_pieces[XYp(s_switch.second)].colour == kBlack) { // Single black B
      explode(kMiniBoom, s_switch.first.x, s_switch.first.y, s_pieces[XYp(s_switch.first)].colour);
      s_pieces[XYp(s_switch.second)].exploded = true;
      matchesFound = true;
    }
  }

  // Markup the board
  for (int dir = 0; dir < 2; ++dir) { // x or y

    int xStop = 0, yStop = 0, max = 0;
    if (dir == 0) { // go along x, look in y
      yStop = 2;
      max = BOARD_PIECES_Y;
    } else { // go along y, look in x
      xStop = 2;
      max = BOARD_PIECES_X;
    }

    for (int x=0; x < BOARD_PIECES_X - xStop; ++x) {
      for (int y=0; y < BOARD_PIECES_Y - yStop; ++y) {

        // Find a run
        int runSize = 1, nextX, nextY;
        if (dir == 0) {
          nextX = x;
          nextY = y+1;
        } else {
          nextX = x+1;
          nextY = y;
        }

        Colour_t runColour = s_pieces[XY(x,y)].colour;
        while (1) {
          if (runColour == kWhite) runColour = s_pieces[XY(nextX,nextY)].colour; // If first colour(s) were white - need to update to know colour of run

          if      ( s_pieces[XY(nextX,nextY)].colour == runColour) {} // Progress - Same colour
          else if ( s_pieces[XY(nextX,nextY)].colour == kWhite ) {} // Progress - Wildcard, white always matches
          else break; // Square is different colour - stop here

          ++runSize; // Square accepted
          if (dir == 0) {
            if (++nextY == max) break; // This is where the asymmetric grid bug was hiding before, only compare one
          } else {
            if (++nextX == max) break;
          }
        }

        if (runSize > 4) {
          explode(kColourBoom, 0, 0, runColour); // do colour BOOM
          matchesFound = true;
        } else if (runSize > 2) {
          if (runColour == kBlack) { // Special - three blacks? Very rare, but deserves a big explosion! Like an extended black-black match
            //APP_LOG(APP_LOG_LEVEL_DEBUG,"MATCH-3-or-4-BLACK!!!!");
            if  (dir == 0) for (int P=y; P < nextY; ++P) explode(kBOOM, x, P, 0);
            else           for (int P=x; P < nextX; ++P) explode(kBOOM, P, y, 0);
            matchesFound = true;
          } else {
            //APP_LOG(APP_LOG_LEVEL_DEBUG,"MATCH-3-or-4");
            runSize == 3 ? score(kMatch3, 0) : score(kMatch4, 0);
            if  (dir == 0) for (int P=y; P < nextY; ++P) s_pieces[XY(x,P)].match++; // A piece can be matched up to twice
            else           for (int P=x; P < nextX; ++P) s_pieces[XY(P,y)].match++;
            matchesFound = true;
          }
        }

        //Promote white
        if (runSize == 4) { // We promote the switched piece if user instagated, or the final piece if part of a cascade
          //APP_LOG(APP_LOG_LEVEL_DEBUG,"PROMOTE WHITE");
          if  (dir == 0) {
            for (int P=y; P < nextY; ++P) {
              if (isSwitch(x,P) || P == nextY-1) {
                s_pieces[XY(x,P)].promoteFlag = kWhite;
                break;
              }
            }
          } else {
            for (int P=x; P < nextX; ++P) {
              if (isSwitch(P,y) || P == nextX-1) {
                s_pieces[XY(P,y)].promoteFlag = kWhite;
                break;
              }
            }
          }
        }

        // Skip over the cells we've just dealed with (remember we're at the end of the loop so going to get a +1 anyway)
        if      (dir == 0 && runSize > 2) y += (runSize-1);
        else if (dir == 1 && runSize > 2) x += (runSize-1);
      }
    }
  }

  // Promote black
  for (int x=0; x < BOARD_PIECES_X; ++x) {
    for (int y=0; y < BOARD_PIECES_Y; ++y) {
      if (s_pieces[XY(x,y)].match == kMatchedTwice) {
        score(kMatchT, 0); // This is a bonus on top of the 2x match-3 / match-4s
        s_pieces[XY(x,y)].promoteFlag = kBlack; // This can in theory overwrite a promote white command
        //APP_LOG(APP_LOG_LEVEL_DEBUG,"PROMOTE BLACK");
      }
    }
  }

  //remember to unset switches so they don't trigger on iterations of this phase
  s_switch.first = GPoint(-1,-1);
  s_switch.second = GPoint(-1,-1);

  if (matchesFound == true) { // Remove and repeat, continue to cascade until no runs remain
    s_gameState = kFlashRemoved;
    if (s_currentRun < ANIM_FPS/3) ++s_currentRun; // This makes things faster if more matches are found
  } else { // No more runs
     s_gameState = kFindNextMove; // Let the comp try and find a valid move, if any
   }

  return false; // don't redraw, nothing graphical
}
コード例 #19
0
ファイル: meshGEdge.cpp プロジェクト: kevinr2763/gmsh
void meshGEdge::operator() (GEdge *ge)
{
#if defined(HAVE_ANN)
  FieldManager *fields = ge->model()->getFields();
  BoundaryLayerField *blf = 0;
  Field *bl_field = fields->get(fields->getBoundaryLayerField());
  blf = dynamic_cast<BoundaryLayerField*> (bl_field);
#else
  bool blf = false;
#endif

  ge->model()->setCurrentMeshEntity(ge);

  if(ge->geomType() == GEntity::DiscreteCurve) return;
  if(ge->geomType() == GEntity::BoundaryLayerCurve) return;
  if(ge->meshAttributes.method == MESH_NONE) return;
  if(CTX::instance()->mesh.meshOnlyVisible && !ge->getVisibility()) return;

  // look if we are doing the STL triangulation
  std::vector<MVertex*> &mesh_vertices = ge->mesh_vertices ;
  std::vector<MLine*> &lines = ge->lines ;

  deMeshGEdge dem;
  dem(ge);

  if(MeshExtrudedCurve(ge)) return;

  if (ge->meshMaster() != ge){
    GEdge *gef = dynamic_cast<GEdge*> (ge->meshMaster());
    if (gef->meshStatistics.status == GEdge::PENDING) return;
    Msg::Info("Meshing curve %d (%s) as a copy of %d", ge->tag(),
              ge->getTypeString().c_str(), ge->meshMaster()->tag());
    copyMesh(gef, ge, ge->masterOrientation);
    ge->meshStatistics.status = GEdge::DONE;
    return;
  }

  Msg::Info("Meshing curve %d (%s)", ge->tag(), ge->getTypeString().c_str());

  // compute bounds
  Range<double> bounds = ge->parBounds(0);
  double t_begin = bounds.low();
  double t_end = bounds.high();

  // first compute the length of the curve by integrating one
  double length;
  std::vector<IntPoint> Points;
  if(ge->geomType() == GEntity::Line &&
      ge->getBeginVertex() == ge->getEndVertex() &&
      //do not consider closed lines as degenerated
      (ge->position(0.5) - ge->getBeginVertex()->xyz()).norm() < CTX::instance()->geom.tolerance)
    length = 0.; // special case t avoid infinite loop in integration
  else
    length = Integration(ge, t_begin, t_end, F_One, Points, 1.e-8 * CTX::instance()->lc);
  ge->setLength(length);
  Points.clear();

  if(length < CTX::instance()->mesh.toleranceEdgeLength){
    ge->setTooSmall(true);
  }

  // Integrate detJ/lc du
  double a;
  int N;
  if(length == 0. && CTX::instance()->mesh.toleranceEdgeLength == 0.){
    Msg::Warning("Curve %d has a zero length", ge->tag());
    a = 0.;
    N = 1;
  }
  else if(ge->degenerate(0)){
    a = 0.;
    N = 1;
  }
  else if(ge->meshAttributes.method == MESH_TRANSFINITE){
    a = Integration(ge, t_begin, t_end, F_Transfinite, Points,
                    CTX::instance()->mesh.lcIntegrationPrecision);
    N = ge->meshAttributes.nbPointsTransfinite;
    if(CTX::instance()->mesh.flexibleTransfinite && CTX::instance()->mesh.lcFactor)
      N /= CTX::instance()->mesh.lcFactor;
  }
  else{
    if (CTX::instance()->mesh.algo2d == ALGO_2D_BAMG || blf){
      a = Integration(ge, t_begin, t_end, F_Lc_aniso, Points,
                      CTX::instance()->mesh.lcIntegrationPrecision);
    }
    else{
       a = Integration(ge, t_begin, t_end, F_Lc, Points,
                      CTX::instance()->mesh.lcIntegrationPrecision);
    }

    // we should maybe provide an option to disable the smoothing
    for (unsigned int i = 0; i < Points.size(); i++){
      IntPoint &pt = Points[i];
      SVector3 der = ge->firstDer(pt.t);
      pt.xp = der.norm();
    }
    a = smoothPrimitive(ge, sqrt(CTX::instance()->mesh.smoothRatio), Points);
    N = std::max(ge->minimumMeshSegments() + 1, (int)(a + 1.99));
  }

  // force odd number of points if blossom is used for recombination
  if((ge->meshAttributes.method != MESH_TRANSFINITE ||
      CTX::instance()->mesh.flexibleTransfinite) &&
     CTX::instance()->mesh.algoRecombine != 0){
    if(CTX::instance()->mesh.recombineAll){
      if (N % 2 == 0) N++;
      if (CTX::instance()->mesh.algoRecombine == 2)
	N = increaseN(N);
    }
    else{
      std::list<GFace*> faces = ge->faces();
      for(std::list<GFace*>::iterator it = faces.begin(); it != faces.end(); it++){
        if((*it)->meshAttributes.recombine){
	  if (N % 2 == 0) N ++;
	  if (CTX::instance()->mesh.algoRecombine == 2)
	    N = increaseN(N);
          break;
        }
      }
    }
  }

  // printFandPrimitive(ge->tag(),Points);

  // if the curve is periodic and if the begin vertex is identical to
  // the end vertex and if this vertex has only one model curve
  // adjacent to it, then the vertex is not connecting any other
  // curve. So, the mesh vertex and its associated geom vertex are not
  // necessary at the same location
  GPoint beg_p, end_p;
  if(ge->getBeginVertex() == ge->getEndVertex() &&
     ge->getBeginVertex()->edges().size() == 1){
    end_p = beg_p = ge->point(t_begin);
    Msg::Debug("Meshing periodic closed curve");
  }
  else{
    MVertex *v0 = ge->getBeginVertex()->mesh_vertices[0];
    MVertex *v1 = ge->getEndVertex()->mesh_vertices[0];
    beg_p = GPoint(v0->x(), v0->y(), v0->z());
    end_p = GPoint(v1->x(), v1->y(), v1->z());
  }

  // do not consider the first and the last vertex (those are not
  // classified on this mesh edge)
  if(N > 1){
    const double b = a / (double)(N - 1);
    int count = 1, NUMP = 1;
    IntPoint P1, P2;
    mesh_vertices.resize(N - 2);
    while(NUMP < N - 1) {
      P1 = Points[count - 1];
      P2 = Points[count];
      const double d = (double)NUMP * b;
      if((fabs(P2.p) >= fabs(d)) && (fabs(P1.p) < fabs(d))) {
        double dt = P2.t - P1.t;
        double dlc = P2.lc - P1.lc;
        double dp = P2.p - P1.p;
        double t   = P1.t + dt / dp * (d - P1.p);
        SVector3 der = ge->firstDer(t);
        const double d = norm(der);
        double lc  = d/(P1.lc + dlc / dp * (d - P1.p));
        GPoint V = ge->point(t);
        mesh_vertices[NUMP - 1] = new MEdgeVertex(V.x(), V.y(), V.z(), ge, t, lc);
        NUMP++;
      }
      else {
        count++;
      }
    }
    mesh_vertices.resize(NUMP - 1);
  }

  for(unsigned int i = 0; i < mesh_vertices.size() + 1; i++){
    MVertex *v0 = (i == 0) ?
      ge->getBeginVertex()->mesh_vertices[0] : mesh_vertices[i - 1];
    MVertex *v1 = (i == mesh_vertices.size()) ?
      ge->getEndVertex()->mesh_vertices[0] : mesh_vertices[i];
    lines.push_back(new MLine(v0, v1));
  }

  if(ge->getBeginVertex() == ge->getEndVertex() &&
     ge->getBeginVertex()->edges().size() == 1){
    MVertex *v0 = ge->getBeginVertex()->mesh_vertices[0];
    v0->x() = beg_p.x();
    v0->y() = beg_p.y();
    v0->z() = beg_p.z();
  }

  ge->meshStatistics.status = GEdge::DONE;
}
コード例 #20
0
ファイル: mainWindow.c プロジェクト: Developer626/RockCrush
static void boardUpdateProc(Layer* this_layer, GContext *ctx) {
  GRect b = layer_get_bounds(this_layer);
  graphics_context_set_antialiased(ctx, 0);

  // Fill grey back (white on BW)
  graphics_context_set_fill_color(ctx, COLOR_FALLBACK(GColorLightGray, GColorWhite));
  graphics_context_set_stroke_color(ctx, GColorBlack);
  graphics_fill_rect(ctx, b, 0, GCornersAll);

  // Frame highlight around currently selected square colours is gray w white highlight, BW is wite w black highight
  graphics_context_set_fill_color(ctx, COLOR_FALLBACK(GColorDarkGray, GColorWhite));
  graphics_context_set_stroke_color(ctx, COLOR_FALLBACK(GColorWhite, GColorBlack));
  GRect highlightR = GRect(s_cursor.x*PIECE_PIXELS, s_cursor.y*PIECE_PIXELS, PIECE_PIXELS+1, PIECE_PIXELS+1);
  graphics_fill_rect(ctx, highlightR, 0, GCornersAll);
  graphics_draw_rect(ctx, highlightR);

  // Draw all board shapes
  for (int x = 0; x < BOARD_PIECES_X; ++x) {
    for (int y = 0; y < BOARD_PIECES_Y; ++y) {
      int xy = XY(x,y);
      if (s_gameState == kFlashRemoved && (s_pieces[xy].match != kUnmatched || s_pieces[XY(x,y)].exploded == true)) {
        // Highlight squares which have just been matched
        GColor highlight = COLOR_FALLBACK(GColorRed, GColorBlack);
        if (s_pieces[xy].match == kMatchedTwice) highlight = COLOR_FALLBACK(GColorDarkCandyAppleRed, GColorBlack);
        graphics_context_set_fill_color(ctx, highlight);
        graphics_context_set_stroke_color(ctx, COLOR_FALLBACK(GColorBlack, GColorLightGray));
        highlightR = GRect((s_pieces[xy].loc.x/SUB_PIXEL), (s_pieces[xy].loc.y/SUB_PIXEL), PIECE_PIXELS+1, PIECE_PIXELS+1);
        graphics_fill_rect(ctx, highlightR, 0, GCornersAll);
        graphics_draw_rect(ctx, highlightR);
      }
      // Draw the shape itself
      graphics_context_set_fill_color(ctx, COLOURS[ s_pieces[xy].colour ]);
      if (getShape( s_pieces[xy].colour ) != NULL) {
        static const bool bw = PBL_IF_BW_ELSE(true,false);
        if (bw == false && s_pieces[xy].colour == kBlack ) {
          graphics_context_set_stroke_color(ctx, GColorWhite);
        } else if (bw == true
          && (s_pieces[xy].match != kUnmatched || s_pieces[XY(x,y)].exploded == true)
          && COLOURS[ s_pieces[xy].colour ].argb != GColorWhite.argb ) {
          graphics_context_set_stroke_color(ctx, GColorWhite);
        } else {
          graphics_context_set_stroke_color(ctx, GColorBlack);
        }
        gpath_move_to(getShape( s_pieces[xy].colour ), GPoint(s_pieces[xy].loc.x/SUB_PIXEL, s_pieces[xy].loc.y/SUB_PIXEL));
        gpath_draw_filled(ctx, getShape( s_pieces[xy].colour ));
        gpath_draw_outline(ctx, getShape( s_pieces[xy].colour ));
      } else {
        // White rectangle of debug - we should not have the case where we render a NULL square
        graphics_fill_rect(ctx, GRect((s_pieces[xy].loc.x/SUB_PIXEL)+2, (s_pieces[xy].loc.y/SUB_PIXEL)+2, PIECE_PIXELS-3, PIECE_PIXELS-3), 2, GCornersAll);
      }
    }
  }

  // Move Arrows
  if (s_flashArrows == true && s_gameState == kAwaitingDirection) {
    graphics_context_set_fill_color(ctx, GColorWhite);
    for (int d = 0; d < N_CARDINAL; ++d) {
      gpath_move_to(getArrow(d), GPoint(s_cursor.x * PIECE_PIXELS, s_cursor.y * PIECE_PIXELS));
      gpath_draw_filled(ctx, getArrow(d));
      gpath_draw_outline(ctx, getArrow(d));
    }
  }

  // Cursor
  if (s_tiltMode > 0) {
    graphics_context_set_fill_color(ctx, GColorWhite);
    graphics_context_set_stroke_color(ctx, GColorBlack);
    graphics_fill_circle(ctx, GPoint(s_motionCursor.x/SUB_PIXEL,s_motionCursor.y/SUB_PIXEL), 3);
    graphics_draw_circle(ctx, GPoint(s_motionCursor.x/SUB_PIXEL,s_motionCursor.y/SUB_PIXEL), 3);
  }

  // Next move
  if (s_hintOn && s_availableMove.x != -1 && s_gameState == kIdle && s_hintStatus == true) {
    graphics_context_set_stroke_color(ctx, COLOR_FALLBACK(GColorDarkCandyAppleRed,GColorBlack) );
    graphics_context_set_stroke_width(ctx, 3);
    graphics_draw_circle(ctx, GPoint(s_availableMove.x*PIECE_PIXELS + PIECE_PIXELS/2, s_availableMove.y*PIECE_PIXELS + PIECE_PIXELS/2), PIECE_PIXELS);
    graphics_context_set_stroke_width(ctx, 1);
  }

  // Redo border
  graphics_context_set_stroke_color(ctx, GColorBlack);
  graphics_draw_rect(ctx, b);

}
コード例 #21
0
ファイル: chunk.c プロジェクト: vekexasia/Chunk-Weather-v2.0
void weather_set_icon(WeatherIcon icon) {	
  set_container_image(&mWeatherIcon, mWeatherIconLayer, WEATHER_ICONS[icon], GPoint(9, 2));  

  //Reapply inverter
  setStyle();
}
コード例 #22
0
ファイル: Inbox.c プロジェクト: k9topebble/k9topebble-pebble
void m_MenuLayerDrawRowCallback(GContext *ctx, const Layer *cell_layer, MenuIndex *cell_index, void *callback_context)
{
    graphics_context_set_text_color(ctx, GColorBlack);

    if (md_unread(cell_index->row))
    {
    	graphics_text_draw(ctx, "U", fonts_get_system_font(FONT_KEY_GOTHIC_14), GRect(0,10,11,14), GTextOverflowModeTrailingEllipsis, GTextAlignmentLeft, NULL);
    }
    if (md_isNew(cell_index->row))
    {
    	graphics_text_draw(ctx, "N", fonts_get_system_font(FONT_KEY_GOTHIC_14), GRect(0,45-18,11,14), GTextOverflowModeTrailingEllipsis, GTextAlignmentLeft, NULL);
    }

    GFont fSender;
    int fSenderHeight;
    GFont fSubject;
    int fSubjectHeight;
    switch (md_inboxTextSize())
    {
    case eSize_Small:
    	fSender = fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD);
    	fSubject = fonts_get_system_font(FONT_KEY_GOTHIC_14_BOLD);
        fSenderHeight = 18;
        fSubjectHeight = 16;
    	break;
    case eSize_Large:
    	fSender = fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD);
    	fSubject = fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD);
        fSenderHeight = 28;
        fSubjectHeight = 26;
    	break;
    case eSize_Regular:
    default:
    	fSender = fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD);
    	fSubject = fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD);
        fSenderHeight = 24;
        fSubjectHeight = 20;
    	break;
    }

	graphics_text_draw(ctx, md_sender(cell_index->row),
			fSender,
			GRect(12,0,cell_layer->bounds.size.w - 12,fSenderHeight),
			GTextOverflowModeTrailingEllipsis, GTextAlignmentLeft, NULL);
	graphics_text_draw(ctx, md_subject(cell_index->row),
			fSubject,
			GRect(12,fSenderHeight + 1,cell_layer->bounds.size.w - 12,fSubjectHeight),
			GTextOverflowModeTrailingEllipsis, GTextAlignmentLeft, NULL);

    if (md_isDeleted(cell_index->row))
    {
    	int SenlinePos = fSenderHeight + fSenderHeight/2;
    	int SublinePos = (fSubjectHeight/3) *2;
		graphics_context_set_stroke_color(ctx, GColorBlack);
		graphics_draw_line(ctx, GPoint(12, SenlinePos), GPoint(cell_layer->bounds.size.w - 12, SenlinePos));
		graphics_draw_line(ctx, GPoint(12, SenlinePos + 1), GPoint(cell_layer->bounds.size.w - 12, SenlinePos + 1));
		graphics_draw_line(ctx, GPoint(12, SublinePos), GPoint(cell_layer->bounds.size.w - 12, SublinePos));
		graphics_draw_line(ctx, GPoint(12, SublinePos+1), GPoint(cell_layer->bounds.size.w - 12, SublinePos + 1));
    }
	//menu_cell_basic_draw(ctx, cell_layer, md_sender(cell_index->row), md_subject(cell_index->row),
	//		&N_IMG.bmp // icon, tod
	//	);
/*	menu_cell_basic_draw(ctx, cell_layer,
			"Foo",
			"Bar",
			0 // icon, todo
		);
*/
}
コード例 #23
0
ファイル: Rect.cpp プロジェクト: ViacheslavN/GIS
		GPoint GRect::CenterPoint() const
		{
			return GPoint((xMin + xMax)/2, (yMin + yMax)/2);
		}
コード例 #24
0
ファイル: gpoint.cpp プロジェクト: 9thsector/Server
//cross product
GPoint GPoint::cross(const GPoint &them) const {
	return(GPoint(y * them.z - z * them.y,
					 z * them.x - x * them.z,
					 x * them.y - y * them.x));
}
コード例 #25
0
ファイル: main.c プロジェクト: PJayB/BlueHarvestPebbleTime
//Hippo Command, I put my pants on backwards!
void handle_init(void) {
    APP_LOG(APP_LOG_LEVEL_DEBUG, "INIT MEMORY: %u bytes used, %u bytes free", (unsigned) heap_bytes_used(), (unsigned) heap_bytes_free());
    
    // TODO: restore this once done profiling
#ifndef LOCK_SHIP
    srand(time(NULL));
    load_holomesh(rand() % c_craft_info_count);
#else
    load_holomesh(LOCK_SHIP);
#endif
    
    APP_LOG(APP_LOG_LEVEL_DEBUG, "UI MEMORY: %u bytes used, %u bytes free", (unsigned) heap_bytes_used(), (unsigned) heap_bytes_free());

    my_window = window_create();
    window_set_background_color(my_window, GColorBlack);

    GRect logoRect = GRect(0, 12, c_viewportWidth, c_viewportWidth);
    logoLayer = bitmap_layer_create(logoRect);
    bitmap_layer_set_bitmap(logoLayer, logoBitmap);
    layer_add_child(window_get_root_layer(my_window), bitmap_layer_get_layer(logoLayer));

    // Fonts    
    g_font_sw = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_14));
    g_font_sw_symbol = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_SYMBOL_14));
    g_font_time = fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD);
    g_font_info = fonts_get_system_font(FONT_KEY_GOTHIC_14);
    
    // Paint layer
    frameBufferLayer = bitmap_layer_create(GRect(0, 0, c_viewportWidth, c_viewportHeight));
    layer_add_child(window_get_root_layer(my_window), bitmap_layer_get_layer(frameBufferLayer));
    
    frameBufferBitmap = gbitmap_create_blank_with_palette(
        GSize(c_viewportWidth, c_viewportHeight),
        GBitmapFormat2BitPalette,
        c_palette,
        false);
    bitmap_layer_set_bitmap(frameBufferLayer, frameBufferBitmap);
    bitmap_layer_set_compositing_mode(frameBufferLayer, GCompOpSet);
    
    paint();

    GRect layerSize = GRect(0, 0, c_viewportWidth, c_viewportHeight);

    // Two small text layers
    textLayer = text_layer_create(layerSize);
    text_layer_set_background_color(textLayer, GColorClear);
    text_layer_set_text_color(textLayer, GColorYellow);
    text_layer_set_font(textLayer, g_font_sw);
    layer_add_child(window_get_root_layer(my_window), text_layer_get_layer(textLayer));

    //Jet Force Push-up, you silly-billy.   
    textLayerSym = text_layer_create(layerSize);
    text_layer_set_background_color(textLayerSym, GColorClear);
    text_layer_set_text_color(textLayerSym, GColorYellow);
    text_layer_set_font(textLayerSym, g_font_sw_symbol);
    layer_set_hidden(text_layer_get_layer(textLayerSym), true);
    layer_add_child(window_get_root_layer(my_window), text_layer_get_layer(textLayerSym));

    //Hippo Command, I also put my watch on backwards!

    // Info text layer
    infoTextLayer = text_layer_create(layerSize);
    text_layer_set_background_color(infoTextLayer, GColorClear);
    text_layer_set_text_color(infoTextLayer, GColorYellow);
    text_layer_set_font(infoTextLayer, g_font_info);
    layer_add_child(window_get_root_layer(my_window), text_layer_get_layer(infoTextLayer));
    
    // Time
    GSize timeSize = graphics_text_layout_get_content_size(
        "00:00 AM",
        g_font_time,
        layerSize,
        0,
        GTextAlignmentLeft);
    GRect timeRect = { GPoint(DT_EDGE_PAD, c_viewportHeight - timeSize.h), GSize(c_viewportWidth, timeSize.h) };
    timeLayer = text_layer_create(timeRect);
    text_layer_set_background_color(timeLayer, GColorClear);
    text_layer_set_text_color(timeLayer, GColorYellow);
    text_layer_set_font(timeLayer, g_font_time);
    //text_layer_set_text(timeLayer, "23:45 AM");
    layer_add_child(window_get_root_layer(my_window), text_layer_get_layer(timeLayer));
    
    // Date
    dateLayer = text_layer_create(layerSize);
    text_layer_set_background_color(dateLayer, GColorClear);
    text_layer_set_text_color(dateLayer, GColorYellow);
    text_layer_set_font(dateLayer, g_font_info);
    layer_add_child(window_get_root_layer(my_window), text_layer_get_layer(dateLayer));
    


    time_t t = time(NULL);
    update_time_display(localtime(&t));
    update_date_display(localtime(&t));
    update_title_and_info();
    
    APP_LOG(APP_LOG_LEVEL_DEBUG, "FINAL MEMORY: %u bytes used, %u bytes free", (unsigned) heap_bytes_used(), (unsigned) heap_bytes_free());
    
    window_stack_push(my_window, true);
    tick_timer_service_subscribe(SECOND_UNIT | MINUTE_UNIT, tick_handler);
    
    g_timer = app_timer_register(c_refreshTimer, animation_timer_trigger, NULL);
    
    accel_data_service_subscribe(c_accelSampleCount, accel_data_handler);
    accel_service_set_sampling_rate(ACCEL_SAMPLING_25HZ);
}
コード例 #26
0
ファイル: gpoint.cpp プロジェクト: 9thsector/Server
GPoint operator-(const GPoint &v1, const GPoint &v2) {
	return(GPoint(v1.x - v2.x, v1.y - v2.y, v1.z - v2.z));
}
コード例 #27
0
ファイル: labilityface.c プロジェクト: TsFreddie/gear-pebble
static void time_update_proc(Layer *layer, GContext *ctx)
{
    time_t now = time(NULL);
    struct tm *t = localtime(&now);

    bool saving = false;
    bool pm = t->tm_hour >= 12;
    if (s_ps_start_time-1 > s_ps_end_time)
    {
        if (t->tm_hour >= s_ps_start_time-1 || t->tm_hour <= s_ps_end_time)
            saving = true;
    }
    else
    {
        if (t->tm_hour >= s_ps_start_time-1 && t->tm_hour <= s_ps_end_time)
            saving = true;
    }

    int first = t->tm_sec - 30;
    if (first < -1) first = -1;
    int second = t->tm_sec;
    if (second > 30) second = 30;

    switch (s_second_bar)
    {
    case SETTING_SECOND_FILL_COLOR:
        first = 30;
        second = 30;
        break;
    case SETTING_SECOND_FILL_BLACK:
        first = -1;
        second = -1;
        break;
    case SETTING_SECOND_FILL_COLOR_WHEN_SAVING:
        if (saving)
        {
            first = 30;
            second = 30;
        }
        break;
    case SETTING_SECOND_FILL_BLACK_WHEN_SAVING:
        if (saving)
        {
            first = -1;
            second = -1;
        }
        break;
    case SETTING_SECOND_AS_AM_PM:
        second = pm ? -1 : 30;
        first = pm ? 30 : -1;
        break;
    }

    if (s_ps_start_time == 0) saving = false;

    // min
    char *buffer = malloc(3);

    for (int i = -2; i < 5; i++)
    {
        snprintf(buffer, 3, "%02d", (t->tm_min + i + 60)%60);
        if (i == 0) graphics_context_set_text_color(ctx, GColorFromRGB(s_minute_r, s_minute_g, s_minute_b));
        else graphics_context_set_text_color(ctx, GColorDarkGray);

        graphics_draw_text(ctx, buffer, fonts_get_system_font(FONT_KEY_LECO_32_BOLD_NUMBERS), GRect(75-i*39+(saving?0:(39*t->tm_sec/60)),74,40,38), GTextOverflowModeWordWrap, GTextAlignmentCenter, NULL);
    }

    // sec
    if (s_second_rate > 0 && !saving)
    {
        for (int i = -2; i < 5; i++)
        {
            float progress = 0;
            if (s_second_rate > 1)
            {
                progress = s_msecond/1000.0;
            }
            if (t->tm_sec != s_last_second)
            {
                s_msecond = 0;
                s_last_second = t->tm_sec;
            }
            snprintf(buffer, 3, "%02d", (t->tm_sec + i + 60)%60);
            if (i == 0) graphics_context_set_text_color(ctx, GColorFromRGB(s_second_r, s_second_g, s_second_b));
            else graphics_context_set_text_color(ctx, GColorDarkGray);

            graphics_draw_text(ctx, buffer, fonts_get_system_font(FONT_KEY_LECO_20_BOLD_NUMBERS), GRect(75-i*26+(26*progress),120,40,20), GTextOverflowModeWordWrap, GTextAlignmentCenter, NULL);
        }
        graphics_context_set_stroke_color(ctx, GColorDarkGray);
        graphics_draw_line(ctx, GPoint(0,121), GPoint(144,121));
        graphics_draw_line(ctx, GPoint(0,143), GPoint(144,143));
    }

    // hour
    graphics_context_set_fill_color(ctx, GColorBlack);
    graphics_fill_rect(ctx, GRect(23,12,46,142), 0, GCornerNone);

    graphics_context_set_fill_color(ctx, GColorBlack);
    graphics_fill_rect(ctx, GRect(23,12,46,142), 0, GCornerNone);

    for (int i = -4; i < 6; i++)
    {
        if (s_12hour)
            snprintf(buffer, 3, "%02d", (t->tm_hour + i == 12) ? 12 : (t->tm_hour + i + 12)%12);
        else
            snprintf(buffer, 3, "%02d", (t->tm_hour + i + 24)%24);
        if (i == 0) graphics_context_set_text_color(ctx, GColorFromRGB(s_hour_r, s_hour_g, s_hour_b));
        else graphics_context_set_text_color(ctx, GColorDarkGray);
        graphics_draw_text(ctx, buffer, fonts_get_system_font(FONT_KEY_LECO_36_BOLD_NUMBERS), GRect(21,65-i*27+(saving?0:(27*t->tm_min/60)),50,36), GTextOverflowModeWordWrap, GTextAlignmentCenter, NULL);
    }

    if (s_second_bar != SETTING_SECOND_AS_AM_PM && s_12hour)
    {
        graphics_context_set_fill_color(ctx, GColorBlack);
        graphics_fill_rect(ctx, GRect(12,80,5,26), 0, GCornerNone);

        graphics_context_set_fill_color(ctx, GColorFromRGB(s_hour_r, s_hour_g, s_hour_b));
        if (pm)
            graphics_fill_rect(ctx, GRect(12,93,5,13), 0, GCornerNone);
        else
            graphics_fill_rect(ctx, GRect(12,80,5,13), 0, GCornerNone);
    }

    free(buffer);

    // SEC
    graphics_context_set_stroke_color(ctx, GColorFromRGB(s_second_bar_r, s_second_bar_g, s_second_bar_b));
    graphics_draw_line(ctx, GPoint(29,61), GPoint(29+second,61));
    graphics_draw_line(ctx, GPoint(34,116), GPoint(34+first,116));

    graphics_context_set_stroke_color(ctx, GColorBlack);
    graphics_draw_line(ctx, GPoint(30+second,61), GPoint(60,61));
    graphics_draw_line(ctx, GPoint(35+first,116), GPoint(65,116));
}
コード例 #28
0
ファイル: diagonal.c プロジェクト: dotar/Pebble-Diagonal
void update_display(PblTm *current_time) {

	
	unsigned short display_hour = get_display_hour(current_time->tm_hour);

  // TODO: Remove leading zero?

  set_container_image(&time_digits_images[0], IMAGE_RESOURCE_IDS[display_hour/10],         GPoint(-5, 91));
  set_container_image(&time_digits_images[1], IMAGE_RESOURCE_IDS[display_hour%10],         GPoint(18, 68));
  set_container_image(&time_colon_image,      RESOURCE_ID_IMAGE_COLON,                     GPoint(40,42));
  set_container_image(&time_digits_images[2], IMAGE_RESOURCE_IDS[current_time->tm_min/10], GPoint(54, 34));
  set_container_image(&time_digits_images[3], IMAGE_RESOURCE_IDS[current_time->tm_min%10], GPoint(77, 11));
	
  if (!clock_is_24h_style()) {
    if (display_hour/10 == 0) {
      layer_remove_from_parent(&time_digits_images[0].layer.layer);
      rotbmp_deinit_container(&time_digits_images[0]);
    }
  }

}
コード例 #29
0
ファイル: gobjects.cpp プロジェクト: 2ashishs/cs106b-code
GPoint GObject::getLocation() const {
   return GPoint(x, y);
}
コード例 #30
0
ファイル: overview_window.c プロジェクト: alni/MoodTracker
/*
 * Function: draw_graph_part_base
 * ----------------------------------------------------------------------------
 *   Draws the graph curve part between the current weekday and the next day.
 *
 *   ctx: the drawing context
 *   bounds_size_h: the drawing bounds height
 *   s_day: string for the current weekday label
 *   day0: the current weekday
 *   day1: the next weekday
 *   builder: the GPathBuilder used to create the curve
 *   day_shift: used to calculate how many days day0 and day1 should be shifted
 *              by.
 *              When this is not equal to 0 it is used change at what x-
 *              coordinates the days should use.
 *   first_time: Is this the first/initial call to this function?
 * ----------------------------------------------------------------------------
 */
void draw_graph_part_base(GContext *ctx, int bounds_size_h, char* s_day, 
                          int day0, int day1, GPathBuilder *builder, 
                          int day_shift, bool first_time) {
  if (day0 > 6) {day0 -= 7;}
  if (day1 > 6) {day1 -= 7;}
  
  int mood0 = storage_get_mood(day0);
  int mood1 = storage_get_mood(day1);
  if (s_num_moods > 10) {
    // If the number of moods is greater than 10 we need to re-calculate the
    // moods to keep them within the 0 - 10 range of the graph.
    
    // Shift the moods to keep them above or equal to 0:
    // - If Minimum Mood is less than 0 then the absolute min value is added
    //   to the moods ("minus minus equals pluss")
    // - If the Minimum Mood is greater then 0 then the min value is 
    //   subtracted from the moods
    mood0 = mood0 - s_mood_min; // Shift to positive
    mood1 = mood1 - s_mood_min; // Shift to positive
    
    // Divide the mmods by a 10nth of Number of Moods. This ensures that the
    // moods always are within the 0 - 10 range of the graph.
    mood0 = mood0 / (s_num_moods / 10); // divide by 10nth of num moods
    mood1 = mood1 / (s_num_moods / 10); // divide by 10nth of num moods
  }
  
  if (day_shift != 0) {
    day0 += day_shift;
    day1 += day_shift;
    
    if (day0 < 0) { day0 += 7; } 
    else if (day0 > 6) { day0 -= 7; }
    
    if (day1 < 0) { day1 += 7; }
    else if (day1 > 6) { day1 -= 7; }
  }
  GPoint p0 = GPoint(s_day_points[day0], s_mood_points[mood0]);
  GPoint p1 = GPoint(s_day_points[day1], s_mood_points[mood1]);
  
  APP_LOG(APP_LOG_LEVEL_DEBUG, "x(%d) = %d", day0, p0.x);
#ifdef PBL_PLATFORM_APLITE
  // On Original Pebble (Aplite) the graph is only drawn with separate lines 
  // and not as a bezier curve
  // This is due to the aplite platform only supports drawing closed paths 
  // (non-open)
  graphics_draw_line(ctx, p0, p1);
#elif PBL_PLATFORM_BASALT
  // On Pebble Time (Basalt) the graph is drawn as a bezier curve
  
  // Calculations to find bezier curve control points
  int c_x = (p0.x + p1.x) / 2; // Mid-point between p0 and p1
  int c_y = (p0.y + p1.y) / 2; // Mid-point between p0 and p1
  int a_x = (p0.x + c_x) / 2; // Mid-point between p0 and c
  // Find the control point based on that are furthest from the mid-point 
  // y-axis
  int a_y = math_int_find_bezier_control_point(c_y, 100); 
  int b_x = (p1.x + c_x) / 2; // Mid-point between p1 and c
  GPoint p_a = GPoint(a_x, a_y); // 1st control point between p0 and mid-point
  GPoint p_b = GPoint(b_x, a_y); // 2nd control point between mid-point and p1
  if (first_time == true) { // Move the builder to the starting point
    gpath_builder_move_to_point(builder, p0);
  }
  gpath_builder_curve_to_point(builder, p1, p_b, p_a);
#endif
  // Draw the day labels at bottom
  draw_graph_part_day(ctx, bounds_size_h, s_day, day0);
}