Socket
Socket
Sign inDemoInstall

jscolor

Package Overview
Dependencies
0
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

jscolor

Super simple color manipulation using getters and setters


Version published
Maintainers
1
Weekly downloads
193
increased by19.88%
Install size
39.9 kB

Weekly downloads

Readme

Source

jscolor

Super simple color manipulation using getters and setters

Install:

npm install --save jscolor

Usage:

import Color from 'jscolor'

let c = new Color('#483d8b')

Read color values without any extra work:

c.r           // => 72
c.g           // => 61
c.b           // => 139
c.a           // => 1
c.red         // => 72
c.green       // => 61
c.blue        // => 139
c.alpha       // => 1
c.rgb         // => 'rgb(72,61,139)'
c.rgba        // => 'rgba(72,61,139,1)'
c.h           // => 248
c.s           // => 39
c.l           // => 39
c.hue         // => 248
c.saturation  // => 39
c.lightness   // => 39
c.hsl         // => hsl(248,39%,39%)
c.hsla        // => hsla(248,39%,39%,1)
c.hex         // => '#483d8b'
c.yiq         // => 73.181
c.name        // => 'darkslateblue'

Manipulate colors using normal operators:

c.r = 100
c.rgb         // => 'rgb(100,61,139)'
c.hex         // => '#643d8b'

c.hue += 180
c.rgb         // => 'rgb(129,139,61)'
c.hex         // => '#648b3d'

c.rgb = 'rgb(150,170,180)'
c.hsl         // => 'hsl(200,17%,65%)'
c.hex         // => '#96aab4'

Keywords

FAQs

Last updated on 28 Aug 2017

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc