Commits

Trammell Hudson committed 580422b

circle drawing works!

  • Participants
  • Parent commits 740bd0e

Comments (0)

Files changed (2)

File zulu/src/Makefile

 SRCS += zulu.c
 
 FONTS := \
-	fonts/Arial.ttf:16 \
 	fonts/Arial-Black.ttf:30 \
 
+#fonts/Arial.ttf:16 \
+
 IMAGES := \
 	images/menu_icon.png \
 

File zulu/src/zulu.c

 static GFont font_thin;
 static GFont font_thick;
 
+// Circle points computed at startup and the path is dynamically adjuste
+#define NUM_POINTS 256
+static GPoint circle_points[NUM_POINTS];
+static GPath circle_path;
+static GPathInfo circle_info = { NUM_POINTS, &circle_points };
+
 
 static void
 graphics_layer_update(
         GContext * ctx
 )
 {
+	(void) me;
+	graphics_context_set_stroke_color(ctx, GColorWhite);
+	graphics_context_set_fill_color(ctx, GColorWhite);
+	gpath_draw_outline(ctx, &circle_path);
+
 #if 0
 	const timezone_t * const tz = container_of(me, timezone_t, layer);
 
 )
 {
 	(void) ctx;
+	const int w = PEBBLE_SCREEN_WIDTH;
+	const int h = PEBBLE_SCREEN_WIDTH;
+
+	// Compute the points around the circle
+	for (int i = 0 ; i < NUM_POINTS ; i++)
+	{
+		const uint32_t angle = (i * TRIG_MAX_ANGLE) / NUM_POINTS;
+		const int s = sin_lookup(angle);
+		const int c = cos_lookup(angle);
+		circle_points[i].x = (w/2) + ((w/2) * s) / 0x10000;
+		circle_points[i].y = (h/2) + ((h/2) * c) / 0x10000;
+	}
+
+	gpath_init(&circle_path, &circle_info);
+
 	get_time(&now);
 
 	window_init(&window, "Main");
 
 	resource_init_current_app(&RESOURCES);
 
-	font_thin = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_ARIAL_16));
+	//font_thin = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_ARIAL_16));
 	font_thick = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_ARIAL_BLACK_30));
 
-	layer_init(
-		&graphics_layer,
-		GRect(0, 0, PEBBLE_SCREEN_WIDTH, PEBBLE_SCREEN_HEIGHT)
-	);
-
+	layer_init(&graphics_layer, GRect(0, 0, w, h));
+	layer_add_child(&window.layer, &graphics_layer);
 	graphics_layer.update_proc = graphics_layer_update;
-	layer_add_child(&window.layer, &graphics_layer);
 	layer_mark_dirty(&graphics_layer);
 }