{"id":21524172,"url":"https://github.com/alcidesrc/coloreeze","last_synced_at":"2025-04-09T22:53:14.391Z","repository":{"id":47922097,"uuid":"516384276","full_name":"AlcidesRC/coloreeze","owner":"AlcidesRC","description":"A PHP library to deal with color conversions","archived":false,"fork":false,"pushed_at":"2024-08-25T14:02:58.000Z","size":183,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-09T22:53:08.241Z","etag":null,"topics":["cielab","ciexyz","cmyk","color","colors","conversion","convert","greyscale","hex","hsb","hsl","php","rgba"],"latest_commit_sha":null,"homepage":"","language":"PHP","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/AlcidesRC.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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,"publiccode":null,"codemeta":null},"funding":{"github":["AlcidesRC"],"custom":["http://www.paypal.me/AlcidesRC"]}},"created_at":"2022-07-21T13:32:22.000Z","updated_at":"2024-08-25T14:03:02.000Z","dependencies_parsed_at":"2024-11-24T02:15:41.079Z","dependency_job_id":null,"html_url":"https://github.com/AlcidesRC/coloreeze","commit_stats":null,"previous_names":["alcidesrc/coloreeze"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlcidesRC%2Fcoloreeze","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlcidesRC%2Fcoloreeze/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlcidesRC%2Fcoloreeze/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlcidesRC%2Fcoloreeze/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AlcidesRC","download_url":"https://codeload.github.com/AlcidesRC/coloreeze/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248125636,"owners_count":21051766,"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":["cielab","ciexyz","cmyk","color","colors","conversion","convert","greyscale","hex","hsb","hsl","php","rgba"],"created_at":"2024-11-24T01:21:20.377Z","updated_at":"2025-04-09T22:53:14.369Z","avatar_url":"https://github.com/AlcidesRC.png","language":"PHP","funding_links":["https://github.com/sponsors/AlcidesRC","http://www.paypal.me/AlcidesRC"],"categories":[],"sub_categories":[],"readme":"[![Integration Tests](https://github.com/AlcidesRC/coloreeze/actions/workflows/ci.yml/badge.svg)](https://github.com/AlcidesRC/coloreeze/actions/workflows/ci.yml)\n\n# coloreeze\n\n\u003e A PHP library to deal with color conversions\n\n[TOC]\n\n## Summary\n\nColoreeze is a PHP library to deal with color conversions.\n\nCurrently it supports the following color spaces:\n\n- Hexadecimal\n- Integer\n- RGB(a)\n- HSB/HSV\n- HSL\n- CMYK\n- CIELab\n- XYZ\n\n## Features\n\nAdditionally this library contains some useful methods to:\n\n- Generate a greyscale version from a color\n- Generate a darker version from a color\n- Generate a lighter version from a color\n- to create gradients and measure the distance CIE76 between colors.\n\n## Installation\n\nYou can install the package via composer:\n\n```bash\n$ composer require alcidesrc/coloreeze\n```\n\n## Usage\n\n`Coloreeze` package contains independent color classes, all of them implementing a `Color` interface:\n\n- ColorCIELab\n- ColorCMYK\n- ColorFactory\n- ColorHSB\n- ColorHSL\n- ColorHex\n- ColorInt\n- ColorRGBA\n- ColorXYZ\n\n### Color Factory\n\n#### ColorFactory::fromString(string $input): Color\n\nThe `ColorFactory` class allows you to create a color instance from any valid input string.\n\nIf the input string is not a valid color representation it throws an `InvalidInput` exception.\n\n```php\nColorFactory::fromString('rgb(0,100,200)'); // Returns a `ColorRGBA` instance\nColorFactory::fromString('#336699'); // Returns a `ColorHex` instance\nColorFactory::fromString('unknown(1,2,3)'); // Throws an `InvalidInput` exception\n```\n\n### Color Interface\n\n#### __toString(): string\n\nCast the color value to a string:\n\n```php\necho ColorRGBA::fromString('rgba(0,100,200,1.0)');\necho ColorHex::fromString('#336699');\n\n'rgba(0,100,200,1.0)'\n'#336699'\n```\n\n#### fromString(string $input): Color\n\nParses an input string and returns accordingly the related `Color` implementation:\n\n```php\n$hex = ColorHex::fromString('#336699');\n$rgba = ColorRGBA::fromString('rgba(0,100,200,1.0)');\n...\n```\n\nIt throws an `InvalidInput` exception in case of the string is not well formed or unsupported color.\n\n#### getValue(): mixed\n\nReturns the `Color` value. On single-value colors, this method returns a primitive value (int or string) but on composite ones it returns an array with color's components:\n\n```php\n$int = ColorInt::fromString('int(100)');\nvar_dump($int-\u003egetValue());\n\nint(100)\n```\n\n```php\n$rgba = ColorRGBA::fromString('rgba(0, 100, 200)');\nvar_dump($int-\u003egetValue());\n\narray(3) {\n  [0]=\u003e\n  int(0)\n  [1]=\u003e\n  int(100)\n  [2]=\u003e\n  int(200)\n}\n```\n\n```php\n$hex = ColorHex::fromString('#336699');\nvar_dump($int-\u003egetValue());\n\nstring(7) \"#336699\"\n```\n\n#### toCIELab(): ColorCIELab\n\nConverts a color to a **CIELab**:\n\n```php\n$lab = ColorHex::fromString('#336699')-\u003etoCIELab();\n```\n\n#### toCMYK(): ColorCMYK\n\nConverts a color to a **CMYK**:\n\n```php\n$cmyk = ColorHex::fromString('#336699')-\u003etoCMYK();\n```\n\n#### toHex(): ColorHex\n\nConverts a color to a **Hex**:\n\n```php\n$hex = ColorRGBA::fromString('rgba(100,200,200,1.0)')-\u003etoHex();\n```\n\n#### toHSB(): ColorHSB\n\nConverts a color to a **HSB/HSV**:\n\n```php\n$hsb = ColorHex::fromString('#336699')-\u003etoHSB();\n```\n#### toHSL(): ColorHSL\n\nConverts a color to a **HSL**:\n\n```php\n$hsl = ColorHex::fromString('#336699')-\u003etoHSL();\n```\n\n#### toInt(): ColorInt\n\nConverts a color to an **Int**:\n\n```php\n$int = ColorHex::fromString('#336699')-\u003etoInt();\n```\n\n#### toRGBA(): ColorRGBA\n\n```php\n$rgba = ColorInt::fromString('int(255)')-\u003etoRGBA();\n```\n\n#### toXYZ(): ColorXYZ\n\n```php\n$rgba = ColorCMYK::fromString('cmyk(0,0,0,0)')-\u003etoXYZ();\n```\n\n#### toComplementary(): Color\n\n```php\n$complementary = ColorRGBA::fromString('hsl(182,25,50)')-\u003etoComplementary();\n```\n\n#### toGreyscale(): Color\n\n```php\n$greyscale = ColorInt::fromString('int(4278255615)')-\u003etoGreyscale();\n```\n\n#### adjustBrightness(int $steps): Color\n\n```php\n$dark = ColorInt::fromString('int(4278255615)')-\u003eadjustBrightness(-10);\n$light = ColorInt::fromString('int(4278255615)')-\u003eadjustBrightness(10);\n```\n\n#### distanceCIE76(Color $color): float\n\n```php\n$distance = ColorInt::fromString('int(4278255615)')-\u003edistanceCIE76(ColorInt::fromString('int(0)'));\n```\n\n## Testing\n\nYou can run the test suite via composer:\n\n```bash\n$ composer tests\n```\n\n\u003e This Composer script runs the [PHPUnit](https://phpunit.de/) command with [PCOV](https://github.com/krakjoe/pcov) support in order to generate a Code Coverage report.\n\n### Unit Tests\n\nThis library provides a [PHPUnit](https://phpunit.de/) testsuite with **1434 unit tests** and **2670 assertions**:\n\n```bash\nTime: 00:00.426, Memory: 24.00 MB\n\nOK (1434 tests, 2670 assertions)\n```\n\n### Code Coverage\n\nHere is the Code Coverage report summary:\n\n```bash\nCode Coverage Report:\n  2022-07-22 06:32:15\n\n Summary:\n  Classes: 100.00% (11/11)\n  Methods: 100.00% (135/135)\n  Lines:   100.00% (475/475)\n```\n\n\u003e Full report will be generated in **./reports/coverage** folder.\n\n## QA\n\n### Static Analyzer\n\nYou can check this library with [PHPStan](https://phpstan.org/):\n\n```bash\n$ composer phpstan\n```\n\nThis command generates the following report:\n\n```bash\n\u003e vendor/bin/phpstan analyse --level 9 --memory-limit 1G --ansi ./src ./tests\n 29/29 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%\n\n [OK] No errors\n```\n\n### PHP Parallel Lint\n\nYou can check this library with [PHP Parallel Lint](https://github.com/php-parallel-lint/PHP-Parallel-Lint):\n\n```bash\n$ composer linter\n```\n\nThis command generates the following report:\n\n```bash\nPHP 8.1.8 | 10 parallel jobs\n.............................                                29/29 (100 %)\nChecked 29 files in 0.1 seconds\nNo syntax error found\n```\n\n## PHP Insights\n\nYou can check this library with [PHP Insights](https://phpinsights.com/):\n\n```bash\n$ composer phpinsights\n```\n\nThis command generates the following summary:\n\n```bash\n\u003e ./vendor/bin/phpinsights --fix\n\n 16/16 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%\n\n ✨ Analysis Completed !\n\n[2022-07-22 08:20:20] `/code`\n\n                99.0%                  89.5%                  94.1%                  100 %\n                Code                 Complexity            Architecture              Style\n\nScore scale: ◼ 1-49 ◼ 50-79 ◼ 80-100\n\n[CODE] 99 pts within 494 lines\n\nComments ....................................................... 5.1 %\nClasses ....................................................... 85.6 %\nFunctions ...................................................... 0.0 %\nGlobally ....................................................... 9.3 %\n\n[COMPLEXITY] 89.5 pts with average of 1.32 cyclomatic complexity\n\n[ARCHITECTURE] 94.1 pts within 13 files\n\nClasses ....................................................... 84.6 %\nInterfaces ..................................................... 7.7 %\nGlobally ....................................................... 7.7 %\nTraits ......................................................... 0.0 %\n\n[MISC] 100 pts on coding style and 0 security issues encountered\n```\n\n## Security Vulnerabilities\n\nPlease review our security policy on how to report security vulnerabilities:\n\n\u003e **PLEASE DON'T DISCLOSE SECURITY-RELATED ISSUES PUBLICLY**\n\n### Supported Versions\n\nOnly the latest major version receives security fixes.\n\n### Reporting a Vulnerability\n\nIf you discover a security vulnerability within this project, please [open an issue here](https://github.com/alcidesrc/coloreeze/issues). All security vulnerabilities will be promptly addressed.\n\n## License\n\nThe MIT License (MIT). Please see [License File](https://github.com/alcidesrc/coloreeze/blob/main/LICENSE) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falcidesrc%2Fcoloreeze","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falcidesrc%2Fcoloreeze","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falcidesrc%2Fcoloreeze/lists"}