Fix lint warnings

This commit is contained in:
Sven Weidauer 2021-01-02 22:43:26 +01:00
parent ba7c0c04fa
commit e6f44f5be2

View file

@ -2,26 +2,35 @@ extension Color {
init(hue: Int, saturation: UInt8, value: UInt8, alpha: UInt8 = 0xFF) {
let degrees = abs(hue % 360)
let s = Double(saturation) / 0xFF
let v = Double(value) / 0xFF
let C = s * v
let saturation = Double(saturation) / 0xFF
let value = Double(value) / 0xFF
// swiftlint:disable identifier_name - Wish I knew what these actually mean.
let C = saturation * value
let X = C * (1 - abs((Double(degrees) / 60).truncatingRemainder(dividingBy: 2) - 1))
let m = v - C
let m = value - C
// swiftlint:enable identifier_name
let result: (r: Double, g: Double, b: Double)
switch degrees {
case 0..<60:
result = (C, X, 0)
case 60..<120:
result = (X, C, 0)
case 120..<180:
result = (0, C, X)
case 180..<240:
result = (0, X, C)
case 240..<300:
result = (X, 0, C)
case 300..<360:
result = (C, 0, X)
default:
fatalError("Degrees out of range")
}