Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

color-between

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

color-between

get a gradient color between two colors

  • 1.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
686
decreased by-34.1%
Maintainers
1
Weekly downloads
 
Created
Source

color-between

NPM version Build status Test coverage Downloads

get a gradient color between two colors.

Installation

$ npm install color-between --save

Usage

get a middle color between two hsl color, with default 0.5 gradient degree:

const colorBetween = require('color-between');

colorBetween('hsl(0, 100%, 100%)', 'hsl(100, 0%, 0%)');
// equal: colorBetween('hsl(0, 100%, 100%)', 'hsl(100, 0%, 0%)', 0.5, 'hsl');
// output: 'hsl(50, 50%, 50%)'

get a color between two colors with a gradient degree:

const colorBetween = require('color-between');

// rgb format
colorBetween('rgb(255, 255, 255)', 'rgb(0, 0, 0)', 0.5, 'rgb');
// output: 'rgb(128, 128, 128)'

// rgba format
colorBetween('rgba(255, 255, 255, .2)', 'rgba(0, 0, 0, .8)', 0.5, 'rgb');
// output: 'rgba(128, 128, 128, 0.5)

// hex format
colorBetween('#fff', '#000', 0.5, 'hex');
// output: '#808080'

// mixed format
colorBetween('#fff', 'rgb(0, 0, 0)', 0.5, 'hsl');
output: 'hsl(0, 0%, 50%)'

API

colorBetween(startColor, endColor, gradientDegree, outputFormat) => color:String

startColor:String and endColor:String

valid color string (eg, hsl(0, 100%, 100%), rgb(100, 100, 100), rgba(0, 0, 0, 0.5), #fff). Also, support input of color package.

gradientDegree:Number

valid number between 0 and 1 (eg, 0.5).

outputFormat:String

output string format type, support these format:

  • hsl
  • rgb
  • hex

color:String

return a color string with outputFormat format type.

Test

npm i
npm test

Keywords

FAQs

Package last updated on 13 Oct 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc