{"id":13465421,"url":"https://github.com/Boris-Em/ColorKit","last_synced_at":"2025-03-25T16:31:45.604Z","repository":{"id":40409934,"uuid":"242843513","full_name":"Boris-Em/ColorKit","owner":"Boris-Em","description":"Advanced color manipulation for iOS.","archived":false,"fork":false,"pushed_at":"2023-12-31T18:02:25.000Z","size":6697,"stargazers_count":744,"open_issues_count":12,"forks_count":85,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-03-19T19:48:23.695Z","etag":null,"topics":["average-color","cie94","ciede2000","cielab","cmyk","color","color-difference","contrast-ratio","deltae","dominant-color","dominant-colors","hex","hex-strings","ios","luminance","swift","uicolor","uicolor-extension","uicolor-hex","xyz"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Boris-Em.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2020-02-24T21:06:36.000Z","updated_at":"2025-03-16T07:21:32.000Z","dependencies_parsed_at":"2024-01-29T16:57:56.148Z","dependency_job_id":"26d3aed7-5761-4d22-aa27-3462fba6bb08","html_url":"https://github.com/Boris-Em/ColorKit","commit_stats":{"total_commits":50,"total_committers":4,"mean_commits":12.5,"dds":0.06000000000000005,"last_synced_commit":"6e4375a6126eac0a29893c607ae318bdbe33310c"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Boris-Em%2FColorKit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Boris-Em%2FColorKit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Boris-Em%2FColorKit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Boris-Em%2FColorKit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Boris-Em","download_url":"https://codeload.github.com/Boris-Em/ColorKit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245500249,"owners_count":20625532,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["average-color","cie94","ciede2000","cielab","cmyk","color","color-difference","contrast-ratio","deltae","dominant-color","dominant-colors","hex","hex-strings","ios","luminance","swift","uicolor","uicolor-extension","uicolor-hex","xyz"],"created_at":"2024-07-31T15:00:29.422Z","updated_at":"2025-03-25T16:31:44.577Z","avatar_url":"https://github.com/Boris-Em.png","language":"Swift","funding_links":[],"categories":["Libs","Colors [🔝](#readme)","UI and SwiftUI","Swift"],"sub_categories":["Colors"],"readme":"# ColorKit\n\n\u003cp align=\"center\"\u003e\u003cimg src=\"Assets/colorkit_banner.jpg\"/\u003e\u003c/p\u003e\n\n**ColorKit** is your companion to work with colors on iOS.\n\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"LICENSE\"\u003e\n        \u003cimg src=\"https://github.com/Boris-Em/ColorKit/workflows/Test/badge.svg?branch=master\" alt=\"Build\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"LICENSE\"\u003e\n        \u003cimg src=\"https://img.shields.io/badge/license-MIT-brightgreen.svg\" alt=\"MIT License\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://swift.org\"\u003e\n        \u003cimg src=\"https://img.shields.io/badge/swift-5.1-brightgreen.svg\" alt=\"Swift 5.1\"\u003e\n    \u003c/a\u003e\n\u003c/p\u003e\n\n- [Features](#features)\n- [Installation](#installation)\n- [Sample Project](#sample-project)\n- [Contributing](#contributing)\n- [License](#license)\n\n\u003c/br\u003e\n\n## Features\n\n### Dominant Colors\n**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.\n\n```swift\nlet dominantColors = try image.dominantColors()\n```\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"Assets/dominant_colors.jpg\"\u003e\n\u003c/p\u003e\n\nBy 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](https://en.wikipedia.org/wiki/K-means_clustering). Choose whichever is more appropriate for your use case.\n\n---\n\n### Color Palette\n**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.  \nThis feature is particularly powerful when combined with the dominant color calculation.\n\n```swift\nlet colors = try image.dominantColors()\nlet palette = ColorPalette(orderedColors: colors, ignoreContrastRatio: true)\n```\nThe following examples use the palette to dynamically match the color of the text and background to the album covers.\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"Assets/color_palette_albums.jpg\"\u003e\n\u003c/p\u003e\n\n---\n\n### Average Color\n\nTo compute the average color of an image, simply call the `averageColor` function on a `UIImage` instance.\n```swift\nlet averageColor = try image.averageColor()\n```\n\n---\n\n### Color Difference (DeltaE)\n\nPerceptual color difference / comparaison is a common problem of color science.  \nIt simply consists of calculating how different two colors look from each other, to the human eye. This is commonly referenced as the DeltaE.\n\n**ColorKit** makes it a breaze to compare two colors.\n\n```swift\nlet colorDifference = UIColor.green.difference(from: .white) // 120.34\n```\n\nWhile this may seem trivial, simply using the RGB color model often yields non-accurate results for human perception.\nThis is because RGB is not perceptually uniform.\n\nHere is an example highlighting the limitations of using the RGB color model to compare colors.\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"Assets/color_difference_deltaE_RGB.jpg\"\u003e\n\u003c/p\u003e\n\nAs 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 by the algorithm.  \nThis obviously does not match the expectation of the human eye.\n\nThankfully, **ColorKit** provides algorithms that make it possible to compare colors just like the human eye would: **CIE76**, **CIE94** and **CIEDE2000**.\n\n```swift\nlet colorDifference = UIColor.green.difference(from: .white, using: .CIE94) \n```\n\nHere is the same example as above, using the **CIE94** algorithm.\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"Assets/color_difference_deltaE_CIE94.jpg\"\u003e\n\u003c/p\u003e\n\nThe **CIE94** algorithm successfuly realizes that the two greens (left) look closer from each other than the pink and gray (right) do.\n\nMore information about color difference can be found [here](https://en.wikipedia.org/wiki/Color_difference).\n\n---\n\n### Contrast Ratio\n\nTo calculate the contrast ratio between two colors, simply use the `contrastRatio` function.\n```swift\nlet contrastRatio = UIColor.green.contrastRatio(with: UIColor.white)\n```\nThe contrast ratio is particularly important when displaying text.\nTo ensure that it's readable by everyone, **ColorKit** makes it easy for you to follow the accessibility guidelines set by [WCAG 2](https://www.w3.org/WAI/WCAG21/quickref/?versions=2.0#qr-visual-audio-contrast-contrast).\n\n---\n\n### Color Space Conversions\n\n**ColorKit** assists you when translating a color from a color space to another.\nThey're simply supported as extensions on `UIColor`.  \n**CIELAB**, **XYZ** and **CMYK** are supported.\n\n---\n\n### More\n\nThere is a lot more that **ColorKit** is capable of.\nHere is a short list of examples:\n- Working with Hex color codes\n```swift\nlet hexValue = UIColor.green.hex\nlet color = UIColor(hex: \"eb4034\")\n```\n- Generating random colors\n```swift\nlet randomColor = UIColor.random()\n```\n- Calculating the relative luminance of a color\n```swift\nlet relativeLuminance = UIColor.green.relativeLuminance\n```\n- Generating complementary colors\n```swift\nlet complementaryColor = UIColor.green.complementaryColor\n```\n\n\u003c/br\u003e\n\n## Installation\n\n### Swift Package Manager\n\nThe [Swift Package Manager](https://swift.org/package-manager/) is the easiest way to install and manage **ColorKit** as a dependecy.  \nSimply add **ColorKit** to your dependencies in your `Package.swift` file:\n```swift\ndependencies: [\n    .package(url: \"https://github.com/Boris-Em/ColorKit.git\")\n]\n```\n\nAlternatively, you can also use XCode to add **ColorKit** to your existing project, by using `File \u003e Swift Packages \u003e Add Package Dependency...`.\n\n### Manually\n\n**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.\n\n\u003c/br\u003e\n\n## Sample Project\n\nUse the iOS sample project included in this repository to find comprehensive examples of the different features of **ColorKit**.\n\n\u003c/br\u003e\n\n## Contributing\n\nContributions to **ColorKit** are always welcome!   \nFor bugs and feature requests, open an [issue](https://github.com/Boris-Em/ColorKit/issues/new).  \nTo contribute to the code base, simply submit a [pull request](https://github.com/Boris-Em/ColorKit/pulls).\n\n\u003c/br\u003e\n\n## License\n\nSee the [License](https://github.com/Boris-Em/ColorKit/blob/master/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!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FBoris-Em%2FColorKit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FBoris-Em%2FColorKit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FBoris-Em%2FColorKit/lists"}