All Projects β†’ Boris-Em β†’ Colorkit

Boris-Em / Colorkit

Licence: mit
Advanced color manipulation for iOS.

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Colorkit

ColorHelper
No description or website provided.
Stars: ✭ 34 (-91.24%)
Mutual labels:  hex, color
colorsys
🎨 Minimalistic color converter for RGB, HSV, HSL, CMYK, HEX and CSS strings
Stars: ✭ 53 (-86.34%)
Mutual labels:  hex, color
react-color
🎨 Is a tiny color picker widget component for React apps.
Stars: ✭ 50 (-87.11%)
Mutual labels:  hex, color
khroma
A collection of functions for manipulating CSS colors, inspired by SASS.
Stars: ✭ 28 (-92.78%)
Mutual labels:  hex, color
colorsys.rs
Lib for modifying colors and converting to other spaces
Stars: ✭ 28 (-92.78%)
Mutual labels:  hex, color
dehex
πŸŽ¨πŸ‘€ R package: learn to assess a colour hex code by eye
Stars: ✭ 29 (-92.53%)
Mutual labels:  hex, color
Farge
🎈Tell the name of hex color
Stars: ✭ 23 (-94.07%)
Mutual labels:  hex, color
Xcodecolorsense
🎈 An Xcode plugin that makes working with color easier
Stars: ✭ 79 (-79.64%)
Mutual labels:  hex, color
utils.js
πŸ‘· πŸ”§ zero dependencies vanilla JavaScript utils.
Stars: ✭ 14 (-96.39%)
Mutual labels:  hex, color
hex-to-css-filter
Easy way to generate colors from HEX to CSS Filters
Stars: ✭ 20 (-94.85%)
Mutual labels:  hex, color
Dynamiccolor
Yet another extension to manipulate colors easily in Swift and SwiftUI
Stars: ✭ 2,677 (+589.95%)
Mutual labels:  hex, color
Xcodecolorsense2
πŸ‰ An Xcode source editor extension that shows hex color info
Stars: ✭ 281 (-27.58%)
Mutual labels:  hex, color
Color
A little library to deal with color conversions
Stars: ✭ 166 (-57.22%)
Mutual labels:  hex, color
noire
🎨 Light/darken, mix, (de)saturate the colors in Golang with CMYK / RGB / HSV / HSL / Hex / HTML supported.
Stars: ✭ 38 (-90.21%)
Mutual labels:  hex, color
Values.js
πŸ‡ Get the tints and shades of a color
Stars: ✭ 97 (-75%)
Mutual labels:  hex, color
colour
Validate colours.
Stars: ✭ 31 (-92.01%)
Mutual labels:  hex, color
React Colorful
🎨 A tiny (2,5 KB) color picker component for React and Preact apps
Stars: ✭ 951 (+145.1%)
Mutual labels:  hex, color
Colorhighlight
🎨 Lightweight Color Highlight colorizer for Sublime Text
Stars: ✭ 76 (-80.41%)
Mutual labels:  hex, color
color
A library of well-tested helper methods for working with colors.
Stars: ✭ 13 (-96.65%)
Mutual labels:  hex, color
Culori
A comprehensive color library for JavaScript.
Stars: ✭ 271 (-30.15%)
Mutual labels:  hex, color

ColorKit

ColorKit is your companion to work with colors on iOS.

Build MIT License Swift 5.1

Features

Dominant Colors

ColorKit makes it easy to find the dominant colors of an image. It returns a color palette of the most common colors on the image.

let dominantColors = try image.dominantColors()

By default, ColorKit uses an iterative process to determine the dominant colors of an image. But it also supports doing so via a k-mean clustering algorithm. Choose whichever is more appropriate for your use case.


Color Palette

ColorKit lets you generate color palettes from a collection of colors. It will automatically ensure that the best colors are picked based on a few configurable parameters like contrast ratio.
This feature is particularly powerful when combined with the dominant color calculation.

let colors = try image.dominantColors()
let palette = ColorPalette(orderedColors: colors, ignoreContrastRatio: true)

The following examples use the palette to dynamically match the color of the text and background to the album covers.


Average Color

To compute the average color of an image, simply call the averageColor function on a UIImage instance.

let averageColor = try image.averageColor()

Color Difference (DeltaE)

Perceptual color difference / comparaison is a common problem of color science.
It simply consists of calculating how different two colors look from each other, to the human eye. This is commonly referenced as the DeltaE.

ColorKit makes it a breaze to compare two colors.

let colorDifference = UIColor.green.difference(from: .white) // 120.34

While this may seem trivial, simply using the RGB color model often yields non-accurate results for human perception. This is because RGB is not perceptually uniform.

Here is an example highlighting the limitations of using the RGB color model to compare colors.

As you can see, the difference between the two greens (left) is considered greater than the difference between the pink and gray colors (right). In other words, the pink and gray are considered to look more similar than the two greens.
This obviously does not match the expectation of the human eye.

Thankfully, ColorKit provides algorithms that make it possible to compare colors just like the human eye would: CIE76, CIE94 and CIEDE2000.

let colorDifference = UIColor.green.difference(from: .white, using: .CIE94) 

Here is the same example as above, using the CIE94 algorithm.

The CIE94 algorithm successfuly realizes that the two greens (left) look closer from each other than the pink and gray (right) do.

More information about color difference can be found here.


Contrast Ratio

To calculate the contrast ratio between two colors, simply use the contrastRatio function.

let contrastRatio = UIColor.green.contrastRatio(with: UIColor.white)

The contrast ratio is particularly important when displaying text. To ensure that it's readable by everyone, ColorKit makes it easy for you to follow the accessibility guidelines set by WCAG 2.


Color Space Conversions

ColorKit assists you when translating a color from a color space to another. They're simply supported as extensions on UIColor.
CIELAB, XYZ and CMYK are supported.


More

There is a lot more that ColorKit is capable of. Here is a short list of examples:

  • Working with Hex color codes
let hexValue = UIColor.green.hex
let color = UIColor(hex: "eb4034")
  • Generating random colors
let randomColor = UIColor.random()
  • Calculating the relative luminance of a color
let relativeLuminance = UIColor.green.relativeLuminance
  • Generating complementary colors
let complementaryColor = UIColor.green.complementaryColor

Installation

Swift Package Manager

The Swift Package Manager is the easiest way to install and manage ColorKit as a dependecy.
Simply add ColorKit to your dependencies in your Package.swift file:

dependencies: [
    .package(url: "https://github.com/Boris-Em/ColorKit.git")
]

Alternatively, you can also use XCode to add ColorKit to your existing project, by using File > Swift Packages > Add Package Dependency....

Manually

ColorKit can also be added to your project manually. Download the ColorKit project from Github, then drag and drop the folder ColorKit/ColorKit into your XCode project.

Sample Project

Use the iOS sample project included in this repository to find comprehensive examples of the different features of ColorKit.

Contributing

Contributions to ColorKit are always welcome!
For bugs and feature requests, open an issue.
To contribute to the code base, simply submit a pull request.

License

See the License. You are free to make changes and use this in either personal or commercial projects. Attribution is not required, but highly appreciated. A little "Thanks!" (or something to that affect) is always welcome. If you use ColorKit in one of your projects, please let us know!

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].