mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
remove alpha from color utils
This commit is contained in:
parent
3742ee0330
commit
aec8059dbb
1 changed files with 6 additions and 22 deletions
|
|
@ -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)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue