0.0.2 • Published 11 months ago

color-variation-generator v0.0.2

Weekly downloads
-
License
MIT
Repository
-
Last release
11 months ago

color-variation-generator

generateColorVariation is a function that generates random colors in a similar color range based on a given base hue value. It can be used to create multiple colors for gradient effects, and the colors are based on HSL (Hue, Saturation, Lightness) values.

Installation

You can install the package using npm:

npm install color-variation-generator

Or you can use yarn:

yarn add color-variation-generator

Usage

This package provides the generateColorVariation function. You can import and use it as follows:

import { generateColorVariation } from "color-variation-generator";

const color = generateColorVariation({
  baseHue: 200,
  hueVariance: 50,
  gradientIndex: 0,
  gradientSteps: 5,
});

console.log(color); // Example output: "#4da6ff"

Parameters

ParameterTypeDescription
baseHuenumberThe base hue value, which is a number between 0 and 360. Similar colors are generated based on this value.
hueVariancenumberThe range of variation for the hue value, which is a number between 0 and 360. This value determines the difference between colors.
gradientIndexnumberThe index of the current color in the array of generated colors. This is mainly used for creating gradient effects.
gradientStepsnumberThe total number of colors to generate, required when creating colors for gradient effects.

Example Values for baseHue

Hue ValueColor
0Red
60Yellow
120Green
180Cyan
240Blue
300Magenta

Example Values for hueVariance

Hue VarianceDescription
0Colors are generated with no variation from the base hue.
50Colors are generated within a ±25 range of the base hue.
100Colors are generated within a ±50 range of the base hue.

Return

The function returns a hex color code as a string, such as #4da6ff.

License

This package is licensed under the MIT License.

0.0.2

11 months ago

0.0.1

11 months ago