PHPackages                             byteforge/color-randomizer - 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. byteforge/color-randomizer

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

byteforge/color-randomizer
==========================

This could be used in various cases of color. Amzing things like generating random colors and many more.

v1.0.3(2y ago)09MITPHP

Since Apr 9Pushed 2y ago1 watchersCompare

[ Source](https://github.com/muslimdevhamid/color-randomizer-package)[ Packagist](https://packagist.org/packages/byteforge/color-randomizer)[ RSS](/packages/byteforge-color-randomizer/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (5)Used By (0)

Color Randomizer
================

[](#color-randomizer)

Overview
--------

[](#overview)

Color Randomizer is a comprehensive toolkit for color manipulation and generation. Designed to provide a plethora of functionalities ranging from the generation of random colors to the conversion between color formats, it caters to a wide array of needs for developers and designers alike. Boasting a library of over 450 colors, Color Randomizer ensures both accuracy and variety in its outputs. Key features include:

- Generating single or multiple random colors
- Converting between hex and RGB color formats
- Accessing a library of over 450 featured colors
- Comparing two colors to determine their difference
- Calculating color brightness
- Extracting the RGB components from an RGB string
- Retrieving HTML color codes for over 450 colors
- Finding the closest matching color name for a given color code
- Discovering similar or complementary colors
- Showcasing all supported colors in an aesthetically pleasing manner

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

[](#installation)

You Can Install The Package via Composer,

```
composer require byteforge/color-randomizer
```

You only require laravel^6 to effortlessly install the Color Randomizer Package. No additional dependencies are necessary; just stick to the default Laravel setup.

Usage Guidelines
----------------

[](#usage-guidelines)

### Generate a Single Random Color

[](#generate-a-single-random-color)

The `getSingleColor` function within Color Randomizer offers a flexible and customizable approach to generating random colors, suitable for various applications such as dynamically changing website backgrounds. Below are examples of how to use this function in different scenarios.

**Example Usage:**

```
use ByteForge\ColorRandomizer\ColorRandomizer;

// Example code...

// Generating a color without its name
$color = ColorRandomizer::getSingleColor(hex: true, minBrightness: 30, maxBrightness: 255, withMostMatchedName: false);

// Generating a color with its name
$color = ColorRandomizer::getSingleColor(hex: true, minBrightness: 30, maxBrightness: 255, withMostMatchedName: true, formattedName: true);
```

#### Parameters Explained:

[](#parameters-explained)

- `hex`: Determines the format of the returned color code. true for hex format, false for RGB format.
- `minBrightness & maxBrightness`: Control the brightness of the generated color, where a higher value results in a lighter color, and a lower value results in a darker color. Note: $maxBrightness should not exceed 255.
- `withMostMatchedName`: When set to true, the function returns an array with name and color\_code, providing the closest matched color name. When false, only the color code is returned as a string.
- `formattedName`: Specifies the format of the returned color name when $withMostMatchedName is true. true for a formatted name (e.g., 'Alice Blue'), false for the raw name (e.g., 'alice blue'). By leveraging these features, users can easily incorporate dynamic color functionalities into their projects, enhancing aesthetics and user experience.

### Generate Multiple Random Colors

[](#generate-multiple-random-colors)

`getMultipleColors` This function utilize everything of `getSingleColor`, It just have an extra Argument At first That is the quantity of color, you want to get. It'll return you an array containing all the colors, or an all the arrays containing name and color\_code.

**Example Usage:**

```
// Other Codes..
$colors = ColorRandomizer::getMultipleColors(colorsAmount: 4, hex: true, minBrightness: 30, maxBrightness: 255, withMostMatchedName: true, formattedName: true); // returns an array like, [['name'=> Blue, 'color_code' => '#0000FF'], ['name' => 'Alice Blue', 'color_code' => '#F0F8FF' ...]]

$colors = ColorRandomizer::getMultipleColors(colorsAmount: 4, hex: true, minBrightness: 30, maxBrightness: 255, withMostMatchedName: false) ;// returns an array like, ['#ED872D', '#483D8B', '#DE3163' ...]
```

### Access Our An Array Containing All 450+ Colors

[](#access-our-an-array-containing-all-450-colors)

It's so simple, You can easily get all of my 450+ Color Hard work in a second through ColorRandomizer::getColors() or ColorRandomizer::$colors.

**Example Usage:**

```
// 1st way
$colors = ColorRandomizer::getColors(formatNames: true); // You are able to Format Names through The function, This makes it better than the 2nd way.

// 2nd way
$colors = ColorRandomizer::$colors; // Color Names wont be formatted
```

#### RGB TO HEX &amp; HEX TO RGB

[](#rgb-to-hex--hex-to-rgb)

We provide the best and easiest way to convert RGB To Hex and Hex To RGB.

**Example Usage:**

```
// RGB To Hex

// 1st Way
$hex = ColorRandomizer::rgbToHex(fullRGB: "5, 91, 230"); // Make Sure You Specify The Argument Name Like 'fullRGB: $myRGB'. You can also give the RGB like rgb(5, 91, 230),
// Returns #055be6

// 2nd Way
$hex = ColorRandomizer::rgbToHex(r: 5, g: 91, b: 230); // Make Sure You Specify The Argument Name Like 'r:, g: and b:',
// Returns #055be6

// Hex To RGB
$rgb = ColorRandomizer::hexToRgb(hex: '#055be6');
// returns rgb(5, 91, 230)
```

### Calculate Brightness And Difference Beetwen 2 Colors

[](#calculate-brightness-and-difference-beetwen-2-colors)

We Provide 90%+ Accurate Results On the calculations. Easy &amp; The Best Way for color calculation.

**Example Usage:**

```
// Get Color Difference Between 2 colors
$colorDifference = ColorRandomizer::colorDifference(color1: '#0548e6', color2: '#05a6e6', hex: true); // Hex refers that your color1 and color2 is Hex or RGB.
// returns 94. Similar Colors Threshold Could Be 130

// Get Color Brightness
$colorBrightness = ColorRandomizer::calculateBrightness(rgbOrHex: '#0548e6', type: 'hex'); // type must be hex or rgb, Its for verifying your Color code Type.
// returns 69
```

### Extract Red, Green, Blue From Full RGB

[](#extract-red-green-blue-from-full-rgb)

Extract Red, Green And Blue From A Full RGB Through Just Line Of code.

**Example Usage:**

```
$rgbArray = ColorRandomizer::extractRGBComponents(colorString: "rgb(5, 91, 230)") // returns ['r' => 5, 'g' => 91, 'b' => 230'];
```

### Get Color Code From Color Name

[](#get-color-code-from-color-name)

We support `450+ Color` and search through them to get you the most Accurate color code in accordance of color name.

```
$colorCode = ColorRandomizer::getCodesFromHtmlColors(hex: true, name: 'dandelion') // returns #F0E130;
```

### Get Most Matched Color Name From Color Code

[](#get-most-matched-color-name-from-color-code)

The Best Color Name Finding function with Color code over 95% Accurate Results.

```
$colorName = ColorRandomizer::getNearestNameFromCode(hex: true, rgbOrHex: '#05e676'); // returns 'spring green'
// You can use ucwords($colorName) to format the words 1st letter to uppercase
```

### Get Similar Colors

[](#get-similar-colors)

The Similar Colors Function Always you to Get Similar Colors/Colors Related to the Color you give, ('Disclaimer For Custom Colors, For Fullfilling Colors Amount you may use custom color but it may make your web page a lot slower. So Not using the Custom Colors is preffered')

```
$similarColors = ColorRandomizer::getSimilarColors(rgbOrHex: '#FFB7C5', goalAmount: 7, hex: true, maxDifference: 100, minDifference: 0.5, allowCustomColors: false);
/* It'll return an array containing other arrays like,
[["name" => "Carnation Pink", "hex" => "FFA6C9", "rgb" => "rgb(255, 166, 201)", "difference" => 17.464249196573] ... more]
*/
```

### All Colors Page Configuration

[](#all-colors-page-configuration)

Configure That The All Colors Page is Visible And The Route Of the Page,

**Configure On ENV:**

```
COLOR_RANDOMIZER_COLOR_PAGE_ROUTE = '/all-colors'
COLOR_RANDOMIZER_COLOR_PAGE = true
```

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity44

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

Total

4

Last Release

769d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/737c2b7d9ce3f52acb5b24a7695d962859ca838a2adf3a05e4e3facf9ae40d74?d=identicon)[Abdul Hamid](/maintainers/Abdul%20Hamid)

---

Top Contributors

[![muslimdevhamid](https://avatars.githubusercontent.com/u/149595767?v=4)](https://github.com/muslimdevhamid "muslimdevhamid (10 commits)")

### Embed Badge

![Health badge](/badges/byteforge-color-randomizer/health.svg)

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

PHPackages © 2026

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