Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jeffreymorganio/nscolor-components
A Swift extension to NSColor that provides easy access to its RGB and HSB components.
https://github.com/jeffreymorganio/nscolor-components
cocoa nscolor swift
Last synced: 13 days ago
JSON representation
A Swift extension to NSColor that provides easy access to its RGB and HSB components.
- Host: GitHub
- URL: https://github.com/jeffreymorganio/nscolor-components
- Owner: jeffreymorganio
- License: mit
- Created: 2016-03-01T16:07:29.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2020-08-14T21:27:08.000Z (over 4 years ago)
- Last Synced: 2024-12-21T22:46:43.583Z (13 days ago)
- Topics: cocoa, nscolor, swift
- Language: Swift
- Size: 8.79 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# nscolor-components
`NSColorComponents` is a Swift extension to `NSColor` that provides easy access to the RGB and HSB components of an `NSColor`.
## Integration
Configure your Podfile to use `NSColorComponents`:
```
platform :osx
use_frameworks!target 'MyApp' do
pod 'NSColorComponents', :git => 'https://github.com/jeffreymorganio/nscolor-components'
end
```## Use
The `NSColorComponents` extension to `NSColor` adds properties that return tuples of the red, green, blue and alpha components and the hue, saturation, brightness and alpha components.
### RGB Components
The `CGFloatRGB` property returns a tuple of the red, green, blue and alpha components as `CGFloat` values between 0 and 1:
```
if let (red, green, blue, alpha) = NSColor.redColor().CGFloatRGB {
...
}
```The `IntRGB` property returns a tuple of the red, green, blue and alpha components as `Int` values between 0 and 255:
```
if let (red, green, blue, alpha) = NSColor.redColor().IntRGB {
...
}
```### HSB Components
The `CGFloatHSB` property returns a tuple of the hue, saturation, brightness and alpha components as `CGFloat` values between 0 and 1:
```
if let (hue, saturation, brightness, alpha) = NSColor.redColor().CGFloatHSB {
...
}
```The `IntHSB` property returns a tuple of the hue, saturation, brightness and alpha components as `Int` values between 0 and 255:
```
if let (hue, saturation, brightness, alpha) = NSColor.redColor().IntHSB {
...
}
```