void handle_minute_tick(AppContextRef ctx, PebbleTickEvent *t) { (void)t; (void)ctx; property_animation_init_layer_frame(&mouth_animation_beg, &mouth_layer, &mouth_from_rect, &mouth_to_rect); property_animation_init_layer_frame(&jaw_animation_beg, &jaw_layer, &jaw_from_rect, &jaw_to_rect); animation_set_handlers(&mouth_animation_beg.animation, (AnimationHandlers) { .started = (AnimationStartedHandler) animation_started, .stopped = (AnimationStoppedHandler) animation_stopped }, &ctx);
void animation_stopped(Animation *animation, void *data) { (void)animation; (void)data; text_layer_set_text(&text_time_layer, time_text); property_animation_init_layer_frame(&mouth_animation_end, &mouth_layer, &mouth_to_rect, &mouth_from_rect); property_animation_init_layer_frame(&jaw_animation_end, &jaw_layer, &jaw_to_rect, &jaw_from_rect); animation_schedule(&mouth_animation_end.animation); animation_schedule(&jaw_animation_end.animation); }
void init_animations() { property_animation_init_layer_frame(&up_animation, &text_time_layer.layer, &LOWER_TO_RECT, &UPPER_TO_RECT); animation_set_duration(&up_animation.animation, ANIMATION_DURATION_IN_MS); animation_set_curve(&up_animation.animation, AnimationCurveEaseOut); property_animation_init_layer_frame(&down_animation, &text_time_layer.layer, &UPPER_TO_RECT, &LOWER_TO_RECT); animation_set_duration(&down_animation.animation, ANIMATION_DURATION_IN_MS); animation_set_curve(&down_animation.animation, AnimationCurveEaseOut); }
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); } }
/* 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); }
void handle_init(AppContextRef ctx) { window_init(&window, "Animation Demo"); window_stack_push(&window, false); text_layer_init(&text_layer, GRect(0, 0, 60, 60)); text_layer_set_text(&text_layer, "Text!"); layer_add_child(&window.layer, &text_layer.layer); GRect to_rect = GRect(84, 92, 60, 60); property_animation_init_layer_frame(&prop_animation, &text_layer.layer, NULL, &to_rect); animation_schedule(&prop_animation.animation); }
static void text_layer( word_t * word, GRect frame, GFont font ) { text_layer_setup(&window, &word->layer, frame, font); GRect frame_right = frame; frame_right.origin.x = 150; property_animation_init_layer_frame( &word->anim, &word->layer.layer, &frame_right, &frame ); animation_set_duration(&word->anim.animation, 500); animation_set_curve(&word->anim.animation, AnimationCurveEaseIn); }
void scroll_layer_set_content_offset(ScrollLayer *scroll_layer, GPoint offset, bool animated) { if (gpoint_equal(&scroll_layer->content_sublayer.frame.origin,&offset)) return; offset.x=0; GPoint oldOffset=scroll_layer_get_content_offset(scroll_layer); GRect to=scroll_layer_get_new_content_rect(scroll_layer,offset); if (animated) { property_animation_init_layer_frame(&scroll_layer->animation,&scroll_layer->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_layer->animation,duration); animation_schedule((Animation*)&scroll_layer->animation); } else { scroll_layer->content_sublayer.frame.origin=offset; layer_mark_dirty((Layer*)scroll_layer); } if (scroll_layer->callbacks.content_offset_changed_handler!=0) scroll_layer->callbacks.content_offset_changed_handler(scroll_layer,scroll_layer->context); }