{"id":21467453,"url":"https://github.com/elusivecodes/fyrecolor","last_synced_at":"2025-07-15T05:31:38.114Z","repository":{"id":57680831,"uuid":"494433460","full_name":"elusivecodes/FyreColor","owner":"elusivecodes","description":"FyreColor is a free, open-source color manipulation library for PHP.","archived":false,"fork":false,"pushed_at":"2024-06-29T02:02:45.000Z","size":109,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-06-30T05:09:59.611Z","etag":null,"topics":["cmy","cmyk","color","hex","hsl","hsv","php","rgb","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/elusivecodes.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,"publiccode":null,"codemeta":null}},"created_at":"2022-05-20T11:14:40.000Z","updated_at":"2024-06-29T02:02:25.000Z","dependencies_parsed_at":"2024-06-24T12:43:45.481Z","dependency_job_id":"26b33e18-a795-4cb1-90b9-c52c9884592c","html_url":"https://github.com/elusivecodes/FyreColor","commit_stats":{"total_commits":2,"total_committers":1,"mean_commits":2.0,"dds":0.0,"last_synced_commit":"df489411273d4c45385fb97dc7876241be8bbce0"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elusivecodes%2FFyreColor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elusivecodes%2FFyreColor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elusivecodes%2FFyreColor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elusivecodes%2FFyreColor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/elusivecodes","download_url":"https://codeload.github.com/elusivecodes/FyreColor/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226017596,"owners_count":17560543,"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":["cmy","cmyk","color","hex","hsl","hsv","php","rgb","rgba"],"created_at":"2024-11-23T08:18:08.396Z","updated_at":"2024-11-23T08:18:10.357Z","avatar_url":"https://github.com/elusivecodes.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# FyreColor\r\n\r\n**FyreColor** is a free, open-source immutable color manipulation library for *PHP*.\r\n\r\nIt is a modern library, and features full support for RGB, HSL, HSV, CMY and CMYK color-spaces.\r\n\r\n\r\n## Table Of Contents\r\n- [Installation](#installation)\r\n- [Basic Usage](#basic-usage)\r\n- [Color Creation](#color-creation)\r\n- [Color Formatting](#color-formatting)\r\n- [Color Attributes](#color-attributes)\r\n- [Color Manipulation](#color-manipulation)\r\n- [Color Schemes](#color-schemes)\r\n- [Color Palettes](#color-palettes)\r\n- [Static Methods](#static-methods)\r\n\r\n\r\n\r\n## Installation\r\n\r\n**Using Composer**\r\n\r\n```\r\ncomposer require fyre/color\r\n```\r\n\r\nIn PHP:\r\n\r\n```php\r\nuse Fyre\\Color\\Color;\r\n```\r\n\r\n\r\n## Basic Usage\r\n\r\n**From RGB**\r\n\r\n- `$red` is a number between *0* and *255*.\r\n- `$green` is a number between *0* and *255*.\r\n- `$blue` is a number between *0* and *255*.\r\n- `$alpha` is a number between *0* and *1*, and will default to *1*.\r\n\r\n```php\r\n$color = new Color($red, $green, $blue, $alpha);\r\n```\r\n\r\n**From Brightness**\r\n\r\n- `$brightness` is a number between *0* and *100*.\r\n- `$alpha` is a number between *0* and *1*, and will default to *1*.\r\n\r\n```php\r\n$color = new Color($brightness, $alpha);\r\n```\r\n\r\n## Color Creation\r\n\r\n**From String**\r\n\r\nCreate a new *Color* from a HTML color string.\r\n\r\n- `$colorString` is a string containing a color value in either hexadecimal, RGB, RGBA, HSL, HSLA or a standard HTML color name.\r\n\r\n```php\r\n$color = Color::fromString($colorString);\r\n```\r\n\r\n**From CMY**\r\n\r\nCreate a new *Color* from CMY values.\r\n\r\n- `$cyan` is a number between *0* and *100*.\r\n- `$magenta` is a number between *0* and *100*.\r\n- `$yellow` is a number between *0* and *100*.\r\n- `$alpha` is a number between *0* and *1*, and will default to *1*.\r\n\r\n```php\r\n$color = Color::fromCMY($cyan, $magenta, $yellow, $alpha);\r\n```\r\n\r\n**From CMYK**\r\n\r\nCreate a new *Color* from CMYK values.\r\n\r\n- `$cyan` is a number between *0* and *100*.\r\n- `$magenta` is a number between *0* and *100*.\r\n- `$yellow` is a number between *0* and *100*.\r\n- `$key` is a number between *0* and *100*.\r\n- `$alpha` is a number between *0* and *1*, and will default to *1*.\r\n\r\n```php\r\n$color = Color::fromCMYK($cyan, $magenta, $yellow, $key, $alpha);\r\n```\r\n\r\n**From HSL**\r\n\r\nCreate a new *Color* from HSL values.\r\n\r\n- `$hue` is a number between *0* and *360*.\r\n- `$saturation` is a number between *0* and *100*.\r\n- `$lightness` is a number between *0* and *100*.\r\n- `$alpha` is a number between *0* and *1*, and will default to *1*.\r\n\r\n```php\r\n$color = Color::fromHSL($hue, $saturation, $lightness, $alpha);\r\n```\r\n\r\n**From HSV**\r\n\r\nCreate a new *Color* from HSV values.\r\n\r\n- `$hue` is a number between *0* and *360*.\r\n- `$saturation` is a number between *0* and *100*.\r\n- `$value` is a number between *0* and *100*.\r\n- `$alpha` is a number between *0* and *1*, and will default to *1*.\r\n\r\n```php\r\n$color = Color::fromHSV($hue, $saturation, $value, $alpha);\r\n```\r\n\r\n\r\n## Color Formatting\r\n\r\n**To String**\r\n\r\nGet a HTML string representation of the color.\r\n\r\n```php\r\n$colorString = $color-\u003etoString();\r\n```\r\n\r\nThe `$colorString` returned will be a string containing either a HTML color name (if one exists), a hexadecimal string (if alpha is *1*) or an RGBA string.\r\n\r\n**To Hex String**\r\n\r\nGet a hexadecimal string representation of the color.\r\n\r\n```php\r\n$hexString = $color-\u003etoHexString();\r\n```\r\n\r\n**To RGB String**\r\n\r\nGet a RGB/RGBA string representation of the color.\r\n\r\n```php\r\n$rgbString = $color-\u003etoRGBString();\r\n```\r\n\r\n**To HSL String**\r\n\r\nGet a HSL/HSLA string representation of the color.\r\n\r\n```php\r\n$hslString = $color-\u003etoHSLString();\r\n```\r\n\r\n**Label**\r\n\r\nGet the closest color name for the color.\r\n\r\n```php\r\n$label = $color-\u003elabel();\r\n```\r\n\r\n\r\n## Color Attributes\r\n\r\n**Get Alpha**\r\n\r\nGet the alpha value of the color (between *0* and *1*).\r\n\r\n```php\r\n$alpha = $color-\u003egetAlpha();\r\n```\r\n\r\n**Get Brightness**\r\n\r\nGet the brightness value of the color (between *0* and *100*).\r\n\r\n```php\r\n$brightness = $color-\u003egetBrightness();\r\n```\r\n\r\n**Get Hue**\r\n\r\nGet the hue value of the color (between *0* and *360*).\r\n\r\n```php\r\n$hue = $color-\u003egetHue();\r\n```\r\n\r\n**Get Saturation**\r\n\r\nGet the saturation value of the color (between *0* and *100*).\r\n\r\n```php\r\n$saturation = $color-\u003egetSaturation();\r\n```\r\n\r\n**Luma**\r\n\r\nGet the relative luminance value of the color (between *0* and *1*).\r\n\r\n```php\r\n$luma = $color-\u003eluma();\r\n```\r\n\r\n**Set Alpha**\r\n\r\nSet the alpha value of the color.\r\n\r\n- `$alpha` is a number between *0* and *1*.\r\n\r\n```php\r\n$newColor = $color-\u003esetAlpha($alpha);\r\n```\r\n\r\n**Set Brightness**\r\n\r\nSet the brightness value of the color.\r\n\r\n- `$brightness` is a number between *0* and *100*.\r\n\r\n```php\r\n$newColor = $color-\u003esetBrightness($brightness);\r\n```\r\n\r\n**Set Hue**\r\n\r\nSet the hue value of the color.\r\n\r\n- `$hue` is a number between *0* and *360*.\r\n\r\n```php\r\n$newColor = $color-\u003esetHue($hue);\r\n```\r\n\r\n**Set Saturation**\r\n\r\nSet the saturation value of the color.\r\n\r\n- `$saturation` is a number between *0* and *100*.\r\n\r\n```php\r\n$newColor = $color-\u003esetSaturation($saturation);\r\n```\r\n\r\n\r\n## Color Manipulation\r\n\r\n**Darken**\r\n\r\nDarken the color by a specified amount.\r\n\r\n- `$amount` is a number between *0* and *1*.\r\n\r\n```php\r\n$newColor = $color-\u003edarken($amount);\r\n```\r\n\r\n**Invert**\r\n\r\nInvert the color.\r\n\r\n```php\r\n$newColor = $color-\u003einvert();\r\n```\r\n\r\n**Lighten**\r\n\r\nLighten the color by a specified amount.\r\n\r\n- `$amount` is a number between *0* and *1*.\r\n\r\n```php\r\n$newColor = $color-\u003elighten($amount);\r\n```\r\n\r\n**Shade**\r\n\r\nShade the color by a specified amount.\r\n\r\n- `$amount` is a number between *0* and *1*.\r\n\r\n```php\r\n$newColor = $color-\u003eshade($amount);\r\n```\r\n\r\n**Tint**\r\n\r\nTint the color by a specified amount.\r\n\r\n- `$amount` is a number between *0* and *1*.\r\n\r\n```php\r\n$newColor = $color-\u003etint($amount);\r\n```\r\n\r\n**Tone**\r\n\r\nTone the color by a specified amount.\r\n\r\n- `$amount` is a number between *0* and *1*.\r\n\r\n```php\r\n$newColor = $color-\u003etone($amount);\r\n```\r\n\r\n\r\n## Color Schemes\r\n\r\n**Complementary**\r\n\r\nCreate a complementary color variation.\r\n\r\n```php\r\n$complementary = $color-\u003ecomplementary();\r\n```\r\n\r\n**Split**\r\n\r\nCreate an array with 2 split color variations.\r\n\r\n```php\r\n[$secondary, $accent] = $color-\u003esplit();\r\n```\r\n\r\n**Analogous**\r\n\r\nCreate an array with 2 analogous color variations.\r\n\r\n```php\r\n[$secondary, $accent] = $color-\u003eanalogous();\r\n```\r\n\r\n**Triadic**\r\n\r\nCreate an array with 2 triadic color variations.\r\n\r\n```php\r\n[$secondary, $accent] = $color-\u003etriadic();\r\n```\r\n\r\n**Tetradic**\r\n\r\nCreate an array with 3 tetradic color variations.\r\n\r\n```php\r\n[$secondary, $alternate, $accent] = $color-\u003etetradic();\r\n```\r\n\r\n\r\n## Color Palettes\r\n\r\nCreate a palette of colors from a *Color* object you have created using the following methods.\r\n\r\n**Shades**\r\n\r\nCreate an array with a specified number of shade variations.\r\n\r\n- `$shades` is a number indicating how many shades you wish to generate, and will default to *10*.\r\n\r\n```php\r\n$colorShades = $color-\u003eshades($shades);\r\n```\r\n\r\n**Tints**\r\n\r\nCreate an array with a specified number of tint variations.\r\n\r\n- `$tints` is a number indicating how many tints you wish to generate, and will default to *10*.\r\n\r\n```php\r\n$colorTints = $color-\u003etints($tints);\r\n```\r\n\r\n**Tones**\r\n\r\nCreate an array with a specified number of tone variations.\r\n\r\n- `$tones` is a number indicating how many tones you wish to generate, and will default to *10*.\r\n\r\n```php\r\n$colorTones = $color-\u003etones($tones);\r\n```\r\n\r\n**Palette**\r\n\r\nCreate a palette object with a specified number of shades, tints and tone variations.\r\n\r\n- `$shades` is a number indicating how many shades you wish to generate, and will default to *10*.\r\n- `$tints` is a number indicating how many tints you wish to generate, and will default to *10*.\r\n- `$tones` is a number indicating how many tones you wish to generate, and will default to *10*.\r\n\r\n```php\r\n$colorPalette = $color-\u003epalette($shades, $tints, $tones);\r\n```\r\n\r\n\r\n## Static Methods\r\n\r\n**Contrast**\r\n\r\nCalculate the contrast between two colors (between *1* and *21*).\r\n\r\n- `$color1` is a *Color* object.\r\n- `$color2` is a *Color* object.\r\n\r\n```php\r\n$contrast = Color::contrast($color1, $color2);\r\n```\r\n\r\n**Distance**\r\n\r\nCalculate the distance between two colors.\r\n\r\n- `$color1` is a *Color* object.\r\n- `$color2` is a *Color* object.\r\n\r\n```php\r\n$distance = Color::dist($color1, $color2);\r\n```\r\n\r\n**Find Contrast**\r\n\r\nFind an optimally contrasting color for another color.\r\n\r\n- `$color1` is a *Color* object.\r\n- `$color2` is a *Color* object, and will default to *null*.\r\n- `$minContrast` is a number between *1* and *21* indicating the minimum valid contrast, and will default to *4.5*.\r\n- `$stepSize` is a number between *0* and *1* indicating the amount to darken/lighten the color on each iteration, and will default to *0.01*.\r\n\r\n```php\r\n$contrastColor = Color::findContrast($color1, $color2, $minContrast, $stepSize);\r\n```\r\n\r\nIf `$color2` value is *null*, `$color1` will be used instead.\r\n\r\nThis method will tint/shade `$color2` until it meets a minimum contrast threshold with `$color1`, then the new color will be returned. If no valid contrast value can be found, this method will return *null* instead.\r\n\r\n**Mix**\r\n\r\nCreate a new *Color* by mixing two colors together by a specified amount.\r\n\r\n- `$color1` is a *Color* object.\r\n- `$color2` is a *Color* object.\r\n- `$amount` is a number between *0* and *1*.\r\n\r\n```php\r\n$mixed = Color::mix($color1, $color2, $amount);\r\n```\r\n\r\n**Multiply**\r\n\r\nCreate a new *Color* by multiplying two colors together by a specified amount.\r\n\r\n- `$color1` is a *Color* object.\r\n- `$color2` is a *Color* object.\r\n- `$amount` is a number between *0* and *1*.\r\n\r\n```php\r\n$multiplied = Color::multiply($color1, $color2, $amount);\r\n```\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felusivecodes%2Ffyrecolor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Felusivecodes%2Ffyrecolor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felusivecodes%2Ffyrecolor/lists"}