Giter VIP home page Giter VIP logo

color.js's Introduction

color.js

A tiny library for color management.

Example usage

var header    = color("red");             // header.rgb()     => "rgb(255, 0, 0)"
var paragraph = header.clone().lum(20);   // paragraph.rgb()  => "rgb(255, 102, 102)"

Properties

Property Description
input The argument passed to the color function. It can be a color string or an RGB array.
type Type of the color, e.g., "rgb", "rgba", "hsl", "hsla".
values Color values for the given type of color, e.g., [255, 0, 0] for "red" in "rgb".

Methods

Conversion Description Usage Output
hex() Returns color in hex format. color("red").hex() "#ff0000"
rgb() Returns color in RGB format. color("red").rgb() "rgb(255, 0, 0)"
rgba() Returns color in RGBA format.
If the color doesn't have alpha value, it is set to 1.
color("red").rgba() "rgba(255, 0, 0, 1)"
hsl() Returns color in HSL format. color("red").hsl() "hsl(0, 100%, 50%)"
hsla() Returns color in HSLA format.
If the color doesn't have alpha value, it is set to 1.
color("red").hsla() "hsla(0, 100%, 50%, 1)"
Modification Description Usage
hue() Shifts the hue by the entered amount. color("red").hue(70)
sat() Increases/decreases the saturation by the entered amount. color("slateblue").sat(20)
lum() Increases/decreases the luminosity by the entered amount. color("slateblue").lum(-20)
alpha() Increases/decreases the alpha (opacity) by the entered amount. color("slateblue").alpha(-0.25)

First three methods, converts the color to HSL format, and then applies the change. If your color is in Hex or RGB format, you'll end up with HSL.

color.js's People

Contributors

akinuri avatar

Stargazers

Andrés Muñoz avatar

Watchers

James Cloos avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.