Skip to content

Instantly share code, notes, and snippets.

@OdNairy
Created May 24, 2023 13:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save OdNairy/8dd5c96e055694daf9074a3b62633ce9 to your computer and use it in GitHub Desktop.
Save OdNairy/8dd5c96e055694daf9074a3b62633ce9 to your computer and use it in GitHub Desktop.
func generateSunColor(progress: Double) -> UIColor {
if progress < 0.2 {
return interpolateColor(from: .white,
to: UIColor(red: 255/255, green: 242/255, blue: 0/255, alpha: 1), // Yellow
with: (progress) / 0.2)
} else if progress < 0.4 {
return interpolateColor(from: UIColor(red: 255/255, green: 242/255, blue: 0/255, alpha: 1), // Yellow
to: .white,
with: (progress - 0.2) / 0.2)
} else if progress < 0.7 {
return .white
} else if progress <= 0.85 {
return interpolateColor(from: .white,
to: UIColor(red: 255/255, green: 180/255, blue: 0/255, alpha: 1),
with: (progress - 0.7) / 0.15)
} else {
return interpolateColor(from: UIColor(red: 255/255, green: 180/255, blue: 0/255, alpha: 1),
to: UIColor(red: 204/255, green: 51/255, blue: 0/255, alpha: 1),
with: (progress - 0.85) / 0.15)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment