color-spacer
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -1,2 +0,2 @@ | ||
export default function getColors(n: number, { shift, s, v }: { | ||
export declare function getColors(n: number, { shift, s, v }?: { | ||
shift?: number | undefined; | ||
@@ -6,1 +6,2 @@ s?: number | undefined; | ||
}): string[]; | ||
export default getColors; |
@@ -25,3 +25,3 @@ "use strict"; | ||
} | ||
function getColors(n, { shift = 0, s = 1, v = 1 }) { | ||
function getColors(n, { shift = 0, s = 1, v = 1 } = {}) { | ||
const c = v * s; | ||
@@ -33,3 +33,3 @@ const m = v - c; | ||
const [r, g, b] = getColor(i, n, c, m, shift).map((chan) => { | ||
const x = chan.toString(16); | ||
const x = Math.round(chan).toString(16); | ||
return x.length > 1 ? x : '0' + x; | ||
@@ -40,3 +40,4 @@ }); | ||
} | ||
exports.getColors = getColors; | ||
exports.default = getColors; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "color-spacer", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Utility for generating evenly-space colors around an HSV color wheel.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
# color-spacer | ||
Utility for generating evenly-spaced colors around an HSV color wheel. | ||
``` | ||
const { getColors } = require('./dist/index.js'); | ||
getColors(6); // [ '#ff0000', '#ffff00', '#00ff00', '#00ffff', '#0000ff', '#ff00ff' ] | ||
getColors(3); // [ '#ff0000', '#00ff00', '#0000ff' ] | ||
getColors(3, { shift: Math.PI / 6 }); // [ '#ffff00', '#00ffff', '#ff00ff' ] | ||
getColors(3, { s: 0.5 }); // [ '#ff8080', '#80ff80', '#8080ff' ] | ||
getColors(3, { v: 0.5 }); // [ '#800000', '#008000', '#000080' ] | ||
``` |
Sorry, the diff of this file is not supported yet
5513
45
12