项目作者: robertgonzales

项目描述 :
Color manipulation using getters and setters
高级语言: JavaScript
项目地址: git://github.com/robertgonzales/jscolor.git
创建时间: 2016-11-18T05:25:34Z
项目社区:https://github.com/robertgonzales/jscolor

开源协议:

下载


jscolor

Super simple color manipulation using getters and setters

Install:

  1. npm install --save jscolor

Usage:

  1. import Color from 'jscolor'
  2. let c = new Color('#483d8b')

Read color values without any extra work:

  1. c.r // => 72
  2. c.g // => 61
  3. c.b // => 139
  4. c.a // => 1
  5. c.red // => 72
  6. c.green // => 61
  7. c.blue // => 139
  8. c.alpha // => 1
  9. c.rgb // => 'rgb(72,61,139)'
  10. c.rgba // => 'rgba(72,61,139,1)'
  11. c.h // => 248
  12. c.s // => 39
  13. c.l // => 39
  14. c.hue // => 248
  15. c.saturation // => 39
  16. c.lightness // => 39
  17. c.hsl // => hsl(248,39%,39%)
  18. c.hsla // => hsla(248,39%,39%,1)
  19. c.hex // => '#483d8b'
  20. c.yiq // => 73.181
  21. c.name // => 'darkslateblue'

Manipulate colors using normal operators:

  1. c.r = 100
  2. c.rgb // => 'rgb(100,61,139)'
  3. c.hex // => '#643d8b'
  4. c.hue += 180
  5. c.rgb // => 'rgb(129,139,61)'
  6. c.hex // => '#648b3d'
  7. c.rgb = 'rgb(150,170,180)'
  8. c.hsl // => 'hsl(200,17%,65%)'
  9. c.hex // => '#96aab4'