@@ -15,6 +15,19 @@ public extension UIColor {
1515 /// - isUppercase: whether the hex values should be upper or lower case
1616 /// - Returns: the formatted hexadecimal string
1717 func rgbDisplayString( prefix: String ? = nil , isUppercase: Bool = true ) -> String {
18+ _rgbDisplayString ( prefix: prefix, isUppercase: isUppercase, isDebug: false )
19+ }
20+
21+ /// Formats a color as an RGB hexadecimal string. Appropriate for debug printing.
22+ /// - Parameters:
23+ /// - prefix: optional prefix to precede the hexadecimal value such as `0x` or `#` (default = nil)
24+ /// - isUppercase: whether the hex values should be upper or lower case
25+ /// - Returns: the formatted hexadecimal string (with an `⚠️` for colors that fall outside of the sRGB color space)
26+ func rgbDebugDisplayString( prefix: String ? = nil , isUppercase: Bool = true ) -> String {
27+ _rgbDisplayString ( prefix: prefix, isUppercase: isUppercase, isDebug: true )
28+ }
29+
30+ private func _rgbDisplayString( prefix: String ? , isUppercase: Bool , isDebug: Bool ) -> String {
1831 let comp = rgbaComponents
1932 let format = isUppercase ? " %02X%02X%02X " : " %02x%02x%02x "
2033 let r = Int ( round ( comp. red * 255 ) )
@@ -30,6 +43,6 @@ public extension UIColor {
3043 if !isRGB && YCoreUI . isLoggingEnabled {
3144 YCoreUI . colorLogger. warning ( " Color \( self ) falls outside of the sRGB color space. " )
3245 }
33- return " \( prefix ?? " " ) \( value) \( isRGB ? " " : " ⚠️ " ) "
46+ return " \( prefix ?? " " ) \( value) \( isDebug && ! isRGB ? " ⚠️ " : " " ) "
3447 }
3548}
0 commit comments