Swiftpack.co - sersoft-gmbh/color-components as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
A color component calculation library
.package(url: "https://github.com/sersoft-gmbh/color-components.git", from: "1.6.0")

Color Components

GitHub release Tests Codacy Badge codecov jazzy

A color component calculation library written in Swift.


Add the following dependency to your Package.swift:

.package(url: "https://github.com/sersoft-gmbh/color-components.git", from: "1.0.0"),

Or add it via Xcode (as of Xcode 11).


There are currently three color component implementations included in ColorComponents:

  • BW & BWA
  • HSB & HSBA
  • RGB & RGBA

Each implementation is generic and supports both integer values (0 - 255) and floating point values (0.0 - 1.0). Also, each implementation allows converting between them.

If available, each implementation also provides conversion options from and to the platform native colors (e.g. UIColor on iOS, tvOS & watchOS and NSColor on macOS). SwiftUI.Color is also supported as of macOS 11, iOS 14, tvOS 14 and watchOS 7. Due to the lack of direct component accessors, SwiftUI.Color support goes through the aforementioned platform colors.

Possible Features

While not yet integrated, the following features might provide added value and could make it into this package in the future:

  • CMYK color components.
  • Color space support.
  • More ways of converting between the components.


The API is documented using header doc. If you prefer to view the documentation as a webpage, there is an online version available for you.


If you find a bug / like to see a new feature in this package there are a few ways of helping out:

  • If you can fix the bug / implement the feature yourself please do and open a PR.
  • If you know how to code (which you probably do), please add a (failing) test and open a PR. We'll try to get your test green ASAP.
  • If you can do neither, then open an issue. While this might be the easiest way, it will likely take the longest for the bug to be fixed / feature to be implemented.


See LICENSE file.


Stars: 3
Last commit: 1 week ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Submit a free job ad (while I'm testing this). The analytics numbers for this website are here.

Release Notes

24 weeks ago
  • Add Swift 5.4 support

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