Swiftpack.co - kaishin/Kroma as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by kaishin.
kaishin/Kroma v0.1.0
A collection of color helpers for SwiftUI.
⭐️ 15
🕓 1 year ago
iOS macOS tvOS
.package(url: "https://github.com/kaishin/Kroma.git", from: "v0.1.0")

Kroma 🟥🟩🟦

Test GitHub release Swift 5.3 platforms

A collection of color extensions and utilities for SwiftUI.

Install

Swift Package Manager (Standalone)

Add Korma as a dependency in your Package.swift file:

dependencies: [
  ...
 .package(url: "https://github.com/kaishin/Kroma.git", from: "0.1.0")
]

Swift Package Manager (Xcode)

Add https://github.com/kaishin/Kroma.git as a dependency in the Swift Packages tab of the Xcode project.

Usage

Inspect Color Components

Color.purple.rgbComponents
// -> (0.68, 0.32, 0.87)

Convert to Other Representations

Color.purple.rgbComponents.toHSB()
// -> (0.77, 0.63, 0.87)

Lighten or Darken a Color

Logo
Color.purple.rgbComponents // (0.686, 0.322, 0.871)
Color.purple.lighter(by: 0.1).rgbComponents // (0.88, 0.52, 1.0)
Color.purple.darker(by: 0.1).rgbComponents // (0.48, 0.12, 0.67)

Get Luma Value of a Color

Color.purple.luma // 0.438744325864315

You can read more on luma here.

Check if a Color is Perceived as Light or Dark

Color.purple.isLight // false
Color.white.isLight // true
Color.yellow.isLight // true
Color.red.isLight // false

License

See LICENSE.

GitHub

link
Stars: 15
Last commit: 1 year ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Release Notes

1 year ago

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