MCPcopy Index your code
hub / github.com/davidmerfield/randomColor

github.com/davidmerfield/randomColor @0.6.2

repository ↗ · DeepWiki ↗ · release 0.6.2 ↗ · Ask this repo → · + Follow
53 symbols 117 edges 5 files 0 documented · 0% 2 cross-repo links updated 7mo ago0.6.2 · 2025-12-03★ 6,12815 open issues
README

Random Color

A tiny script for generating attractive random colors. See the demo for an explanation and some samples. randomColor has been ported to C#, C++, Go, Haskell, Kotlin, Mathematica, PHP, Python, Raku, Objective-C, Java, R, Reason, Dart, Ruby, Rust, Swift and Typescript.

Demo

To use randomColor in the browser, download the latest minified version of randomColor and include it on your page. Then call the script:

var color = randomColor(); // a hex code for an attractive color

To use randomColor on the server with node.js, install randomColor from npm then call the script:

npm install randomcolor
var randomColor = require('randomcolor'); // import the script
var color = randomColor(); // a hex code for an attractive color

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: red, orange, yellow, green, blue, purple, pink and monochrome are currently supported. If you pass a hexidecimal color string such as #00FFFF, randomColor will extract its hue value and use that to generate colors.

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

count – An integer which specifies the number of colors to generate.

seed - An integer or string which when passed will cause randomColor to return the same color each time.

format – A string which specifies the format of the generated color. Possible values are rgb, rgba, rgbArray, hsl, hsla, hslArray and hex (default).

alpha – A decimal between 0 and 1. Only relevant when using a format with an alpha channel (rgba and hsla). Defaults to a random value.

Examples


// Returns a hex code for an attractive color
randomColor(); 

// Returns an array of ten green colors
randomColor({
   count: 10,
   hue: 'green'
});

// Returns a hex code for a light blue
randomColor({
   luminosity: 'light',
   hue: 'blue'
});

// Returns a hex code for a 'truly random' color
randomColor({
   luminosity: 'random',
   hue: 'random'
});

// Returns a bright color in RGB
randomColor({
   luminosity: 'bright',
   format: 'rgb' // e.g. 'rgb(225,200,20)'
});

// Returns a dark RGB color with random alpha
randomColor({
   luminosity: 'dark',
   format: 'rgba' // e.g. 'rgba(9, 1, 107, 0.6482447960879654)'
});

// Returns a dark RGB color with specified alpha
randomColor({
   luminosity: 'dark',
   format: 'rgba',
   alpha: 0.5 // e.g. 'rgba(9, 1, 107, 0.5)',
});

// Returns a light HSL color with random alpha
randomColor({
   luminosity: 'light',
   format: 'hsla' // e.g. 'hsla(27, 88.99%, 81.83%, 0.6450211517512798)'
});

Core symbols most depended-on inside this repo

defineColor
called by 8
randomColor.js
randomWithin
called by 6
randomColor.js
randomColor
called by 4
randomColor.js
getColorInfo
called by 4
randomColor.js
HSVtoRGB
called by 4
randomColor.js
componentToHex
called by 3
randomColor.js
HSVtoHSL
called by 3
randomColor.js
HexToHSB
called by 2
randomColor.js

Shape

Function 53

Languages

TypeScript100%

Modules by API surface

demo/public/randomColor.min.js22 symbols
randomColor.js19 symbols
demo/source/tests.js4 symbols
demo/public/tests.js4 symbols
demo/index.js4 symbols

Used by 2 indexed graphs manifest dependencies, hub-wide

Dependencies from manifests, versioned

cheerio1.0.0-rc.12 · 1×
clean-css4.1.11 · 1×
esbuild0.19.0 · 1×
fs-extra5.0.0 · 1×
highlight0.2.3 · 1×
highlight.js11.8.0 · 1×
html-minifier4.0.0 · 1×
typeset0.2.6 · 1×

For agents

$ claude mcp add randomColor \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact