Swiftpack.co - CaptureContext/Palette as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by CaptureContext.
CaptureContext/Palette 5.0.0
Static Factory of Generic Colors
⭐️ 3
🕓 2 years ago
.package(url: "https://github.com/CaptureContext/Palette.git", from: "5.0.0")

SwiftPM Mac & Linux Twitter: @maximkrouk

Platform agnostic static factory of colors.

Usage

import Palette
let color1 = Color<RGB>.pantone(.classicBlue()) // Pantone color of 2020
let color2 = Color<RGB>.web(.skyBlue()) // WebColor SkyBlue
let color3 = Color<RGB>.fuchsia // The same as magenta
let color4 = Color<RGB>.iOS(.systemRed())
let color5 = Color<RGB>.iOS(.systemRed(.light))
let color6 = Color<RGB>.iOS(.systemRed(.dark))

Compatibility with NSColor/UIColor:

func setTextColor(_ color: Color<RGB>, to label: UILabel) {
    label.textColor = .init(color)
}

func getTextColor(from label: UILabel) -> Color<RGB> {
    label.textColor.genericRGB
}

Installation

Add the package to Your SwiftPM package dependencies:

.package(
    url: "https://github.com/MakeupStudio/Palette.git", 
    from: "4.0.0-beta.3.0"
)

then add Palette dependency to your target.

Licence

MIT

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics