Skip to content

gavinhungry/colorstops

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

colorstops

Mix colors against multiple color stops.

Installation

ES6 Module

import ColorStops from 'colorstops';

Browserify

$ browserify colorstops.js --standalone ColorStops -o colorstops-browser.js

Usage

Constructor

let colorStops = new ColorStops([
   { color: '#FF0000', value: 20 },
   { color: '#00FF00', value: 40 },
   { color: '#0000FF', value: 80 }
]);

hex

Get a mixed hex color string for an input value against the defined color stops.

colorStops.hex(-200); // '#FF0000'
colorStops.hex(20);   // '#FF0000'
colorStops.hex(30);   // '#808000'
colorStops.hex(40);   // '#00FF00'
colorStops.hex(41);   // '#00F906'
colorStops.hex(79);   // '#0006F9'
colorStops.hex(200);  // '#0000FF'

Tests

$ npm run test

License

This software is released under the terms of the MIT license. See LICENSE.

About

Mix colors against multiple color stops

Resources

License

Stars

Watchers

Forks

Packages

No packages published