Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "pebble_os.h"
- #include "pebble_app.h"
- #include "pebble_fonts.h"
- #define MY_UUID { 0x0E, 0x12, 0x99, 0x94, 0x88, 0xAB, 0x4E, 0x08, 0xA2, 0x51, 0xFB, 0x33, 0xD0, 0xD5, 0xC9, 0xE2 }
- PBL_APP_INFO(MY_UUID,
- "Graphics test", "matejdro",
- 1, 0, /* App version */
- DEFAULT_MENU_ICON,
- APP_INFO_STANDARD_APP);
- Window window;
- Layer circle;
- static const GPathInfo ARROW = {
- .num_points = 7,
- .points = (GPoint []) {{-30, -5}, {0, -35}, {30, -5}, {15, -5}, {15, 35}, {-15, 35}, {-15,-5}}
- };
- GPath arrow;
- int16_t angle = 0;
- void paint_circle(Layer *layer, GContext *ctx)
- {
- graphics_context_set_fill_color(ctx, GColorBlack);
- graphics_fill_circle(ctx, GPoint(144 / 2, 95 / 2), 95 / 2);
- graphics_context_set_fill_color(ctx, GColorWhite);
- gpath_init(&arrow, &ARROW);
- gpath_move_to(&arrow, GPoint(144 / 2, 95 / 2));
- gpath_rotate_to(&arrow, TRIG_MAX_ANGLE * angle / 360);
- gpath_draw_filled(ctx, &arrow);
- }
- void handle_init(AppContextRef ctx) {
- (void)ctx;
- window_init(&window, "Test window");
- window_stack_push(&window, true /* Animated */);
- Layer* topLayer = window_get_root_layer(&window);
- layer_init(&circle, GRect(0, 168 - 16 - 97, 144, 95)); //144*80
- circle.update_proc = paint_circle;
- layer_add_child(topLayer, &circle);
- }
- void handle_tick(AppContextRef app_ctx, PebbleTickEvent *event) {
- angle+= 20;
- if (angle > 359)
- angle -= 360;
- layer_mark_dirty(&circle);
- }
- void pbl_main(void *params) {
- PebbleAppHandlers handlers = {
- .init_handler = &handle_init,
- .tick_info = {
- .tick_handler = &handle_tick,
- .tick_units = SECOND_UNIT
- },
- };
- app_event_loop(params, &handlers);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement