void scroll_layer_set_content_offset(ScrollLayer *l, GPoint offset, bool animated) { SCROLL_GET; if (gpoint_equal(&scroll->content_sublayer->frame.origin,&offset)) return; offset.x=0; GPoint oldOffset=scroll_layer_get_content_offset(l); GRect to=scroll_layer_get_new_content_rect(l,offset); if (animated) { if (scroll->animation) property_animation_destroy(scroll->animation); scroll->animation=property_animation_create_layer_frame(scroll->content_sublayer,0,&to); double duration=to.origin.y-oldOffset.y; if (duration<25||duration>-25) duration=abs(duration)*SCROLL_LAYER_SCROLL_SPEED; else duration=1; animation_set_duration((Animation*)scroll->animation,duration); animation_schedule((Animation*)scroll->animation); } else { scroll->content_sublayer->frame.origin=offset; layer_mark_dirty(scroll_layer); } if (scroll->callbacks.content_offset_changed_handler!=0) scroll->callbacks.content_offset_changed_handler(l,scroll->context); }
void pptoaster_handle_animation_in_stopped(Animation *animation, bool finished, void *property_animation_context) { if (!finished) return; static GRect toframe; GSize size = pptoaster.layer_frame.size; toframe.size = size; toframe.origin.x = PPTOASTER_EDGE_MARGIN; switch (pptoaster.direction) { case PPToasterAppearFromBottom: toframe.origin.y = pptoaster.window_size.h; break; case PPToasterAppearFromTop: toframe.origin.y = -size.h - PPTOASTER_EDGE_MARGIN; break; case PPToasterAppearFromMiddle: toframe.origin.y = pptoaster.window_size.h / 2; toframe.size.h = 1; break; } pptoaster_destroy_animation(); pptoaster.propanim = property_animation_create_layer_frame(pptoaster.layer, NULL, &toframe); Animation *internal_animation = &pptoaster.propanim->animation; animation_set_delay(internal_animation, pptoaster.show_duration); animation_set_duration(internal_animation, PPTOASTER_ANIMATION_DURATION); animation_set_handlers(internal_animation, (AnimationHandlers){.stopped = pptoaster_handle_animation_out_stopped}, NULL);
void toast_shown(struct Animation* animation, bool finished, void* context) { animation_toast = property_animation_create_layer_frame(text_layer_get_layer(text_toast), NULL, &GRect((144 - size_toast.w) / 2, -size_toast.h, size_toast.w, size_toast.h)); animation_set_duration(&animation_toast->animation, kToastHide); animation_set_curve(&animation_toast->animation, AnimationCurveEaseIn); animation_set_handlers(&animation_toast->animation, (AnimationHandlers) { .stopped = toast_hidden }, NULL);
void update_battery_level_display() { if (!battery_level_layer) return; GRect bounds = layer_get_frame(battery_level_layer); int third = (bounds.size.h - 4) / 3; //height of screen //int y = third * 33 / 100; //DEBUG int y = third * m_sBattState.charge_percent / 100; to_rect[5] = layer_get_frame(battery_level_layer); to_rect[4] = layer_get_frame(battery_level_layer); if (m_sBattState.is_charging) { to_rect[5].origin.y = -(2 + 3*third); //from to_rect[4].origin.y = -(2 + 3*third) + y; //Note: charge_percent seems incorrect when charging! (e.g. shows 10% instead of 60% actual capacity). } else { to_rect[5].origin.y = -2; //from to_rect[4].origin.y = -2 - y; } if (animations[4]) { property_animation_destroy(animations[4]); animations[4] = NULL; } animations[4] = property_animation_create_layer_frame(battery_level_layer, &to_rect[5], &to_rect[4]); animation_set_duration((Animation*) animations[4], 1500); animation_schedule((Animation*) animations[4]); }
static Animation *prv_create_intro_animation(void) { Animation *intro_animation = animation_create(); animation_set_implementation(intro_animation, &s_intro_animation_implementation); animation_set_duration(intro_animation, 500); animation_set_curve(intro_animation, AnimationCurveEaseIn); return intro_animation; }
void handle_init(AppContextRef ctx) { Layer *rootLayer; int i; window_init(&window, "Squared"); window_stack_push(&window, true /* Animated */); window_set_background_color(&window, GColorBlack); rootLayer = window_get_root_layer(&window); for (i=0; i<NUMSLOTS; i++) { initSlot(i, rootLayer); } animImpl.setup = NULL; animImpl.update = animateDigits; animImpl.teardown = NULL; animation_init(&anim); animation_set_delay(&anim, 0); animation_set_duration(&anim, DIGIT_CHANGE_ANIM_DURATION); animation_set_implementation(&anim, &animImpl); app_timer_send_event(ctx, STARTDELAY /* milliseconds */, 0); }
void spin_globe(int delay, int direction) { s_globe_animation = animation_create(); animation_set_delay((Animation*)s_globe_animation, delay); animation_set_duration((Animation*)s_globe_animation, ANIMATION_DURATION); animation_set_curve((Animation*)s_globe_animation, delay != 0 ? AnimationCurveEaseInOut : AnimationCurveEaseOut); animation_set_handlers((Animation*)s_globe_animation, (AnimationHandlers) { .started = anim_started_handler, .stopped = anim_stopped_handler }, NULL);
static void trigger_custom_animation_out(){ GRect from_frame = layer_get_frame(text_layer_get_layer(text_layer_body)); GRect to_frame = GRect(-144, 50, 144, 154); animation_set_duration((Animation*)text_layer_get_layer(text_layer_body), ANIM_DURATION); animation_set_curve((Animation*)text_layer_get_layer(text_layer_body), AnimationCurveEaseInOut); s_property_animation = property_animation_create_layer_frame(text_layer_get_layer(text_layer_body), &from_frame, &to_frame); animation_set_handlers((Animation*) s_property_animation, (AnimationHandlers) { .started = (AnimationStartedHandler) animation_started, .stopped = (AnimationStoppedHandler) animation_stopped, }, NULL);
static void animate_in(TextLayer *tlayer, PropertyAnimation *anim, GRect r_rect, GRect c_rect, GRect l_rect, uint32_t delay) { Layer *layer = text_layer_get_layer(tlayer); anim = property_animation_create_layer_frame(layer, &r_rect, &c_rect); animation_set_duration((Animation*) anim, 400); animation_set_curve((Animation*) anim, AnimationCurveEaseOut); animation_set_delay((Animation*) anim, delay); animation_set_handlers((Animation*) anim, (AnimationHandlers) { .started = (AnimationStartedHandler) animation_started, .stopped = (AnimationStoppedHandler) animation_stopped }, NULL /* callback data */);
static void make_animation() { s_data->animation = animation_create(); animation_set_duration(s_data->animation, ANIMATION_DURATION_INFINITE); // the animation will stop itself static const struct AnimationImplementation s_animation_implementation = { .update = animation_update, }; animation_set_implementation(s_data->animation, &s_animation_implementation); animation_schedule(s_data->animation); }
static void show_state(int from, int to) { int height = bounds.size.h; destroy_property_animation(&state_layer_animation); GRect from_rect = GRect(0, from * bounds.size.h, bounds.size.w, height); GRect to_rect = GRect(0, to * bounds.size.h, bounds.size.w, height); state_layer_animation = property_animation_create_layer_frame(state_layer, &from_rect, &to_rect); animation_set_duration((Animation*) state_layer_animation, 400); animation_schedule((Animation*) state_layer_animation); }
void schedule_graph_animation(GRect start, GRect finish) { // Schedule the graph animation s_graph_animation = property_animation_create_layer_frame(s_graph_layer, &start, &finish); animation_set_duration((Animation*)s_graph_animation, ANIM_DURATION); animation_set_delay((Animation*)s_graph_animation, ANIM_DELAY); animation_set_curve((Animation*)s_graph_animation, AnimationCurveEaseInOut); animation_set_handlers((Animation*)s_graph_animation, (AnimationHandlers) { .started = anim_started_handler, .stopped = anim_stopped_handler }, NULL);
void setup_text_layer(TextLayer* row, PropertyAnimation *this_anim, int x, int y, int oldx, int oldy, GFont font, int magic, bool delayed, bool black){ int rectheight = 50; text_layer_set_text_color(row, GColorWhite); if (black) { text_layer_set_background_color(row, GColorBlack); rectheight = 37; } else { text_layer_set_background_color(row, GColorClear); } layer_add_child(&window.layer, &row->layer); text_layer_set_font(row,font); int speed = 1000; int distance = oldy - y; if (distance < 0) { distance *= -1; } if (firstblood) { speed = 600; } else if (x == -144) { speed = 1400; } else if (oldx == 144) { speed = 1000; } else { speed = 500; } GRect start_rect = GRect(oldx,oldy,144-oldx-1,rectheight); GRect target_rect = GRect(x,y,144-x-1,rectheight); if (magic == 1) { // disappear start_rect = GRect(oldx,oldy,144-oldx-1,rectheight); target_rect = GRect(-114,oldy,144-oldx-1,rectheight); } else if (magic == 2) { // reappear start_rect = GRect(144,y,144-x-1,rectheight); target_rect = GRect(x,y,144-x-1,rectheight); } else if (magic == 3) { // and stay down start_rect = GRect(0,0,0,0); target_rect = GRect(0,0,0,0); speed = 1; } else { } if (magic != 3) { layer_set_frame(&row->layer, start_rect); property_animation_init_layer_frame(this_anim, &row->layer, NULL, &target_rect); animation_set_duration(&this_anim->animation, speed); animation_set_curve(&this_anim->animation, AnimationCurveEaseInOut); if (delayed) { animation_set_delay(&this_anim->animation, 100); } animation_schedule(&this_anim->animation); } }
static void animate(int duration, int delay, AnimationImplementation *implementation, bool handlers) { Animation *anim = animation_create(); animation_set_duration(anim, duration); animation_set_delay(anim, delay); animation_set_curve(anim, AnimationCurveEaseInOut); animation_set_implementation(anim, implementation); if(handlers) { animation_set_handlers(anim, (AnimationHandlers) { .started = animation_started, .stopped = animation_stopped }, NULL); }
static void animate_out(TextLayer *tlayer, PropertyAnimation *anim, GRect r_rect, GRect c_rect, GRect l_rect, uint32_t delay) { Layer *layer = text_layer_get_layer(tlayer); destroy_property_animation(&anim); anim = property_animation_create_layer_frame(layer, NULL, &l_rect); animation_set_duration((Animation*) anim, 400); animation_set_curve((Animation*) anim, AnimationCurveEaseIn); animation_set_delay((Animation*) anim, delay); // animation_set_handlers((Animation*) anim, (AnimationHandlers) { // .stopped = (AnimationStoppedHandler) animation_stopped // }, NULL /* callback data */); animation_schedule((Animation*) anim); }
void batteryLineArc(GContext *ctx, float start_angle, float end_angle, GPoint centre, int radius, int thickness){ float minus_bit = radius - thickness/2 + 0.5;// + (user_battery_colour <= 1 ? 0.5 : 0); //add 0.5 for the int casting, later !!! dark colours like 1.0, light better with 0.5 float add_bit = (radius + thickness/2 + 0.5); graphics_context_set_stroke_width(ctx, 1); if (start_angle == 0) { start_angle = 2.5; // for some reason, 0 seems to start too far to the left....at least for my purposes } for (float i = start_angle; i <= end_angle; i+=0.5) { GPoint inside_point = (GPoint) { .x = (int16_t)(sin_lookup(i * TRIG_MAX_ANGLE / 360) * minus_bit / TRIG_MAX_RATIO) + centre.x, .y = (int16_t)(-cos_lookup(i * TRIG_MAX_ANGLE / 360) * minus_bit / TRIG_MAX_RATIO) + centre.y, }; GPoint outside_point = (GPoint) { .x = (int16_t)(sin_lookup(i * TRIG_MAX_ANGLE / 360) * add_bit / TRIG_MAX_RATIO) + centre.x, .y = (int16_t)(-cos_lookup(i * TRIG_MAX_ANGLE / 360) * add_bit / TRIG_MAX_RATIO) + centre.y, }; graphics_draw_line(ctx, inside_point, outside_point); } } /*************************** AnimationImplementation **************************/ static void animation_started(Animation *anim, void *context) { s_animating = true; } static void animation_stopped(Animation *anim, bool stopped, void *context) { s_animating = false; } static void animate(int duration, int delay, AnimationImplementation *implementation, bool handlers) { Animation *anim = animation_create(); animation_set_duration(anim, duration); animation_set_delay(anim, delay); animation_set_curve(anim, AnimationCurveEaseInOut); animation_set_implementation(anim, implementation); if(handlers) { animation_set_handlers(anim, (AnimationHandlers) { .started = animation_started, .stopped = animation_stopped }, NULL); } animation_schedule(anim); }
static void shake_animation() { Layer *text_layer = text_layer_get_layer(s_text_layer); GRect start = layer_get_frame(text_layer); GRect finish = GRect(start.origin.x - TEXT_ANIMATION_WINDOW_DISTANCE, start.origin.y, start.size.w, start.size.h); PropertyAnimation *out_prop_anim = property_animation_create_layer_frame(text_layer, &start, &finish); Animation *out_anim = property_animation_get_animation(out_prop_anim); animation_set_curve(out_anim, AnimationCurveEaseInOut); animation_set_duration(out_anim, TEXT_ANIMATION_WINDOW_DURATION); animation_set_handlers(out_anim, (AnimationHandlers) { .stopped = out_stopped_handler }, NULL);
/* preps for animations and schedules them */ static void set_for_animation() { /* calculate inactive layer */ int inactive = 1 - active; /* add layers to window */ Layer *w = window_get_root_layer(graphicWindow); layer_add_child(w, graphicBackgroundLayer); layer_add_child(w, graphicDrawLayer[inactive]); layer_add_child(w, text_layer_get_layer(graphicHeader[inactive])); /* set the 'to' frame for background layer */ int width = layer_get_frame(w).size.w - BAR_WIDTH; int height = layer_get_frame(w).size.h; GRect backgroundTo = GRect(0,0,width,height); /* set the 'to' frame for draw layer */ width = layer_get_frame(w).size.w - BAR_WIDTH - 2 * DETAIL_OFFSET; height = layer_get_frame(w).size.h - HEADER_HEIGHT - DETAIL_SPACE - DETAIL_OFFSET; GRect layerTo = GRect(DETAIL_OFFSET, HEADER_HEIGHT + DETAIL_SPACE, width, height); /* set the 'to' frame for header*/ GRect headerTo = GRect(0,0,HEADER_WIDTH,HEADER_HEIGHT); /* set layer frames */ animations[BACKGROUND] = property_animation_create_layer_frame(graphicBackgroundLayer, NULL, &backgroundTo); animations[LAYER] = property_animation_create_layer_frame(graphicDrawLayer[inactive], NULL, &layerTo); animations[HEADER] = property_animation_create_layer_frame(text_layer_get_layer(graphicHeader[inactive]), NULL, &headerTo); /* set timing */ animation_set_duration((Animation *)animations[BACKGROUND], ANIMATION_SPEED); animation_set_duration((Animation *)animations[LAYER], ANIMATION_SPEED); animation_set_duration((Animation *)animations[HEADER], ANIMATION_SPEED); /* set handler ONLY for layer */ animation_set_handlers((Animation *) animations[LAYER], (AnimationHandlers) { .started = (AnimationStartedHandler) NULL, .stopped = (AnimationStoppedHandler) layer_animation_ended, }, NULL);
/* segment_show draws a segment with an animation */ void segment_show(Quadrant *quadrant, int id) { GRect visible = Segments[id].visible; GRect invisible = Segments[id].invisible; /* Ensures the segment is not animating to prevent bugs */ if(animation_is_scheduled(&quadrant->animations[id].animation)) { animation_unschedule(&quadrant->animations[id].animation); } property_animation_init_layer_frame(&quadrant->animations[id], &quadrant->segments[id], &invisible, &visible); animation_set_duration(&quadrant->animations[id].animation, AnimationTime); animation_set_curve(&quadrant->animations[id].animation, AnimationCurveLinear); animation_schedule(&quadrant->animations[id].animation); }
static void animate_hub_layer(GRect start, GRect finish) { if (animation_is_ongoing) { #ifdef PBL_SDK_2 animation_unschedule((Animation*)prop_anim); if (prop_anim) property_animation_destroy(prop_anim); prop_anim = NULL; #endif } animation_is_ongoing = true; prop_anim = property_animation_create_layer_frame(hub_layer, &start, &finish); animation_set_duration((Animation*)prop_anim, 1000); animation_set_handlers((Animation*)prop_anim, (AnimationHandlers) { .stopped = anim_stopped_handler }, NULL);
static void out_stopped_handler(Animation *animation, bool finished, void *context) { s_current_text += (s_current_text == 0) ? 1 : -1; text_layer_set_text(s_text_layer, s_text[s_current_text]); Layer *text_layer = text_layer_get_layer(s_text_layer); GRect frame = layer_get_frame(text_layer); GRect start = GRect(frame.origin.x + (2 * TEXT_ANIMATION_WINDOW_DISTANCE), frame.origin.y, frame.size.w, frame.size.h); GRect finish = GRect(frame.origin.x + TEXT_ANIMATION_WINDOW_DISTANCE, frame.origin.y, frame.size.w, frame.size.h); PropertyAnimation *in_prop_anim = property_animation_create_layer_frame(text_layer, &start, &finish); Animation *in_anim = property_animation_get_animation(in_prop_anim); animation_set_curve(in_anim, AnimationCurveEaseInOut); animation_set_duration(in_anim, TEXT_ANIMATION_WINDOW_DURATION); animation_schedule(in_anim); }
/** * Change the digit in given column, and animate the column by rolling * the newly selected digit into position (3rd row). **/ void set_digit(int col, int num) { Layer *layer = text_layer_get_layer(text_layer[col]); to_rect[col] = layer_get_frame(layer); to_rect[col].origin.y = (offsets[col][num] * -42) + center - 28; if (animations[col]) { property_animation_destroy(animations[col]); animations[col] = NULL; } animations[col] = property_animation_create_layer_frame(layer, NULL, &to_rect[col]); animation_set_duration((Animation*) animations[col], 1000); animation_schedule((Animation*) animations[col]); }
void animation_proceed(void) { Layer *layer = text_layer_get_layer(finish_text); GRect middle_rect = GRect(50, 74, 100, 24); destroy_property_animation(&prop_animation); prop_animation = property_animation_create_layer_frame(layer, NULL, &middle_rect); animation_set_duration((Animation*) prop_animation, 500); animation_set_curve((Animation*) prop_animation, AnimationCurveEaseInOut); animation_set_handlers((Animation*) prop_animation, (AnimationHandlers) { .started = (AnimationStartedHandler) animation_started, .stopped = (AnimationStoppedHandler) animation_stopped, }, NULL /* callback data */);
void mario_jump_animation_stopped(Animation *animation, void *data) { (void)animation; (void)data; text_layer_set_text(text_hour_layer, hour_text); text_layer_set_text(text_minute_layer, minute_text); if (!mario_animation_end) { mario_animation_end = property_animation_create_layer_frame(mario_layer, &mario_up_rect, &mario_down_rect); animation_set_duration((Animation *)mario_animation_end, MARIO_JUMP_DURATION); animation_set_curve((Animation *)mario_animation_end, AnimationCurveEaseIn); animation_set_handlers((Animation *)mario_animation_end, (AnimationHandlers){ .started = (AnimationStartedHandler)mario_down_animation_started, .stopped = (AnimationStoppedHandler)mario_down_animation_stopped }, 0);
static Animation* prv_create_slide_settle_animation(Layer *layer) { SelectionLayerData *data = layer_get_data(layer); PropertyAnimation *slide_settle_anim = property_animation_create_layer_frame(layer, NULL, NULL); Animation *animation = property_animation_get_animation(slide_settle_anim); animation_set_curve(animation, AnimationCurveEaseOut); animation_set_duration(animation, SLIDE_SETTLE_DURATION_MS); AnimationHandlers anim_handler = { .stopped = prv_slide_settle_stopped, }; animation_set_handlers(animation, anim_handler, layer); data->slide_settle_anim_impl = (AnimationImplementation) { .update = prv_slide_settle_impl, }; animation_set_implementation(animation, &data->slide_settle_anim_impl); return animation; }
static Animation *activity_indicator_layer_create_animation(Layer *layer) { Animation *animations[3]; const uint32_t duration = 1000; uint32_t from = 0, to = TRIG_MAX_ANGLE; animations[0] = ({ PropertyAnimation *property_animation = property_animation_create(&property_animation_implementation_stroke_start, layer, NULL, NULL); property_animation_from(property_animation, &from, sizeof(from), true); property_animation_to(property_animation, &to, sizeof(to), true); Animation *animation = (Animation *)property_animation; animation_set_custom_curve(animation, stroke_start_custom_curve); animation_set_delay(animation, duration * 2 / 3); animation_set_duration(animation, duration); animation_set_play_count(animation, ANIMATION_PLAY_COUNT_INFINITE); animation; });
void setup_bolt_animation() { int total_send_delay = 0; for(int x = 0; x < FRAME_COUNT - 1; x++) //-1 because animate_bolt looks at the current frame and the next frame in the array { bolt_animation[x] = property_animation_create_layer_frame(bitmap_layer_get_layer(bolt), &bolt_frames[x].frame, &bolt_frames[x + 1].frame); animation_set_duration((Animation*) bolt_animation[x], bolt_frames[x].duration); animation_set_delay((Animation*) bolt_animation[x], total_send_delay); animation_set_curve((Animation*) bolt_animation[x], AnimationCurveLinear); total_send_delay += bolt_frames[x].duration; if(x == FRAME_COUNT - 2) //-2 because that is the last item when the condition to break is < X - 1 { animation_set_handlers((Animation*) bolt_animation[x], (AnimationHandlers) { .started = (AnimationStartedHandler) bolt_animation_started, .stopped = (AnimationStoppedHandler) bolt_animation_stopped, }, NULL /* callback data */); }
static void show_event(int index) { int screen_count = s_active_item_count + 1; int height = bounds.size.h * (screen_count + 2); destroy_property_animation(&prop_animation); bool invert = false; GRect from_rect = GRect(0, -(current_item + 1) * bounds.size.h, bounds.size.w, height); if(index < 0) { index = screen_count - 1; from_rect.origin.y = -(screen_count + 1) * bounds.size.h; invert = true; } else if(index >= screen_count) { index = 0; from_rect.origin.y = 0; invert = true; } GRect to_rect = GRect(0, -(index + 1) * bounds.size.h, bounds.size.w, height); prop_animation = property_animation_create_layer_frame(events_layer, &from_rect, &to_rect); animation_set_duration((Animation*) prop_animation, 400); animation_schedule((Animation*) prop_animation); // if state is about to be shown or hidden then animate it if (index == 0 || current_item == 0) { int stateFrom = 0, stateTo = 0; if (current_item == 1) stateFrom = -1; else if (current_item > 1) stateFrom = 1; if (index == 1) stateTo = -1; else if (index > 1) stateTo = 1; if (invert && screen_count == 2) { stateFrom = -stateFrom; stateTo = -stateTo; } show_state(stateFrom, stateTo); } current_item = index; layer_mark_dirty(navi_layer); }
static Animation* prv_create_bump_text_animation(Layer *layer) { SelectionLayerData *data = layer_get_data(layer); PropertyAnimation *bump_text_anim = property_animation_create_layer_frame(layer, NULL, NULL); Animation *animation = property_animation_get_animation(bump_text_anim); animation_set_curve(animation, AnimationCurveEaseIn); animation_set_duration(animation, BUMP_TEXT_DURATION_MS); AnimationHandlers anim_handler = { .stopped = prv_bump_text_stopped, }; animation_set_handlers(animation, anim_handler, layer); data->bump_text_impl = (AnimationImplementation) { .update = prv_bump_text_impl, }; animation_set_implementation(animation, &data->bump_text_impl); return animation; }
EXTFN void chart_load(Window *window) { // Bring up chart chart_showing = true; chart_window = window; read_chart_data(); window_set_background_color(chart_window, BACKGROUND_COLOR); Layer *window_layer = window_get_root_layer(chart_window); GRect bounds = layer_get_bounds(window_layer); uint16_t width = bounds.size.w; int16_t centre = bounds.size.w / 2; macro_bitmap_layer_create(&chart_moon, MOON_START, window_layer, RESOURCE_ID_KEYBOARD_BG, true); #ifndef PBL_ROUND notice_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_DIGITAL_16)); chart_name_layer = macro_text_layer_create(GRect(5, 15, 134, 30), window_layer, GColorWhite, GColorClear, notice_font, GTextAlignmentRight); text_layer_set_text(chart_name_layer, APP_NAME); #endif window_set_click_config_provider(chart_window, (ClickConfigProvider) chart_click_config_provider); int16_t v_centre = bounds.size.h / 2; int16_t h_centre = bounds.size.w / 2; bar_height = bounds.size.h * 2 / 5 - 5; int16_t bar_top = v_centre - bar_height / 2; bar_width = bounds.size.w; int16_t bar_left = h_centre - bar_width / 2; #ifndef PBL_ROUND bar_top += 5; #endif chart_date = macro_text_layer_create(GRect(0, bar_top + bar_height - 5, width, 31), window_layer, GColorWhite, BACKGROUND_COLOR, fonts_get_system_font(FONT_KEY_GOTHIC_24), GTextAlignmentCenter); bar_layer = macro_layer_create(GRect(bar_left, bar_top, bar_width, bar_height), window_layer, &bar_layer_update_callback); moon_animation = property_animation_create_layer_frame(bitmap_layer_get_layer_jf(chart_moon.layer), &MOON_START, &MOON_FINISH); animation_set_duration((Animation*) moon_animation, 750); animation_set_handlers((Animation*) moon_animation, (AnimationHandlers ) { .stopped = (AnimationStoppedHandler) moon_animation_stopped, }, NULL /* callback data */);