All Projects → 1024jp → Wfcolorcode

1024jp / Wfcolorcode

Licence: mit
NSColor extension adding ability to handle HSL color space and CSS3 style color codes

Programming Languages

swift
15916 projects

Labels

Projects that are alternatives of or similar to Wfcolorcode

Coteditor
Lightweight Plain-Text Editor for macOS
Stars: ✭ 4,129 (+25706.25%)
Mutual labels:  cocoa
Fluentui Apple
UIKit and AppKit controls for building native Microsoft experiences
Stars: ✭ 459 (+2768.75%)
Mutual labels:  cocoa
Orsserialport
Serial port library for Objective-C and Swift macOS apps
Stars: ✭ 609 (+3706.25%)
Mutual labels:  cocoa
Realm Tasks
To Do app built with Realm, inspired by Clear for iOS
Stars: ✭ 369 (+2206.25%)
Mutual labels:  cocoa
Githubupdates
Cocoa framework to install application updates from GitHub releases.
Stars: ✭ 393 (+2356.25%)
Mutual labels:  cocoa
Midiapps
MIDI apps for Mac OS X: MIDI Monitor and SysEx Librarian.
Stars: ✭ 488 (+2950%)
Mutual labels:  cocoa
Stprivilegedtask
An NSTask-like wrapper around the macOS Security Framework's AEWP function to run shell commands with root privileges in Objective-C / Cocoa.
Stars: ✭ 335 (+1993.75%)
Mutual labels:  cocoa
Scrooge
A Thrift parser/generator
Stars: ✭ 724 (+4425%)
Mutual labels:  cocoa
Seaglass
A truly native Matrix client for macOS - written in Swift/Cocoa, with E2E encryption support
Stars: ✭ 428 (+2575%)
Mutual labels:  cocoa
Strongbox
A KeePass/Password Safe Client for iOS and OS X
Stars: ✭ 586 (+3562.5%)
Mutual labels:  cocoa
Sentry Cocoa
The official Sentry SDK for iOS, tvOS, macOS, watchOS
Stars: ✭ 370 (+2212.5%)
Mutual labels:  cocoa
Segmentedprogressbar
Snapchat / Instagram Stories like progress indicator
Stars: ✭ 376 (+2250%)
Mutual labels:  cocoa
Brisk
✨Cross-platform set of tools for building native UIs with Reason/OCaml
Stars: ✭ 518 (+3137.5%)
Mutual labels:  cocoa
Wxwidgets
wxWidgets is a free and open source cross-platform C++ framework for writing advanced GUI applications using native controls.
Stars: ✭ 3,994 (+24862.5%)
Mutual labels:  cocoa
Latest
A small utility app for macOS that makes sure you know about all the latest updates to the apps you use.
Stars: ✭ 657 (+4006.25%)
Mutual labels:  cocoa
Cocoaseeds
Git Submodule Alternative for Cocoa.
Stars: ✭ 340 (+2025%)
Mutual labels:  cocoa
Swiftai
SwiftAI, write Swift code smart. SwiftAI can generate Model class from JSON now. Codable and HandyJSON is supported. More features will be add.
Stars: ✭ 470 (+2837.5%)
Mutual labels:  cocoa
Nswindowstyles
A showcase of the many different styles of windows possible with NSWindow on macOS
Stars: ✭ 801 (+4906.25%)
Mutual labels:  cocoa
Xit
Mac OS X Git GUI
Stars: ✭ 700 (+4275%)
Mutual labels:  cocoa
Vimr
Project VimR is a Neovim GUI for macOS. The goal is to build an editor that uses Neovim inside with many of the convenience GUI features similar to those present in modern editors. We mainly use Swift, but also use C/Objective-C when where appropriate.
Stars: ✭ 5,524 (+34425%)
Mutual labels:  cocoa

WFColorCode

Test Status SwiftPM compatible

WFColorCode is a NSColor extension that allows creating NSColor instance from a CSS color code string, or color code string from a NSColor instance. It also adds the ability to handle HSL color space.

  • Requirements: OS X 10.10 or later

Usage

WFColorCode supports the following color code styles.

/// color code type
enum ColorCodeType: Int {
    case hex        // #ffffff
    case shortHex   // #fff
    case cssRGB     // rgb(255,255,255)
    case cssRGBa    // rgba(255,255,255,1)
    case cssHSL     // hsl(0,0%,100%)
    case cssHSLa    // hsla(0,0%,100%,1)
    case cssKeyword // White
};

Example

Import ColorCode to use.

import ColorCode

// create NSColor instance from HSLa color code
var type: ColorCodeType?
let whiteColor = NSColor(colorCode: "hsla(0,0%,100%,0.5)", type: &type)
let hex: String = whiteColor.colorCode(type: .hex)  // => "#ffffff"

// create NSColor instance from HSLa values
let color = NSColor(deviceHue:0.1, saturation:0.2, lightness:0.3, alpha:1.0)

// create NSColor instance from a CSS3 keyword
let ivoryColor = NSColor(colorCode: "ivory")

// get HSL values from NSColor instance
var hue: CGFloat = 0
var saturation: CGFloat = 0
var lightness: CGFloat = 0
var alpha: CGFloat = 0
color.getHue(hue: &hue, saturation: &saturation, lightness: &lightness, alpha: &alpha)

Installation

Swift Package Manager

WFColorCode is SwiftPM compatible.

Source files

If you don't use SwiftPM, place NSColor+ColorCode.swift and NSColor+HSL.swift in Sources/ColorCode/ directory somewhere in your project.

License

© 2014-2020 1024jp.

The source code is distributed under the terms of the MIT License. See the bundled LICENSE for details.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].