{"id":25195946,"url":"https://github.com/simplisticated/pixels","last_synced_at":"2025-05-08T17:04:29.928Z","repository":{"id":62450798,"uuid":"109568070","full_name":"simplisticated/Pixels","owner":"simplisticated","description":"Simplifying work with colors in Swift","archived":false,"fork":false,"pushed_at":"2018-05-09T21:39:50.000Z","size":4413,"stargazers_count":11,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-08T17:04:06.827Z","etag":null,"topics":["alpha-component","brand-colors","color","rgb","rgba","uicolor"],"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/simplisticated.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}},"created_at":"2017-11-05T09:58:07.000Z","updated_at":"2021-12-23T11:01:25.000Z","dependencies_parsed_at":"2022-11-01T23:33:03.600Z","dependency_job_id":null,"html_url":"https://github.com/simplisticated/Pixels","commit_stats":null,"previous_names":["igormatyushkin014/pixels"],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simplisticated%2FPixels","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simplisticated%2FPixels/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simplisticated%2FPixels/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simplisticated%2FPixels/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/simplisticated","download_url":"https://codeload.github.com/simplisticated/Pixels/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253112072,"owners_count":21856070,"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":["alpha-component","brand-colors","color","rgb","rgba","uicolor"],"created_at":"2025-02-10T01:39:11.341Z","updated_at":"2025-05-08T17:04:29.887Z","avatar_url":"https://github.com/simplisticated.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\" \u003e\n\u003cimg src=\"https://github.com/igormatyushkin014/Pixels/blob/master/Images/logo_2048_2048.png\" alt=\"Pixels\" title=\"Pixels\" width=\"300px\" height=\"300px\"\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n\u003ca href=\"https://swift.org\"\u003e\u003cimg src=\"https://img.shields.io/badge/Swift-4.0-orange.svg?style=flat\"\u003e\u003c/a\u003e\n\u003ca href=\"https://cocoapods.org\"\u003e\u003cimg src=\"https://img.shields.io/cocoapods/v/Pixels.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://cocoapods.org\"\u003e\u003cimg src=\"https://img.shields.io/cocoapods/dt/Pixels.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://tldrlegal.com/license/mit-license\"\u003e\u003cimg src=\"https://img.shields.io/badge/License-MIT-blue.svg?style=flat\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n# Pixels\n\nThe purpose of `Pixels` library is to simplify common tasks with colors in iOS, which makes implementation of colorful UI designs easier. Absolutely compatible with native iOS SDK.\n\n## How To Get Started\n\n- Copy content of `Source` folder to your project.\n\nor\n\n- Use `Pixels` cocoapod\n\n## Requirements\n\n* iOS 9 and later\n* Xcode 9 and later\n* Swift 4\n\n## Usage\n\n### Color Initialization\n\nThe common expression for color in RGB system is `#123456`. Another variety of this expression looks like `#123` which is equivalent to `#112233`. The same time, iOS SDK doesn't support those expressions above and requires to use `CGFloat` values for red, green, blue and alpha components in constructor of `UIColor` class. Not comfortable enough, right?\n\n`Pixels` has a solution for the problem described above, so instead of this\n\n```swift\nlet grayColor = UIColor(\n    red: 51.0 / 255.0,\n    green: 51.0 / 255.0,\n    blue: 51.0,\n    alpha: 255.0\n)\n```\n\nyou can simply write this\n\n```swift\nlet grayColor = UIColor(hexString: \"#333333\") // RGB {51, 51, 51}\n```\n\nor this\n\n```swift\nlet grayColor = UIColor(hexString: \"#333\") // RGB {51, 51, 51}\n```\n\nor even this\n\n```swift\nlet grayColor = UIColor(hexString: \"333\") // RGB {51, 51, 51}\n```\n\nAs you can see in last example, sharp symbol is optional. Hex string will be parsed correctly with or without sharp prefix.\n\n`Pixels` supports both RGB and RGBA color systems, so you can also add alpha component to expression:\n\n```swift\nlet grayColorWithSmallTransparency = UIColor(hexString: \"#333333dd\") // RGBA {51, 51, 51, 221}\nlet halfTransparentGrayColor = UIColor(hexString: \"#3338\") // RGBA {51, 51, 51, 136}\nlet almostTransparentGrayColor = UIColor(hexString: \"#33333310\") // RGBA {51, 51, 51, 16}\n```\n\nIf hex string has wrong format, `nil` will be returned instead of `UIColor` instance.\n\n### Operations with Color\n\nWith `Pixels` you can invert any color:\n\n```swift\nlet invertedColor = UIColor.white.pxls\n    .invertedColor(invertAlpha: false)\n    .color // returns black color\n```\n\nAlso, it's possible to mix two colors:\n\n```swift\nlet mixedColor = UIColor.blue.pxls\n    .mix(with: UIColor.orange)\n    .color // returns purple color\n```\n\nAll operations support chains, so you can use them like in example below:\n\n```swift\nlet resultColor = UIColor.yellow.pxls\n    .invertedColor(invertAlpha: false) // invert yellow color\n    .mix(with: .orange)                // mix inverted color with orange\n    .color                             // get `UIColor` instance\n    .withAlphaComponent(0.5)           // make color 50% transparent\n```\n\nEvery chain begins with `.pxls` and finishes by mentioning `.color` reference that generates final `UIColor` instance.\n\n### Brand Colors\n\nSometimes you don't know which colors are good enough for your project. But you don't need to be a professional designer, because you can reuse popular color schemes used by well-known services. `Pixels` provides great collection of brand colors. All that you need is to write:\n\n```swift\nlet color = UIColor.Brands.Google.blue\n```\n\nor \n\n```swift\nlet color = UIColor.Brands.Flickr.pink\n```\n\nOf course, you are not limited to make any operations with those colors:\n\n```swift\nlet flickrPinkWithHalfTransparency = UIColor.Brands.Flickr.pink.colorWithAlphaComponent(0.5)\n```\n\nTo see full collection of available brands, just type in Xcode `UIColor.Brands.` and you will see output like this:\n\n\u003cp align=\"center\" \u003e\n\u003cimg src=\"https://github.com/igormatyushkin014/Pixels/blob/master/Images/available_brands.png\" alt=\"Available Brands\" title=\"Available Brands\"\u003e\n\u003c/p\u003e\n\nAnother way to check available brands is to take a look at the [source code](Source/Extensions/Color/UIColorExtensionBrands.swift).\n\n### HTML Colors\n\n`Pixels` provides a list of [HTML colors](https://www.w3schools.com/colors/colors_names.asp). All of them are available in [`UIColor.HTML`](/Source/Resources/Colors/UIColorExtensionHTMLColors.swift) namespace:\n\n```swift\nlet purple = UIColor.HTML.purple         // #800080\nlet orange = UIColor.HTML.orange         // #FFA500\nlet lightGreen = UIColor.HTML.lightGreen // #90EE90\n```\n\n### Google Material Colors\n\n`Pixels` also includes set of material colors that can be used like in example below:\n\n```swift\nlet orange = UIColor.Material.Orange._500\nlet blue = UIColor.Material.Blue.a200\n// etc.\n```\n\n## License\n\n`Pixels` is available under the MIT license. See the [LICENSE](./LICENSE) file for more info.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimplisticated%2Fpixels","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsimplisticated%2Fpixels","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimplisticated%2Fpixels/lists"}