-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for animating startPoint
and endPoint
of radial gradients
#1798
Conversation
/// Combines the given keyframe groups of `Keyframe<T>`s into a single keyframe group of of `Keyframe<[T]>`s | ||
/// - If all of the `KeyframeGroup`s have the exact same animation timing, the keyframes are merged | ||
/// - Otherwise, the keyframes are manually interpolated at each frame in the animation | ||
static func combined<T>(_ allGroups: [KeyframeGroup<T>]) -> KeyframeGroup<[T]> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These methods were renamed from Keyframes.combinedIfPossible(...) -> KeyframeGroup?
to Keyframes.combined(...) -> KeyframeGroup
else { | ||
// If the keyframes don't all share the same timing information, | ||
// we have to interpolate the value at each individual frame | ||
return Keyframes.manuallyInterpolated(allGroups, makeCombinedResult: makeCombinedResult) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the only new logic in this method (previously this was just return nil
)
return KeyframeGroup(keyframes: combinedKeyframes) | ||
} | ||
|
||
private static func manuallyInterpolated<CombinedResult>( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method is new
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! Nice cleanup too
/// Combines the given keyframe groups of `Keyframe<T>`s into a single keyframe group of of `Keyframe<[T]>`s | ||
/// - If all of the `KeyframeGroup`s have the exact same animation timing, the keyframes are merged | ||
/// - Otherwise, the keyframes are manually interpolated at each frame in the animation | ||
static func combined<T1, T2, T3, T4, T5, T6, T7, CombinedResult>( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could really use "row polymorphism" for this one! 😂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please, variadic generics when
This PR adds support for animating the
startPoint
andendPoint
of radial gradients. We can do this by combining the two sets of keyframes into a singleKeyframeGroup
, manually interpolating them if necessary. Fixes #1762.I took this opportunity to consolidate the manual interpolation functionality into
Keyframes.combined
, and also adopt this in most other places where we were usingKeyframeGroup.exactlyOneKeyframe
.