PHPackages                             popphp/pop-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. popphp/pop-color

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

popphp/pop-color
================

Pop Color Component for Pop PHP Framework

1.0.3(6mo ago)22.8k4BSD-3-ClausePHPPHP &gt;=8.3.0CI passing

Since Nov 9Pushed 6mo ago1 watchersCompare

[ Source](https://github.com/popphp/pop-color)[ Packagist](https://packagist.org/packages/popphp/pop-color)[ Docs](https://github.com/popphp/pop-color)[ RSS](/packages/popphp-pop-color/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (4)Dependencies (1)Versions (8)Used By (4)

pop-color
=========

[](#pop-color)

[![Build Status](https://github.com/popphp/pop-color/workflows/phpunit/badge.svg)](https://github.com/popphp/pop-color/actions)[![Coverage Status](https://camo.githubusercontent.com/684f59fa1d18b61507874d68cc998dac94403dd35a04b04f7bb5cbe45c8dc100/687474703a2f2f63632e706f707068702e6f72672f636f7665726167652e7068703f636f6d703d706f702d636f6c6f72)](http://cc.popphp.org/pop-color/)

[![Join the chat at https://discord.gg/TZjgT74U7E](https://camo.githubusercontent.com/acad7b0eeb78b78d08ffd2b85681ab243436388b5f86f8bcb956a69246e53739/68747470733a2f2f6d656469612e706f707068702e6f72672f696d672f646973636f72642e737667)](https://discord.gg/TZjgT74U7E)

- [Overview](#overview)
- [Install](#install)
- [Quickstart](#quickstart)

Overview
--------

[](#overview)

Pop Color is a helpful component to manage different types of color values and conversions. Supported color formats include:

- RGB
- HEX
- HSL
- CMYK
- Grayscale

Within the Pop PHP Framework, the `pop-css`, `pop-image` and `pop-pdf` components use this component.

[Top](#pop-color)

Install
-------

[](#install)

Install `pop-color` using Composer.

```
composer require popphp/pop-color

```

Or, require it in your composer.json file

```
"require": {
    "popphp/pop-color" : "^1.0.3"
}

```

[Top](#pop-color)

Quickstart
----------

[](#quickstart)

### Create a color object

[](#create-a-color-object)

```
$rgb = Color::rgb(120, 60, 30, 0.5);
echo $rgb . PHP_EOL;
```

The above command will print the default CSS format:

```
rgba(120, 60, 30, 0.5)

```

### Convert to another color format

[](#convert-to-another-color-format)

```
$hex = $rgb->toHex();
echo $hex . PHP_EOL;
```

```
#783c1e

```

```
$hsl = $hex->toHsl();
echo $hsl . PHP_EOL;
```

```
hsl(20, 75%, 47%)

```

```
// Will print a string of space-separated values, common to the PDF color string format
$cmyk = $rgb->toCmyk();
echo $cmyk . PHP_EOL;
```

```
0 0.5 0.75 0.53

```

### Accessing Color Properties

[](#accessing-color-properties)

```
$rgb = Color::rgb(120, 60, 30, 0.5);
echo $rgb->getR() . PHP_EOL;
echo $rgb->getG() . PHP_EOL;
echo $rgb->getB() . PHP_EOL;
echo $rgb->getA() . PHP_EOL;
```

```
120
60
30
0.5

```

```
$cmyk = Color::cmyk(60, 30, 20, 50);
echo $cmyk->getC() . PHP_EOL;
echo $cmyk->getM() . PHP_EOL;
echo $cmyk->getY() . PHP_EOL;
echo $cmyk->getK() . PHP_EOL;
```

```
60
30
20
50

```

### Parse Color Strings

[](#parse-color-strings)

```
$rgb = Color::parse('rgba(120, 60, 30, 0.5)');
echo $rgb->getR() . PHP_EOL;
echo $rgb->getG() . PHP_EOL;
echo $rgb->getB() . PHP_EOL;
echo $rgb->getA() . PHP_EOL;
echo $rgb . PHP_EOL;
```

```
120
60
30
0.5
rgba(120, 60, 30, 0.5)

```

[Top](#pop-color)

###  Health Score

44

—

FairBetter than 92% of packages

Maintenance67

Regular maintenance activity

Popularity23

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity62

Established project with proven stability

 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 ~240 days

Total

4

Last Release

194d ago

PHP version history (3 changes)1.0.0PHP &gt;=8.1.0

1.0.1PHP &gt;=8.2.0

1.0.3PHP &gt;=8.3.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/c19dee900e9e20039c723cc403f76b5c22ac2dddb3f86773ae64fb082d4949e2?d=identicon)[nicksagona](/maintainers/nicksagona)

---

Top Contributors

[![nicksagona](https://avatars.githubusercontent.com/u/898670?v=4)](https://github.com/nicksagona "nicksagona (16 commits)")

---

Tags

rgbhexcmykhsllabgrayscalegraycolor converstioncolor valuescolor management

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/popphp-pop-color/health.svg)

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

###  Alternatives

[paragonie/constant_time_encoding

Constant-time Implementations of RFC 4648 Encoding (Base-64, Base-32, Base-16)

901329.7M148](/packages/paragonie-constant-time-encoding)[ssnepenthe/color-utils

A PHP library for performing SASS-like color manipulations.

631.1M10](/packages/ssnepenthe-color-utils)[tecnickcom/tc-lib-color

PHP library to manipulate various color representations

247.2M9](/packages/tecnickcom-tc-lib-color)[ozdemirburak/iris

PHP library for color manipulation and conversion.

1201.7M16](/packages/ozdemirburak-iris)[spatie/color

A little library to handle color conversions

38018.9M28](/packages/spatie-color)[fjw/color-compare

A library for converting colors (Hex, RGB, HSL, CIELAB (LAB), DIN-99) and calculating color distances based on DIN-99.

1310.0k](/packages/fjw-color-compare)

PHPackages © 2026

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