Comparing version 1.0.0 to 1.1.0
16
index.js
'use strict'; | ||
const ParkMiller = require('park-miller'); | ||
const stringHash = require('@sindresorhus/string-hash'); | ||
const color = require('color'); | ||
const MAX_INT32 = 2147483647; | ||
const GOLDEN_RATIO_CONJUGATE = 0.618033988749895; | ||
@@ -49,4 +51,18 @@ module.exports = class { | ||
} | ||
color(saturation) { | ||
saturation = saturation || 0.5; | ||
let hue = this.float(); | ||
hue += GOLDEN_RATIO_CONJUGATE; | ||
hue %= 1; | ||
return color({ | ||
h: hue * 360, | ||
s: saturation * 100, | ||
v: 95 | ||
}); | ||
} | ||
}; | ||
module.exports.seed = () => Math.floor(Math.random() * MAX_INT32); |
{ | ||
"name": "randoma", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "User-friendly pseudorandom number generator (PRNG)", | ||
@@ -39,2 +39,3 @@ "license": "MIT", | ||
"@sindresorhus/string-hash": "^1.0.0", | ||
"color": "^2.0.1", | ||
"park-miller": "^1.0.0" | ||
@@ -41,0 +42,0 @@ }, |
@@ -60,2 +60,18 @@ # randoma [![Build Status](https://travis-ci.org/sindresorhus/randoma.svg?branch=master)](https://travis-ci.org/sindresorhus/randoma) | ||
#### random.color([saturation]) | ||
Returns a random [aesthetically pleasing color](https://martin.ankerl.com/2009/12/09/how-to-create-random-colors-programmatically/) as a [`color`](https://github.com/Qix-/color) object. | ||
```js | ||
random.color(0.5).hex().toString() | ||
//=> '#AAF2B0' | ||
``` | ||
##### saturation | ||
Type: `number`<br> | ||
Default: `0.5` | ||
Saturation percentage in the range `0...1`. | ||
*"Pull request welcome" for additional commonly used random methods.* | ||
@@ -62,0 +78,0 @@ |
5040
51
91
3
+ Addedcolor@^2.0.1
+ Addedcolor@2.0.1(transitive)
+ Addedcolor-convert@1.9.3(transitive)
+ Addedcolor-name@1.1.3(transitive)
+ Addedcolor-string@1.9.1(transitive)
+ Addedis-arrayish@0.3.2(transitive)
+ Addedsimple-swizzle@0.2.2(transitive)