{"id":27114315,"url":"https://github.com/xenocrat/color2css","last_synced_at":"2026-05-02T02:39:58.372Z","repository":{"id":58153744,"uuid":"198079274","full_name":"xenocrat/color2css","owner":"xenocrat","description":"A PHP class for CSS color interpreting and conversion.","archived":false,"fork":false,"pushed_at":"2024-11-24T11:09:25.000Z","size":42,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-02-12T03:34:41.231Z","etag":null,"topics":["cielab","cielch","color","color-conversion","css","css-color","hex","hsl","hwb","oklab","oklch","php","rgb"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xenocrat.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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}},"created_at":"2019-07-21T16:22:22.000Z","updated_at":"2024-11-16T18:23:10.000Z","dependencies_parsed_at":"2024-02-08T11:31:09.039Z","dependency_job_id":"581b4316-2325-4328-b12b-97b3616f8deb","html_url":"https://github.com/xenocrat/color2css","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/xenocrat/color2css","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xenocrat%2Fcolor2css","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xenocrat%2Fcolor2css/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xenocrat%2Fcolor2css/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xenocrat%2Fcolor2css/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xenocrat","download_url":"https://codeload.github.com/xenocrat/color2css/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xenocrat%2Fcolor2css/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32521113,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-02T01:12:54.858Z","status":"online","status_checked_at":"2026-05-02T02:00:05.923Z","response_time":132,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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","cielch","color","color-conversion","css","css-color","hex","hsl","hwb","oklab","oklch","php","rgb"],"created_at":"2025-04-07T03:56:57.845Z","updated_at":"2026-05-02T02:39:58.333Z","avatar_url":"https://github.com/xenocrat.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"## What is this?\n\ncolor2css is a PHP class for CSS color interpreting and conversion. In the sRGB color space it converts between RGB, HSL, HSV, HWB, hexidecimal, and CSS color keywords. In the CIE Lab color space it converts between Lab and LCH, and in the OKlab color space it converts between OKlab and OKlch.\n\n## Requirements\n\n* PHP 8.0+\n\n## Usage\n\nDefine a new empty color in the sRGB, CIE Lab, and OKlab color spaces:\n\n    use xenocrat\\color2css;\n    $color2css = new color2css();\n\nDefine a new color by taking the properties of another instance:\n\n    $color1 = new color2css(\"white\");\n    $color2 = new color2css($color1);\n\nAdjust the alpha value of colors in the sRGB, CIE Lab, and OKlab color spaces:\n\n    $color2css-\u003ealpha(0.5);\n    $color2css-\u003ealpha(1.0);\n\nAll public non-static methods act as setters when supplied with a value, or getters when not supplied with a value.\n\n### sRGB\n\nDefine the CSS color `rebeccapurple` in the sRGB color space using various methods:\n\n    use xenocrat\\color2css;\n    $color2css = new color2css(\"rebeccapurple\");\n    $color2css = new color2css(\"#663399\");\n    $color2css = new color2css(\"rgb(102, 51, 153)\");\n    $color2css = new color2css(\"rgba(102 51 153 / 1.0)\");\n    $color2css = new color2css(\"hsl(270 50% 40% / 1.0)\");\n    $color2css = new color2css(\"hsla(270, 50%, 40%, 100%)\");\n    $color2css = new color2css(\"hwb(270 20% 40% / 1)\");\n    $color2css = new color2css(0.4, 0.2, 0.6, 1.0);\n\nInterpret a CSS color definition, with clamping for out-of-range values:\n\n    $color2css-\u003ehex(\"#6633GG\");             // returns false\n    $color2css-\u003ehex(\"#663399\");             // returns true\n    $color2css-\u003ergb(\"rgb(102, 51, 153)\");   // returns true\n    $color2css-\u003ergb(\"rgb(256, 51, 153)\");   // returns true\n    $color2css-\u003ergb(\"rgb(40%, 20%, 60%)\");  // returns true\n    $color2css-\u003ergb(\"rgb(0.4, 0.2, 0.6)\");  // returns true\n    $color2css-\u003ehsl(\"hsl(270, 50%, 40%)\");  // returns true\n    $color2css-\u003ehsl(\"hsl(270, 200%, 3%)\");  // returns true\n    $color2css-\u003ehwb(\"hwb(480 20% 40% / 1)\") // returns true\n    $color2css-\u003ehwb(\"hwb(270 200% 4% / 1)\") // returns true\n    $color2css-\u003ehwb(\"hwb(90, 100%, 4%, 1)\") // returns false\n    $color2css-\u003ekeyword(\"rebeccapurple\");   // returns true\n    $color2css-\u003ekeyword(\"undefinedcolor\");  // returns false\n\nAdjust the RGB of a color, in the range 0-1:\n\n    $color2css-\u003ered(1.0);\n    $color2css-\u003egreen(0.388);\n    $color2css-\u003eblue(0.278);\n\nAdjust the hue of a color, in the range 0-360:\n\n    $color2css-\u003ehue(9);\n\nAdjust the HSL saturation and lightness of a color, in the range 0-1:\n\n    $color2css-\u003esaturation(1.0);\n    $color2css-\u003elightness(0.64);\n\nAdjust the HWB whiteness and blackness of a color, in the range 0-1:\n\n    $color2css-\u003ewhiteness(0.28);\n    $color2css-\u003eblackness(0);\n\nAdjust the HSV saturation (colorfulness) and value (brightness) of a color, in the range 0-1:\n\n    $color2css-\u003ecolorfulness(0.6);\n    $color2css-\u003ebrightness(0.254);\n\nCalculate WCAG contrast ratio of the RGB as a float value between 1 and 21:\n\n    $color1 = new color2css(\"white\");\n    $color2 = new color2css(\"black\");\n    $contrast = color2css::contrast($color1, $color2);\n\nExport a CSS color definition:\n\n    $color2ccc-\u003ekeyword(\"tomato\");\n    $color2css-\u003ehex();              // returns \"#ff6347\"\n    $color2css-\u003ehexa();             // returns \"#ff6347ff\"\n    $color2css-\u003ergb();              // returns \"rgb(255 99 71 / 100%)\"\n    $color2css-\u003ehsl();              // returns \"hsl(9.1 100% 63.9% / 100%)\"\n    $color2css-\u003ehwb();              // returns \"hwb(9.1 27.9% 0% / 100%)\"\n    $color2css-\u003ekeyword();          // returns \"tomato\";\n\n### CIE Lab\n\nDefine a CSS color in the CIE Lab color space using Lab and LCH:\n\n    $color2css = new color2css(\"lab(47.9 -30.3 -8.9)\");\n    $color2css = new color2css(\"lch(47.9 31.6 196.5 / 100%)\");\n\nInterpret a CSS color definition, with clamping for out-of-range values:\n\n    $color2css-\u003elab(\"lab(150 -30.3 -8.9)\"); // returns true\n    $color2css-\u003elab(\"lab(47.9, 30, 10)\");   // returns false\n\nAdjust the CIE lightness of a color, in the range 0-100:\n\n    $color2css-\u003ecie_l(64);\n\nAdjust the CIE Lab A and B axes of a color:\n\n    $color2css-\u003ecie_a(42);\n    $color2css-\u003ecie_b(80);\n\nAdjust the CIE LCH chroma of a color, with a value \u003e 0:\n\n    $color2css-\u003ecie_c(85);\n\nAdjust the CIE LCH hue value of a color, in the range 0-360:\n\n    $color2css-\u003ecie_h(245.6);\n\nExport a CSS color definition:\n\n    $color2css-\u003elab();  // returns \"lab(64 -35.1 -77.4 / 100%)\"\n    $color2css-\u003elch();  // returns \"lch(64 85 245.6 / 100%)\"\n\n### OKlab\n\nDefine a CSS color in the OKlab color space using Lab and LCH:\n\n    $color2css = new color2css(\"oklab(0.54 -0.089 -0.023)\");\n    $color2css = new color2css(\"oklch(0.543 0.0927 194.76 / 100%)\");\n\nInterpret a CSS color definition, with clamping for out-of-range values:\n\n    $color2css-\u003eoklab(\"oklab(1.1 0.1 0)\");  // returns true\n    $color2css-\u003eoklab(\"lab(0.7 0.09 0.1)\"); // returns false\n\nAdjust the OK lightness of a color, in the range 0-1:\n\n    $color2css-\u003eok_l(0.75);\n\nAdjust the OKlab A and B axes of a color:\n\n    $color2css-\u003eok_a(0.04);\n    $color2css-\u003eok_b(0.08);\n\nAdjust the OK LCH chroma of a color, with a value \u003e 0:\n\n    $color2css-\u003eok_c(0.1);\n\nAdjust the OK LCH hue value of a color, in the range 0-360:\n\n    $color2css-\u003eok_h(15.9);\n\nExport a CSS color definition:\n\n    $color2css-\u003eoklab();    // returns \"oklab(0.750 0.144 0.041 / 100%)\"\n    $color2css-\u003eoklch();    // returns \"oklch(0.750 0.150 15.9 / 100%)\"\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxenocrat%2Fcolor2css","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxenocrat%2Fcolor2css","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxenocrat%2Fcolor2css/lists"}