PHP code example of mistic100 / randomcolor

1. Go to this page and download the library: Download mistic100/randomcolor library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

mistic100 / randomcolor example snippets



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)'
));

// Returns a RGB color with random alpha
RandomColor::one(array(
   'format': 'rgbaCss', // e.g. 'rgba(9, 1, 107, 0.648)'
));

// Returns an hex color with specified alpha
RandomColor::one(array(
   'format': 'hexa',
   'alpha': 0.5, // e.g.: #c17d3480
));