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

chromath

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chromath

JavaScript color conversion and manipulation functions

  • 0.0.7
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
193
decreased by-11.06%
Maintainers
1
Weekly downloads
 
Created
Source

chromath

Overview

chromath provides provides many color conversion and manipulation functions.

You can:

  • Create a color from just about any reasonable string
  • Convert from one color space to another (rgb->hex, hsv->hsl, rgb->hex->hsl->rgb)
  • Add two colors (using additive or subtractive color)
  • Get a color scheme (complement, split complement, triad, tetrad, etc) based on a color
  • Lots more. Take a look at the docs

Getting started

In the browser:

<script src="/path/to/chromath.js"></script>

In NodeJS:

npm install chromath

then

var Chromath = require('chromath')

From there, the usage is identical in both environments.

Functional or Object-oriented

You can use chromath in a functional or object-oriented manner.

var red = new Chromath('rgb(255, 0, 0)');
red.towards('yellow', 0.5).toString(); // #FF7F00

is the same as

Chromath.towards('red', 'yellow', 0.5).toString(); // #FF7F00

The only difference between instance methods and Class methods with the same name (e.g, Chromath.tint and tint) is that the instance methods pass the instance value as the first argument.

Here's the definition of Chromath.prototype.tint:

tint: function (by) {
    return Chromath.tint(this, by);
}

In NodeJS you can only pull in the portions you're interesed in, e.g:

> var fromRGBToHex = require('chromath').rgb2hex
> fromRGBToHex(234, 56, 78)
'#EA384E'

Documentation

http://JFSIII.org/project/chromath/docs/

License

MIT

Bitdeli Badge

Keywords

FAQs

Package last updated on 01 Aug 2016

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