1.1.4 • Published 4 years ago

@gradient-js/core v1.1.4

Weekly downloads
13
License
MIT
Repository
-
Last release
4 years ago

@gradient-js/core

gradient-js module for raw (object) gradient output generation

License: MIT

Installation

CLI

Yarn

yarn add @gradient-js/core

Npm

npm install --save @gradient-js/core

CDN

<script src="https://unpkg.com/gradient-js/core@x.x.x/core.js">

Usage

import { Core } from '@gradient-js/core';

const core = new Core();
const gradient = core.get(colors, options);

Inputs

In order to create a gradient you will need to pass an array of colors and an options object to the Core's get method. colors should be an array of strings in any valid css format (rgb(a), hex or hsl(a)). options object consists of following properties:

type CoreOptions = {
  useBezier: boolean;
  interpolation: InterpolationMode;
  samples: number;
  lightnessCorrection: boolean;
};

Where each property can be described as it follows:

OptionTypeDescription
useBezierbooleanDecide whether to use chroma's scale() with bezier interpolation
interpolationchroma.InterpolationModeColor interpolation space, one of: "rgb" | "hsl" | "hsv" | "hsi" | "lab" | "lch" | "hcl" | "lrgb"
samplesnumberAmount of gradient parts in the output
lightnessCorrectionbooleanDecide whether to apply lightness correction to your gradient.

Core's get method will generate an array of chroma.Color objects.