remove alpha from color utils

This commit is contained in:
Satindar Dhillon 2022-04-05 14:26:38 -07:00
parent 3742ee0330
commit aec8059dbb

View file

@ -23,7 +23,6 @@ public extension Color {
red = CGFloat((rgb & 0xFF0000) >> 16) / 255.0
green = CGFloat((rgb & 0x00FF00) >> 8) / 255.0
blue = CGFloat(rgb & 0x0000FF) / 255.0
} else if length == 8 {
red = CGFloat((rgb & 0xFF00_0000) >> 24) / 255.0
green = CGFloat((rgb & 0x00FF_0000) >> 16) / 255.0
@ -53,27 +52,12 @@ public extension Color {
let red = Float(components[0])
let green = Float(components[1])
let blue = Float(components[2])
var alpha = Float(1.0)
if components.count >= 4 {
alpha = Float(components[3])
}
if alpha != Float(1.0) {
return String(
format: "%02lX%02lX%02lX%02lX",
lroundf(red * 255),
lroundf(green * 255),
lroundf(blue * 255),
lroundf(alpha * 255)
)
} else {
return String(
format: "%02lX%02lX%02lX",
lroundf(red * 255),
lroundf(green * 255),
lroundf(blue * 255)
)
}
return String(
format: "%02lX%02lX%02lX",
lroundf(red * 255),
lroundf(green * 255),
lroundf(blue * 255)
)
}
}