diff --git a/SignalMessaging/Loki/JazzIcon.swift b/SignalMessaging/Loki/JazzIcon.swift index aedbba8a4..6d8d14b97 100644 --- a/SignalMessaging/Loki/JazzIcon.swift +++ b/SignalMessaging/Loki/JazzIcon.swift @@ -141,6 +141,6 @@ public class JazzIcon { private func hueShift(colours: [UIColor]) -> [UIColor] { let amount = generator.nextCGFloat() * 30 - CGFloat(wobble / 2); - return colours.map { $0.adjust(hueBy: amount / 360.0) } + return colours.map { $0.adjust(hueBy: amount) } } } diff --git a/SignalMessaging/utils/UIColor+Helper.swift b/SignalMessaging/utils/UIColor+Helper.swift index 4c229c4f4..9fa3b9657 100644 --- a/SignalMessaging/utils/UIColor+Helper.swift +++ b/SignalMessaging/utils/UIColor+Helper.swift @@ -1,6 +1,5 @@ extension UIColor { - - public func adjust(hueBy hue: CGFloat = 0, saturationBy saturation: CGFloat = 0, brightnessBy brightness: CGFloat = 0) -> UIColor { + public func adjust(hueBy degrees: CGFloat) -> UIColor { var currentHue: CGFloat = 0.0 var currentSaturation: CGFloat = 0.0 @@ -8,10 +7,15 @@ extension UIColor { var currentAlpha: CGFloat = 0.0 if getHue(¤tHue, saturation: ¤tSaturation, brightness: ¤tBrigthness, alpha: ¤tAlpha) { - return UIColor(hue: currentHue + hue, - saturation: currentSaturation + saturation, - brightness: currentBrigthness + brightness, - alpha: currentAlpha) + // Round values so we get closer values to Desktop + let currentHueDegrees = (currentHue * 360.0).rounded() + let normalizedDegrees = fmod(degrees, 360.0).rounded() + let newHue = (currentHueDegrees + normalizedDegrees) / 360.0 + + return UIColor(hue: newHue, + saturation: currentSaturation, + brightness: currentBrigthness, + alpha: 1.0) } else { return self }