static void animate_angle(PropertyAnimation* animation, Needle* needle, int16_t angle, int duration) { animation = property_animation_create(&angle_animation, needle, NULL, NULL); animation->values.from.int16 = needle->angle; animation->values.to.int16 = angle; animation_set_handlers((Animation*) animation, (AnimationHandlers) { .stopped = animation_stopped_handler }, NULL);
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; });
PropertyAnimation* property_animation_create_layer_frame (Layer* layer,GRect* from,GRect* to) { return property_animation_create (&layer_property_animation_implementation,layer,from,to); }
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; }); animations[1] = ({ PropertyAnimation *property_animation = property_animation_create(&property_animation_implementation_stroke_end, 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_end_custom_curve); animation_set_duration(animation, duration * 5 / 3); animation_set_play_count(animation, ANIMATION_PLAY_COUNT_INFINITE); animation; }); animations[2] = ({ PropertyAnimation *property_animation = property_animation_create(&property_animation_implementation_rotation, layer, NULL, NULL); property_animation_from(property_animation, &from, sizeof(from), true); property_animation_to(property_animation, &to, sizeof(to), true);