Skip to content

Instantly share code, notes, and snippets.

View Exey's full-sized avatar

Exey Panteleev Exey

View GitHub Profile
@Exey
Exey / ColorAnimation.swift
Created September 15, 2021 16:48
ColorAnimation.swift
private struct ColorAnimation: AnimatableModifier {
var animatableData: Double
private let rgbaPair: [(Double, Double)]
init(from: Color, to: Color, percentToColor: Double) {
animatableData = percentToColor
let fromComponents = UIColor(from).cgColor.components!
let toComponents = UIColor(to).cgColor.components!
rgbaPair = Array(zip(fromComponents.map(Double.init), toComponents.map(Double.init)))