• Stars
    star
    235
  • Rank 171,079 (Top 4 %)
  • Language
    PHP
  • License
    MIT License
  • Created almost 10 years ago
  • Updated about 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A color generator for PHP

Random Color

PHP version

For generating attractive random colors.

This is a PHP port of David Merfield randomColor Javascript utility.

See the results on the demo.

Demo

Options

You can pass an options object to influence the type of color it produces. The options object accepts the following properties:

hue – Controls the hue of the generated color. You can pass a string representing a color name (e.g. 'orange'). Possible color names are red, orange, yellow, green, blue, purple, pink and monochrome. You can also pass an array of multiple hues or a specific hue (0 to 360).

luminosity – Controls the luminosity of the generated color. You can pass a string containing bright, light or dark.

format – A string which specifies the format of the generated color. Possible values are hsv, hsl, hslCss, rgb, rgbCss, and hex.

prng – A random (or not) number generator. mt_rand is used as default one.

Examples

use \Colors\RandomColor;

// Returns a hex code for an attractive color
RandomColor::one(); 

// Returns an array of ten green colors
RandomColor::many(10, array(
   'hue' => 'green'
));

// Returns a hex code for a light blue
RandomColor::one(array(
   'luminosity' => 'light',
   'hue' => 'blue'
));

// Returns one yellow or blue color
RandomColors::one(array(
    'hue' => array('yellow', 'blue')
));

// Returns a hex code for a 'truly random' color
RandomColor::one(array(
   'luminosity' => 'random',
   'hue' => 'random'
));

// Returns a bright color in RGB
RandomColor::one(array(
   'luminosity' => 'bright',
   'format' => 'rgbCss' // e.g. 'rgb(225,200,20)'
));

Other languages

RandomColor is available in JavaScript, C#, C++, Go, Haskell, Kotlin, Mathematica, Python, Swift, Perl6, Objective-C, Java, R, Reason, Dart, Ruby and Rust

License

This project is licensed under the terms of the MIT license.

More Repositories

1

jQuery-QueryBuilder

jQuery plugin offering an interface to create complex queries
JavaScript
1,680
star
2

tinygradient

Fast and small gradients manipulation, built on top of TinyColor
JavaScript
194
star
3

jekyll-bootstrap-doc

Simple documentation template for Github pages
HTML
89
star
4

angular-jqcloud

AngularJS directive for jQCloud 2 plugin
35
star
5

HyperCube

Dart
22
star
6

jQuery.extendext

jQuery.extend with configurable behaviour for arrays
JavaScript
21
star
7

squareicon

JavaScript library for generating abstract images from unique identifiers.
JavaScript
17
star
8

three.js-examples

A Bower package only containing the JavaScript files of the Three.js examples.
JavaScript
16
star
9

Rainmeter-Collection

Some Rainmeter skins I did when I was bored
NASL
12
star
10

angular-smilies

AngularJS filter & directive for smilies parsing
JavaScript
11
star
11

Rainmeter-TopProcesses

A Rainmeter plugin to show n-number of top processes by either memory or CPU consumption.
C#
10
star
12

UMWP-Autochanger

UMWP Autochanger is a little tool for multi-monitors users. It randomly and periodically changes the wallpaper of all your monitors and manages sets of wallpapers, allowing you to quickly change which images are used.
C++
8
star
13

Nixie-Clock-IN12

C++
4
star
14

Rainmeter-NowPlayingPlex

A Rainmeter plugin to read the currently playing track on Plex.
C#
4
star
15

Piwigo-PhotoSphere

Add a Photo Sphere viewer to Piwigo
JavaScript
4
star
16

CircleLamp

C++
3
star
17

Rainmeter-Tron-MCP

Full featured Rainmeter monitoring suite inspired by Tron movies.
HTML
2
star
18

Github-Network

A custom clone of the Github network view
JavaScript
2
star
19

hain-plugin-rss

RSS feed reader for Hain launcher
JavaScript
1
star
20

Rainmeter-NowPlayingJellyfin

A Rainmeter plugin to read the currently playing track on Jellyfin.
C#
1
star
21

grunt-qunit-blanket-lcov

Save LCOV reports generated by Blanket for Grunt QUnit.
JavaScript
1
star
22

rpi-led-matrix-server

A simple C++ program to display a slideshow of images on a HUB75 matrix display.
C++
1
star
23

PikaExplorer

A Pokemon Red/Blue/Yellow save game parser writen in JavaScript.
CSS
1
star