PHPackages                             emotality/laravel-color - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. emotality/laravel-color

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

emotality/laravel-color
=======================

A Laravel package to retrieve information from colors, convert and more.

1.2.3(1y ago)01.5k1MITPHPPHP &gt;=7.3

Since Feb 2Pushed 1y ago1 watchersCompare

[ Source](https://github.com/emotality/laravel-color)[ Packagist](https://packagist.org/packages/emotality/laravel-color)[ Docs](https://github.com/emotality/laravel-color)[ Fund](https://www.buymeacoffee.com/emotality)[ GitHub Sponsors](https://github.com/emotality)[ RSS](/packages/emotality-laravel-color/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (2)Versions (9)Used By (0)

Laravel Color
=============

[](#laravel-color)

 [![License](https://camo.githubusercontent.com/189ebead9f1f4d787bd390f8cdeb74d71b17b7f5c5ecc020f67139c8e88e6772/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f656d6f74616c6974792f6c61726176656c2d636f6c6f72)](https://packagist.org/packages/emotality/laravel-color) [![Latest Version](https://camo.githubusercontent.com/4747a12c5cad791faaffe82f159bee045c78b66ed10fa3b7a7848e6602c3b627/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f656d6f74616c6974792f6c61726176656c2d636f6c6f72)](https://packagist.org/packages/emotality/laravel-color) [![Total Downloads](https://camo.githubusercontent.com/1dc37d726f9e411236b511c60b8508aa60414dfc93eba8b2ecf3be96d85de76a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f656d6f74616c6974792f6c61726176656c2d636f6c6f72)](https://packagist.org/packages/emotality/laravel-color)

A Laravel package to retrieve information from colors, convert and more.

⚠️ **Note:** This package is a work-in-progress, rather fork it! 🚧

Requirements
------------

[](#requirements)

- PHP 7.3+
- Laravel 8+

Installation
------------

[](#installation)

```
composer require emotality/laravel-color
```

Usage
-----

[](#usage)

```
use Emotality\LaravelColor\Color;

$value = Color::parse('#ff2830')->functionName();
// or
$color = Color::parse('#ff2830');
$value1 = $color->functionName(); // see functions below
$value2 = $color->functionName(); // see functions below
```

Functions can also be called directly without parsing the color with `parse()`:

```
use Emotality\LaravelColor\Color;

$value = Color::functionName('#ff2830'); // see functions below
```

As this is a Facade, it can just be called without an import like this:

```
$value = \Color::functionName('#ff2830'); // see functions below
```

This package also supports `hex8` which includes the alpha:

```
$color = \Color::parse('#ff283080');
$alpha = $color->rgba()->alpha; // 0.502 (50%)
```

### Examples:

[](#examples)

```
$black = '#000';
$is_dark = \Color::isDark($black); // true
$font_color = \Color::fontColor($black); // #ffffff
```

```
// #ff2830 has a brightness of 41 :
$font_color = \Color::fontColor('#ff2830', 30); // #000000
$font_color = \Color::fontColor('#ff2830', 50); // #ffffff
```

```

    ...

```

Functions
---------

[](#functions)

```
function hex(): string;
function hex8(): string;
function rgb(string $hex = null): object;
function rgba(string $hex = null): object;
function hsl(string $hex = null): object;
function hsv(string $hex = null): object;
function hue(string $hex = null): int;
function value(string $hex = null): int;
function luminance(string $hex = null): float;
function lightness(string $hex = null): int;
function brightness(string $hex = null): int;
function isDark(string $hex = null, int $contrast = null): bool;
function isLight(string $hex = null, int $contrast = null): bool;
function fontColor(string $hex = null, int $contrast = null): string;
function toJson(): string;
function toArray(): array;
function toObject(): object;
// more coming soon!
```

Please see all functions [here](https://github.com/emotality/laravel-color/blob/1.x/src/Interfaces/ColorFunctions.php).

#### toArray() for `#ff283080` :

[](#toarray-for-ff283080-)

```
array:22 [
  "hex" => "#ff2830"
  "hexdec" => 16721968
  "hex8" => "#ff283080"
  "hex8dec" => 4280823935
  "red" => 1               // out of 1
  "green" => 0.15686       // out of 1
  "blue" => 0.18824        // out of 1
  "alpha" => 0.502         // out of 1
  "rgb" => array:3 [
    "red" => 255           // out of 255
    "green" => 40          // out of 255
    "blue" => 48           // out of 255
  ]
  "rgba" => array:4 [
    "red" => 255           // out of 255
    "green" => 40          // out of 255
    "blue" => 48           // out of 255
    "alpha" => 0.502       // out of 1
  ]
  "hsl" => array:3 [
    "hue" => 358           // out of 360
    "saturation" => 100    // out of 100
    "lightness" => 58      // out of 100
  ]
  "hsv" => array:3 [
    "hue" => 358           // out of 360
    "saturation" => 84     // out of 100
    "value" => 100         // out of 100
  ]
  "hue" => 358             // out of 360
  "value" => 100           // out of 100
  "luminance" => 22.99     // out of 100
  "lightness" => 58        // out of 100
  "brightness" => 41       // out of 100
  "dark" => true
  "light" => false
  "font_color" => "#ffffff"
  "shades" => array:21 [
    0 => "#ff2830"
    5 => "#f2262e"
    10 => "#e6242b"
    15 => "#d92229"
    20 => "#cc2026"
    25 => "#bf1e24"
    30 => "#b31c22"
    35 => "#a61a1f"
    40 => "#99181d"
    45 => "#8c161a"
    50 => "#801418"
    55 => "#731216"
    60 => "#661013"
    65 => "#590e11"
    70 => "#4d0c0e"
    75 => "#400a0c"
    80 => "#33080a"
    85 => "#260607"
    90 => "#1a0405"
    95 => "#0d0202"
    100 => "#000000"
  ]
  "tints" => array:21 [
    0 => "#ff2830"
    5 => "#ff333a"
    10 => "#ff3e45"
    15 => "#ff484f"
    20 => "#ff5359"
    25 => "#ff5e64"
    30 => "#ff696e"
    35 => "#ff7378"
    40 => "#ff7e83"
    45 => "#ff898d"
    50 => "#ff9498"
    55 => "#ff9ea2"
    60 => "#ffa9ac"
    65 => "#ffb4b7"
    70 => "#ffbfc1"
    75 => "#ffc9cb"
    80 => "#ffd4d6"
    85 => "#ffdfe0"
    90 => "#ffeaea"
    95 => "#fff4f5"
    100 => "#ffffff"
  ]
]

```

License
-------

[](#license)

laravel-color is released under the MIT license. See [LICENSE](https://github.com/emotality/laravel-color/blob/master/LICENSE) for details.

###  Health Score

32

—

LowBetter than 69% of packages

Maintenance41

Moderate activity, may be stable

Popularity21

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~107 days

Recently: every ~183 days

Total

8

Last Release

494d ago

PHP version history (2 changes)1.0.0PHP &gt;=7.2.5

1.0.5PHP &gt;=7.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/0edff3a3b92fcabd1418b4af5a91783ba51d122e0e1d0b06603102b856ae099b?d=identicon)[emotality](/maintainers/emotality)

---

Top Contributors

[![emotality](https://avatars.githubusercontent.com/u/2683462?v=4)](https://github.com/emotality "emotality (12 commits)")

---

Tags

laravelcolorrgbhexhslhsv

###  Code Quality

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/emotality-laravel-color/health.svg)

```
[![Health](https://phpackages.com/badges/emotality-laravel-color/health.svg)](https://phpackages.com/packages/emotality-laravel-color)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[ozdemirburak/iris

PHP library for color manipulation and conversion.

1201.9M23](/packages/ozdemirburak-iris)[renatomarinho/laravel-page-speed

Laravel Page Speed

2.5k1.7M11](/packages/renatomarinho-laravel-page-speed)[ssnepenthe/color-utils

A PHP library for performing SASS-like color manipulations.

631.2M16](/packages/ssnepenthe-color-utils)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
