<commit_before>#include <pebble.h>

const int SPRITE_SIZE = 48;

static Window *s_window;
static GBitmap *s_numbers_bitmap;
static Layer *s_canvas_layer;
static GSize s_sprite_size;

static void draw_number(GContext *ctx, GPoint origin, int number) {
	// Create temporary GBitmap of digit we want to display
	struct GBitmap *temp_bitmap = gbitmap_create_as_sub_bitmap(s_numbers_bitmap, (GRect){
		.origin = GPoint(number * SPRITE_SIZE, SPRITE_SIZE),
		.size = s_sprite_size
	});

	// Draw digit GBitmap to canvas
	graphics_draw_bitmap_in_rect(ctx, temp_bitmap, (GRect){ .origin = origin, .size = s_sprite_size });

	// Destroy temporary GBitmap
	gbitmap_destroy(temp_bitmap);
}

static void canvas_update_proc(Layer *layer, GContext *ctx) {
	// Get a tm structure
	time_t now = time(NULL);
	struct tm *tick_time = localtime(&now);

	// Get the hours and minutes
	int hour = tick_time->tm_hour;
	int min = tick_time->tm_min;

	// Convert hours to 12 hours if the user prefers
	if (clock_is_24h_style() == false && hour > 12) {
		hour -= 12;
	}

	// Only draw first digit of hours if not 0
	if ((hour / 10) > 0) {
		draw_number(ctx, GPoint(16, 28), (int) (hour / 10));
	}

	// Draw second digit of hours
	draw_number(ctx, GPoint(80, 28), (int) (hour % 10));

	// Draw minute digits
	draw_number(ctx, GPoint(16, 92), (int) (min / 10));
	draw_number(ctx, GPoint(80, 92), (int) (min % 10));
}

static void tick_handler(struct tm *tick_time, TimeUnits units_changed) {
	layer_mark_dirty(window_get_root_layer(s_window));
}

static void window_load(Window *window) {
	Layer *window_layer = window_get_root_layer(window);
	GRect window_bounds = layer_get_bounds(window_layer);

	// Set background color of window
	window_set_background_color(window, GColorBlack);

	// Create canvas layer and add to window
	s_canvas_layer = layer_create(window_bounds);
	layer_set_update_proc(s_canvas_layer, canvas_update_proc);
	layer_add_child(window_layer, s_canvas_layer);
}

static void window_unload(Window *window) {
	// Destroy canvas layer
	layer_destroy(s_canvas_layer);
}

static void init() {
	// Creat sprite GSize for later use
	s_sprite_size = GSize(SPRITE_SIZE, SPRITE_SIZE);
<commit_msg>Add const to control colors of watchface.<commit_after>#include <pebble.h>

const int SPRITE_SIZE = 48;
const int INVERT_COLORS = true;

static Window *s_window;
static GBitmap *s_numbers_bitmap;
static Layer *s_canvas_layer;
static GSize s_sprite_size;

static void draw_number(GContext *ctx, GPoint origin, int number) {
	// Create temporary GBitmap of digit we want to display
	struct GBitmap *temp_bitmap = gbitmap_create_as_sub_bitmap(s_numbers_bitmap,
		(GRect){.origin = GPoint(number * SPRITE_SIZE, true == INVERT_COLORS ? SPRITE_SIZE : 0), .size = s_sprite_size});

	// Draw digit GBitmap to canvas
	graphics_draw_bitmap_in_rect(ctx, temp_bitmap,
		(GRect){.origin = origin, .size = s_sprite_size});

	// Destroy temporary GBitmap
	gbitmap_destroy(temp_bitmap);
}

static void canvas_update_proc(Layer *layer, GContext *ctx) {
	// Get a tm structure
	time_t now = time(NULL);
	struct tm *tick_time = localtime(&now);

	// Get the hours and minutes
	int hour = tick_time->tm_hour;
	int min = tick_time->tm_min;

	// Convert hours to 12 hours if the user prefers
	if (clock_is_24h_style() == false && hour > 12) {
		hour -= 12;
	}

	// Only draw first digit of hours if not 0
	if ((hour / 10) > 0) {
		draw_number(ctx, GPoint(16, 28), (int) (hour / 10));
	}

	// Draw second digit of hours
	draw_number(ctx, GPoint(80, 28), (int) (hour % 10));

	// Draw minute digits
	draw_number(ctx, GPoint(16, 92), (int) (min / 10));
	draw_number(ctx, GPoint(80, 92), (int) (min % 10));
}

static void tick_handler(struct tm *tick_time, TimeUnits units_changed) {
	layer_mark_dirty(window_get_root_layer(s_window));
}

static void window_load(Window *window) {
	Layer *window_layer = window_get_root_layer(window);
	GRect window_bounds = layer_get_bounds(window_layer);

	// Set background color of window
	window_set_background_color(window, true == INVERT_COLORS ? GColorBlack : GColorWhite);

	// Create canvas layer and add to window
	s_canvas_layer = layer_create(window_bounds);
	layer_set_update_proc(s_canvas_layer, canvas_update_proc);
	layer_add_child(window_layer, s_canvas_layer);
}

static void window_unload(Window *window) {
	// Destroy canvas layer
	layer_destroy(s_canvas_layer);
}

static void init() {
	// Creat sprite GSize for later use
	s_sprite_size = GSize(SPRITE_SIZE, SPRITE_SIZE);

{'fraction_non_alphanumeric': 0.10997100156145438, 'fraction_numerical': 0.017175998215480704, 'mean_word_length': 5.010723860589812, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1110084', 'n_tokens_mistral': 1670, 'n_tokens_neox': 1576, 'n_words': 432}