Fix lint warnings
This commit is contained in:
parent
ba7c0c04fa
commit
e6f44f5be2
1 changed files with 13 additions and 4 deletions
|
@ -2,26 +2,35 @@ extension Color {
|
||||||
init(hue: Int, saturation: UInt8, value: UInt8, alpha: UInt8 = 0xFF) {
|
init(hue: Int, saturation: UInt8, value: UInt8, alpha: UInt8 = 0xFF) {
|
||||||
let degrees = abs(hue % 360)
|
let degrees = abs(hue % 360)
|
||||||
|
|
||||||
let s = Double(saturation) / 0xFF
|
let saturation = Double(saturation) / 0xFF
|
||||||
let v = Double(value) / 0xFF
|
let value = Double(value) / 0xFF
|
||||||
let C = s * v
|
|
||||||
|
// 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 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)
|
let result: (r: Double, g: Double, b: Double)
|
||||||
switch degrees {
|
switch degrees {
|
||||||
case 0..<60:
|
case 0..<60:
|
||||||
result = (C, X, 0)
|
result = (C, X, 0)
|
||||||
|
|
||||||
case 60..<120:
|
case 60..<120:
|
||||||
result = (X, C, 0)
|
result = (X, C, 0)
|
||||||
|
|
||||||
case 120..<180:
|
case 120..<180:
|
||||||
result = (0, C, X)
|
result = (0, C, X)
|
||||||
|
|
||||||
case 180..<240:
|
case 180..<240:
|
||||||
result = (0, X, C)
|
result = (0, X, C)
|
||||||
|
|
||||||
case 240..<300:
|
case 240..<300:
|
||||||
result = (X, 0, C)
|
result = (X, 0, C)
|
||||||
|
|
||||||
case 300..<360:
|
case 300..<360:
|
||||||
result = (C, 0, X)
|
result = (C, 0, X)
|
||||||
|
|
||||||
default:
|
default:
|
||||||
fatalError("Degrees out of range")
|
fatalError("Degrees out of range")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue