Skip to content

Commit 89c8734

Browse files
committed
NSColor.hexString
1 parent 195546e commit 89c8734

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

ColorSetKit/NSColor+ColorSetKit.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,13 @@ import Cocoa
141141
self.init( srgbRed: rgb.0, green: rgb.1, blue: rgb.2, alpha: alpha )
142142
}
143143

144+
@objc var hexString: String
145+
{
146+
let rgb = self.rgb()
147+
148+
return String( format: "#%02X%02X%02X", Int( rgb.red * 255 ), Int( rgb.green * 255 ), Int( rgb.blue * 255 ) )
149+
}
150+
144151
@objc func getHue( _ hue: UnsafeMutablePointer< CGFloat >?, saturation: UnsafeMutablePointer< CGFloat >?, lightness: UnsafeMutablePointer< CGFloat >?, alpha: UnsafeMutablePointer< CGFloat >? )
145152
{
146153
var r: CGFloat = 0.0

0 commit comments

Comments
 (0)